Fixes for reversals
This commit is contained in:
parent
ca3d455225
commit
e4344e0c31
|
|
@ -621,12 +621,12 @@ class CheckData extends Command
|
|||
|
||||
$credits_from_reversal = Credit::withTrashed()->where('client_id', $client->id)->where('is_deleted', 0)->whereNotNull('invoice_id')->sum('amount');
|
||||
|
||||
// $credits_used_for_payments = $this->clientCreditPaymentables($client);
|
||||
// $total_paid_to_date = $_client->payments_applied + $credits_used_for_payments[0]->credit_payment - $credits_from_reversal;
|
||||
$credits_used_for_payments = $this->clientCreditPaymentables($client);
|
||||
$total_paid_to_date = $_client->payments_applied + $credits_used_for_payments[0]->credit_payment - $credits_from_reversal;
|
||||
|
||||
//2025-03-06 - new method
|
||||
$credits_used_for_payments = $this->clientCreditPaymentablesNew($client);
|
||||
$total_paid_to_date = $credits_used_for_payments[0]->credit_payment;
|
||||
// $credits_used_for_payments = $this->clientCreditPaymentablesNew($client);
|
||||
// $total_paid_to_date = $credits_used_for_payments[0]->credit_payment;
|
||||
|
||||
if (round($total_paid_to_date, 2) != round($_client->client_paid_to_date, 2)) {
|
||||
$this->wrong_paid_to_dates++;
|
||||
|
|
|
|||
|
|
@ -213,7 +213,10 @@ class CreditController extends BaseController
|
|||
|
||||
if ($credit->invoice_id) {
|
||||
$credit = $credit->service()->markSent()->save();
|
||||
$credit->client->service()->updatePaidToDate(-1 * $credit->balance)->save();
|
||||
$credit->client->service()->updatePaidToDate(-1 * $credit->balance)->save(); // If we mutate the paid to date, we need to reverse the status of the invoice, this will allow the credit note that has been created to be used and double paid to dates prevented.
|
||||
$invoice = $credit->invoice;
|
||||
$invoice->status_id = \App\Models\Invoice::STATUS_REVERSED;
|
||||
$invoice->save();
|
||||
}
|
||||
|
||||
event(new CreditWasCreated($credit, $credit->company, Ninja::eventVars($user->id)));
|
||||
|
|
|
|||
|
|
@ -15438,6 +15438,13 @@ components:
|
|||
group_settings [The group settings object the client is assigned to]
|
||||
|
||||
```
|
||||
|
||||
Usage:
|
||||
|
||||
```html
|
||||
|
||||
/api/v1/clients?include=contacts,documents,activities
|
||||
```
|
||||
required: false
|
||||
schema:
|
||||
type: string
|
||||
|
|
|
|||
|
|
@ -66,6 +66,13 @@
|
|||
group_settings [The group settings object the client is assigned to]
|
||||
|
||||
```
|
||||
|
||||
Usage:
|
||||
|
||||
```html
|
||||
|
||||
/api/v1/clients?include=contacts,documents,activities
|
||||
```
|
||||
required: false
|
||||
schema:
|
||||
type: string
|
||||
|
|
|
|||
Loading…
Reference in New Issue