mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Checks on Company Ledger sanity
This commit is contained in:
parent
f06fc9f720
commit
ff4f2f3953
@ -298,7 +298,7 @@ class CheckData extends Command
|
||||
$invoice_balance = $client->invoices->where('is_deleted', false)->where('status_id', '>', 1)->sum('balance');
|
||||
$credit_balance = $client->credits->where('is_deleted', false)->sum('balance');
|
||||
|
||||
$invoice_balance -= $credit_balance;
|
||||
// $invoice_balance -= $credit_balance;//doesn't make sense to remove the credit amount
|
||||
|
||||
$ledger = CompanyLedger::where('client_id', $client->id)->orderBy('id', 'DESC')->first();
|
||||
|
||||
@ -388,9 +388,9 @@ class CheckData extends Command
|
||||
foreach (Client::cursor()->where('is_deleted', 0) as $client) {
|
||||
//$invoice_balance = $client->invoices->where('is_deleted', false)->where('status_id', '>', 1)->sum('balance');
|
||||
$invoice_balance = Invoice::where('client_id', $client->id)->where('is_deleted', false)->where('status_id', '>', 1)->withTrashed()->sum('balance');
|
||||
$client_balance = Credit::where('client_id', $client->id)->where('is_deleted', false)->withTrashed()->sum('balance');
|
||||
$credit_balance = Credit::where('client_id', $client->id)->where('is_deleted', false)->withTrashed()->sum('balance');
|
||||
|
||||
$invoice_balance -= $client_balance;
|
||||
// $invoice_balance -= $credit_balance;
|
||||
|
||||
$ledger = CompanyLedger::where('client_id', $client->id)->orderBy('id', 'DESC')->first();
|
||||
|
||||
|
@ -136,11 +136,13 @@ class PaymentMethod
|
||||
foreach ($this->gateways as $gateway) {
|
||||
foreach ($gateway->driver($this->client)->gatewayTypes() as $type) {
|
||||
if (isset($gateway->fees_and_limits) && property_exists($gateway->fees_and_limits, $type)) {
|
||||
if ($this->validGatewayForAmount($gateway->fees_and_limits->{$type}, $this->amount)) {
|
||||
|
||||
if ($this->validGatewayForAmount($gateway->fees_and_limits->{$type}, $this->amount) && $gateway->fees_and_limits->{$type}->is_enabled) {
|
||||
$this->payment_methods[] = [$gateway->id => $type];
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->payment_methods[] = [$gateway->id => $type];
|
||||
//$this->payment_methods[] = [$gateway->id => $type];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,8 +57,10 @@ class HandleCancellation extends AbstractService
|
||||
|
||||
public function reverse()
|
||||
{
|
||||
/* The stored cancelled object - contains the adjustment and status*/
|
||||
$cancellation = $this->invoice->backup->cancellation;
|
||||
|
||||
/* Will turn the negative cancellation amount to a positive adjustment*/
|
||||
$adjustment = $cancellation->adjustment * -1;
|
||||
|
||||
$this->invoice->ledger()->updateInvoiceBalance($adjustment, 'Invoice cancellation REVERSAL');
|
||||
|
Loading…
x
Reference in New Issue
Block a user