diff --git a/app/Console/Commands/CheckData.php b/app/Console/Commands/CheckData.php index 6a9f400e69d0..ee12a25b9981 100644 --- a/app/Console/Commands/CheckData.php +++ b/app/Console/Commands/CheckData.php @@ -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(); diff --git a/app/Services/Client/PaymentMethod.php b/app/Services/Client/PaymentMethod.php index a2b0c3c70c3c..e4ea317bac89 100644 --- a/app/Services/Client/PaymentMethod.php +++ b/app/Services/Client/PaymentMethod.php @@ -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]; } } } diff --git a/app/Services/Invoice/HandleCancellation.php b/app/Services/Invoice/HandleCancellation.php index f7d5c83c7442..6f7d71c48868 100644 --- a/app/Services/Invoice/HandleCancellation.php +++ b/app/Services/Invoice/HandleCancellation.php @@ -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');