mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-03 04:34:35 -04:00
Adjustments for client balance
This commit is contained in:
parent
b0d5117a0f
commit
b2b937f9ad
@ -66,6 +66,8 @@ class PaymentRepository extends BaseRepository {
|
|||||||
*/
|
*/
|
||||||
private function applyPayment(array $data, Payment $payment): ?Payment
|
private function applyPayment(array $data, Payment $payment): ?Payment
|
||||||
{
|
{
|
||||||
|
nlog("applying payment");
|
||||||
|
nlog($data);
|
||||||
|
|
||||||
$is_existing_payment = true;
|
$is_existing_payment = true;
|
||||||
$client = false;
|
$client = false;
|
||||||
|
@ -82,6 +82,8 @@ class DeletePayment
|
|||||||
|
|
||||||
$net_deletable = $paymentable_invoice->pivot->amount - $paymentable_invoice->pivot->refunded;
|
$net_deletable = $paymentable_invoice->pivot->amount - $paymentable_invoice->pivot->refunded;
|
||||||
|
|
||||||
|
$client = $this->payment->client->fresh();
|
||||||
|
|
||||||
nlog("net deletable amount - refunded = {$net_deletable}");
|
nlog("net deletable amount - refunded = {$net_deletable}");
|
||||||
|
|
||||||
if(!$paymentable_invoice->is_deleted)
|
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}")
|
->updateInvoiceBalance($net_deletable, "Adjusting invoice {$paymentable_invoice->number} due to deletion of Payment {$this->payment->number}")
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
$paymentable_invoice->client
|
$client = $client->service()
|
||||||
->service()
|
->updateBalance($net_deletable)
|
||||||
->updateBalance($net_deletable)
|
->save();
|
||||||
// ->updatePaidToDate($net_deletable * -1)
|
|
||||||
->save();
|
|
||||||
|
|
||||||
if ($paymentable_invoice->balance == $paymentable_invoice->amount) {
|
if ($paymentable_invoice->balance == $paymentable_invoice->amount) {
|
||||||
$paymentable_invoice->service()->setStatus(Invoice::STATUS_SENT)->save();
|
$paymentable_invoice->service()->setStatus(Invoice::STATUS_SENT)->save();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user