diff --git a/app/Jobs/Ninja/SendReminders.php b/app/Jobs/Ninja/SendReminders.php index 278cbb9898d9..e2d58a1b8659 100644 --- a/app/Jobs/Ninja/SendReminders.php +++ b/app/Jobs/Ninja/SendReminders.php @@ -308,7 +308,7 @@ class SendReminders implements ShouldQueue $invoice = $invoice->calc()->getInvoice(); $this->invoice->client->service()->updateBalance($this->invoice->balance - $temp_invoice_balance)->save(); - $this->invoice->ledger()->updateInvoiceBalance($this->invoice->balance - $temp_invoice_balance); + $this->invoice->ledger()->updateInvoiceBalance($this->invoice->balance - $temp_invoice_balance, "Late Fee Adjustment for invoice {$this->invoice->number}"); return $invoice; } diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index 87c2f85aaa27..4dfb178c798d 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -264,7 +264,7 @@ class BaseDriver extends AbstractPaymentDriver if (collect($invoice->line_items)->contains('type_id', '3')) { $invoice->service()->toggleFeesPaid()->save(); $invoice->client->service()->updateBalance($fee_total)->save(); - $invoice->ledger()->updateInvoiceBalance($fee_total, $notes = 'Gateway fee adjustment'); + $invoice->ledger()->updateInvoiceBalance($fee_total, "Gateway fee adjustment for invoice {$invoice->number}"); } }); } diff --git a/app/PaymentDrivers/BasePaymentDriver.php b/app/PaymentDrivers/BasePaymentDriver.php index bc63edfa0085..858701824803 100644 --- a/app/PaymentDrivers/BasePaymentDriver.php +++ b/app/PaymentDrivers/BasePaymentDriver.php @@ -306,7 +306,7 @@ class BasePaymentDriver if (collect($invoice->line_items)->contains('type_id', '3')) { $invoice->service()->toggleFeesPaid()->save(); $invoice->client->service()->updateBalance($fee_total)->save(); - $invoice->ledger()->updateInvoiceBalance($fee_total, $notes = 'Gateway fee adjustment'); + $invoice->ledger()->updateInvoiceBalance($fee_total, "Gateway fee adjustment for Invoice {$invoice->number}"); } }); } diff --git a/app/Repositories/BaseRepository.php b/app/Repositories/BaseRepository.php index b6fa2b9e66cb..b295419b3fb9 100644 --- a/app/Repositories/BaseRepository.php +++ b/app/Repositories/BaseRepository.php @@ -293,7 +293,7 @@ class BaseRepository if (($state['finished_amount'] != $state['starting_amount']) && ($model->status_id != Invoice::STATUS_DRAFT)) { - $model->ledger()->updateInvoiceBalance(($state['finished_amount'] - $state['starting_amount'])); + $model->ledger()->updateInvoiceBalance(($state['finished_amount'] - $state['starting_amount']), "Update adjustment for invoice {$model->number}"); $model->client->service()->updateBalance(($state['finished_amount'] - $state['starting_amount']))->save(); } diff --git a/app/Services/Invoice/AddGatewayFee.php b/app/Services/Invoice/AddGatewayFee.php index 4cadb94bd498..073375e7bd2a 100644 --- a/app/Services/Invoice/AddGatewayFee.php +++ b/app/Services/Invoice/AddGatewayFee.php @@ -93,10 +93,6 @@ class AddGatewayFee extends AbstractService /**Refresh Invoice values*/ $this->invoice = $this->invoice->calc()->getInvoice(); - /*Update client balance*/ // don't increment until we have process the payment! - //$this->invoice->client->service()->updateBalance($gateway_fee)->save(); - //$this->invoice->ledger()->updateInvoiceBalance($gateway_fee, $notes = 'Gateway fee adjustment'); - return $this->invoice; } @@ -122,10 +118,6 @@ class AddGatewayFee extends AbstractService $this->invoice = $this->invoice->calc()->getInvoice(); - // $this->invoice->client->service()->updateBalance($gateway_fee)->save(); - - // $this->invoice->ledger()->updateInvoiceBalance($gateway_fee, $notes = 'Discount fee adjustment'); - return $this->invoice; } } diff --git a/app/Services/Invoice/AutoBillInvoice.php b/app/Services/Invoice/AutoBillInvoice.php index e2b61215eca7..b588c688c37b 100644 --- a/app/Services/Invoice/AutoBillInvoice.php +++ b/app/Services/Invoice/AutoBillInvoice.php @@ -147,8 +147,8 @@ class AutoBillInvoice extends AbstractService ->save(); $this->invoice->ledger() - ->updateInvoiceBalance($amount * -1, 'Invoice payment using Credit') - ->updateCreditBalance($amount * -1, 'Credits used to pay down Invoice ' . $this->invoice->number) + ->updateInvoiceBalance($amount * -1, "Invoice {$this->invoice->number} payment using Credit {$current_credit->number}") + ->updateCreditBalance($amount * -1, "Credit {$current_credit->number} used to pay down Invoice {$this->invoice->number}") ->save(); event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars())); @@ -325,7 +325,7 @@ class AutoBillInvoice extends AbstractService if ($starting_amount != $this->invoice->amount && $this->invoice->status_id != Invoice::STATUS_DRAFT) { $this->invoice->client->service()->updateBalance($this->invoice->amount - $starting_amount)->save(); - $this->invoice->ledger()->updateInvoiceBalance($this->invoice->amount - $starting_amount, 'Invoice balance updated after stale gateway fee removed')->save(); + $this->invoice->ledger()->updateInvoiceBalance($this->invoice->amount - $starting_amount, "Invoice {$this->invoice->number} balance updated after stale gateway fee removed")->save(); } return $this; diff --git a/app/Services/Invoice/HandleCancellation.php b/app/Services/Invoice/HandleCancellation.php index 6f7d71c48868..d18c76e5a803 100644 --- a/app/Services/Invoice/HandleCancellation.php +++ b/app/Services/Invoice/HandleCancellation.php @@ -42,7 +42,7 @@ class HandleCancellation extends AbstractService $this->backupCancellation($adjustment); //set invoice balance to 0 - $this->invoice->ledger()->updateInvoiceBalance($adjustment, 'Invoice cancellation'); + $this->invoice->ledger()->updateInvoiceBalance($adjustment, "Invoice {$this->invoice->number} cancellation"); $this->invoice->balance = 0; $this->invoice = $this->invoice->service()->setStatus(Invoice::STATUS_CANCELLED)->save(); @@ -63,7 +63,7 @@ class HandleCancellation extends AbstractService /* Will turn the negative cancellation amount to a positive adjustment*/ $adjustment = $cancellation->adjustment * -1; - $this->invoice->ledger()->updateInvoiceBalance($adjustment, 'Invoice cancellation REVERSAL'); + $this->invoice->ledger()->updateInvoiceBalance($adjustment, "Invoice {$this->invoice->number} reversal"); /* Reverse the invoice status and balance */ $this->invoice->balance += $adjustment; diff --git a/app/Services/Invoice/MarkSent.php b/app/Services/Invoice/MarkSent.php index 06830d753a81..1767e61e94f3 100644 --- a/app/Services/Invoice/MarkSent.php +++ b/app/Services/Invoice/MarkSent.php @@ -51,7 +51,7 @@ class MarkSent extends AbstractService $this->client->service()->updateBalance($this->invoice->balance)->save(); - $this->invoice->ledger()->updateInvoiceBalance($this->invoice->balance); + $this->invoice->ledger()->updateInvoiceBalance($this->invoice->balance, "Invoice {$this->invoice->number} marked as sent."); event(new InvoiceWasUpdated($this->invoice, $this->invoice->company, Ninja::eventVars())); diff --git a/app/Services/Payment/DeletePayment.php b/app/Services/Payment/DeletePayment.php index 36bd08324bf0..3169c51a5733 100644 --- a/app/Services/Payment/DeletePayment.php +++ b/app/Services/Payment/DeletePayment.php @@ -80,7 +80,7 @@ class DeletePayment if ($this->payment->invoices()->exists()) { $this->payment->invoices()->each(function ($paymentable_invoice) { $paymentable_invoice->service()->updateBalance($paymentable_invoice->pivot->amount)->save(); - $paymentable_invoice->ledger()->updateInvoiceBalance($paymentable_invoice->pivot->amount)->save(); + $paymentable_invoice->ledger()->updateInvoiceBalance($paymentable_invoice->pivot->amount, "Adjusting invoice {$paymentable_invoice->number} due to deletion of Payment {$this->payment->number}")->save(); $paymentable_invoice->client->service()->updateBalance($paymentable_invoice->pivot->amount)->save(); if ($paymentable_invoice->balance == $paymentable_invoice->amount) {