1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Adjustments for client balance

This commit is contained in:
David Bomba 2022-03-09 13:49:31 +11:00
parent b0d5117a0f
commit b2b937f9ad
2 changed files with 7 additions and 5 deletions

View File

@ -66,6 +66,8 @@ class PaymentRepository extends BaseRepository {
*/
private function applyPayment(array $data, Payment $payment): ?Payment
{
nlog("applying payment");
nlog($data);
$is_existing_payment = true;
$client = false;

View File

@ -82,6 +82,8 @@ class DeletePayment
$net_deletable = $paymentable_invoice->pivot->amount - $paymentable_invoice->pivot->refunded;
$client = $this->payment->client->fresh();
nlog("net deletable amount - refunded = {$net_deletable}");
if(!$paymentable_invoice->is_deleted)
@ -95,11 +97,9 @@ class DeletePayment
->updateInvoiceBalance($net_deletable, "Adjusting invoice {$paymentable_invoice->number} due to deletion of Payment {$this->payment->number}")
->save();
$paymentable_invoice->client
->service()
->updateBalance($net_deletable)
// ->updatePaidToDate($net_deletable * -1)
->save();
$client = $client->service()
->updateBalance($net_deletable)
->save();
if ($paymentable_invoice->balance == $paymentable_invoice->amount) {
$paymentable_invoice->service()->setStatus(Invoice::STATUS_SENT)->save();