diff --git a/app/Console/Commands/CheckData.php b/app/Console/Commands/CheckData.php index cc7a4dac00..d855331f21 100644 --- a/app/Console/Commands/CheckData.php +++ b/app/Console/Commands/CheckData.php @@ -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++; diff --git a/app/Http/Controllers/CreditController.php b/app/Http/Controllers/CreditController.php index 4c3bde9932..c76bfd9e9b 100644 --- a/app/Http/Controllers/CreditController.php +++ b/app/Http/Controllers/CreditController.php @@ -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))); diff --git a/openapi/api-docs.yaml b/openapi/api-docs.yaml index 37f608710a..298504c73c 100644 --- a/openapi/api-docs.yaml +++ b/openapi/api-docs.yaml @@ -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 diff --git a/openapi/components/parameters.yaml b/openapi/components/parameters.yaml index 9539b724d9..264ef8dc33 100644 --- a/openapi/components/parameters.yaml +++ b/openapi/components/parameters.yaml @@ -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