Fixes for deleting payments

This commit is contained in:
David Bomba 2022-03-01 21:25:18 +11:00
parent 93e1fc7185
commit e9e8e259e8
4 changed files with 20 additions and 9 deletions

View File

@ -480,11 +480,11 @@ class CheckData extends Command
LEFT JOIN paymentables
ON
payments.id = paymentables.payment_id
WHERE paymentable_type = 'App\\Models\\Credit'
WHERE paymentable_type = ?
AND paymentables.deleted_at is NULL
AND payments.is_deleted = 0
AND payments.client_id = ?;
"), [$client->id] );
"), [App\Models\Credit::class, $client->id] );
return $results;
}
@ -507,7 +507,7 @@ class CheckData extends Command
$this->wrong_paid_to_dates++;
$this->logMessage($client->present()->name.' id = # '.$client->id." - Paid to date does not match Client Paid To Date = {$client->paid_to_date} - Invoice Payments = {$total_paid_to_date}");
$this->logMessage($client->present()->name.' id = # '.$client->id." - Client Paid To Date = {$client->paid_to_date} != Invoice Payments = {$total_paid_to_date} - {$_client->payments_applied} + {$credits_used_for_payments[0]->credit_payment}");
$this->isValid = false;

View File

@ -362,6 +362,7 @@ class Import implements ShouldQueue
) {
$data['settings']['invoice_design_id'] = 1;
}
$data['settings']['email_sending_method'] = 'default';
$data = $this->transformCompanyData($data);
@ -374,9 +375,6 @@ class Import implements ShouldQueue
$data['subdomain'] = MultiDB::randomSubdomainGenerator();
}
else {
$data['settings']['email_sending_method'] = 'default';
}
$rules = (new UpdateCompanyRequest())->rules();

View File

@ -99,6 +99,6 @@ class ClientService
{
$this->client->save();
return $this->client;
return $this->client->fresh();
}
}

View File

@ -145,10 +145,23 @@ class DeletePayment
$multiplier = -1;
$paymentable_credit->service()
->updateBalance($paymentable_credit->pivot->amount*$multiplier)
->updatePaidToDate($paymentable_credit->pivot->amount*-1)
->updateBalance($paymentable_credit->pivot->amount*$multiplier*-1)
->updatePaidToDate($paymentable_credit->pivot->amount*$multiplier)
->setStatus(Credit::STATUS_SENT)
->save();
$this->payment
->client
->service()
->updatePaidToDate(($paymentable_credit->pivot->amount)*-1)
->save();
//01-03-2022
// $paymentable_credit->service()
// ->updateBalance($paymentable_credit->pivot->amount*$multiplier)
// ->updatePaidToDate($paymentable_credit->pivot->amount*-1)
// ->setStatus(Credit::STATUS_SENT)
// ->save();
});
}