Adjustments for check data
This commit is contained in:
parent
c9392978e2
commit
12f6d9d7fc
|
|
@ -568,6 +568,7 @@ class CheckData extends Command
|
|||
});
|
||||
}
|
||||
|
||||
//@deprecated
|
||||
private function clientCreditPaymentables($client)
|
||||
{
|
||||
$results = \DB::select("
|
||||
|
|
@ -587,6 +588,28 @@ class CheckData extends Command
|
|||
return $results;
|
||||
}
|
||||
|
||||
private function clientCreditPaymentablesNew($client)
|
||||
{
|
||||
|
||||
$results = \DB::select("
|
||||
SELECT
|
||||
SUM(paymentables.amount - paymentables.refunded) as credit_payment
|
||||
FROM payments
|
||||
LEFT JOIN paymentables
|
||||
ON
|
||||
payments.id = paymentables.payment_id
|
||||
WHERE paymentable_type = 'invoices'
|
||||
AND paymentables.deleted_at is NULL
|
||||
AND paymentables.amount > 0
|
||||
AND payments.is_deleted = 0
|
||||
AND payments.client_id = ?;
|
||||
", [$client->id]);
|
||||
|
||||
return $results;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function checkPaidToDatesNew()
|
||||
{
|
||||
$clients_to_check = $this->clientPaidToDateQuery();
|
||||
|
|
@ -598,9 +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);
|
||||
// $credits_used_for_payments = $this->clientCreditPaymentables($client);
|
||||
// $total_paid_to_date = $_client->payments_applied + $credits_used_for_payments[0]->credit_payment - $credits_from_reversal;
|
||||
|
||||
$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;
|
||||
|
||||
if (round($total_paid_to_date, 2) != round($_client->client_paid_to_date, 2)) {
|
||||
$this->wrong_paid_to_dates++;
|
||||
|
|
|
|||
Loading…
Reference in New Issue