mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Add credit adjustment notes to credit notes
This commit is contained in:
parent
f1ef674c20
commit
3155fcca53
@ -11,13 +11,16 @@
|
||||
|
||||
namespace App\Jobs\Credit;
|
||||
|
||||
use App\Utils\Number;
|
||||
use App\Models\Credit;
|
||||
use App\Models\Payment;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Support\Carbon;
|
||||
use App\DataMapper\InvoiceItem;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class ApplyCreditPayment implements ShouldQueue
|
||||
{
|
||||
@ -67,6 +70,19 @@ class ApplyCreditPayment implements ShouldQueue
|
||||
|
||||
$credit_balance = $this->credit->balance;
|
||||
|
||||
$item_date = Carbon::parse($this->payment->date)->format($this->payment->client->date_format());
|
||||
$invoice_numbers = $this->payment->invoices->pluck('number')->implode(",");
|
||||
|
||||
$item = new InvoiceItem();
|
||||
$item->quantity = 0;
|
||||
$item->cost = $this->amount * -1;
|
||||
$item->notes = "{$item_date} - " . ctrans('texts.credit_payment', ['invoice_number' => $invoice_numbers]) . " ". Number::formatMoney($this->amount, $this->payment->client);
|
||||
$item->type_id = "1";
|
||||
|
||||
$line_items = $this->credit->line_items;
|
||||
$line_items[] = $item;
|
||||
$this->credit->line_items = $line_items;
|
||||
|
||||
if ($this->amount == $credit_balance) { //total credit applied.
|
||||
$this->credit
|
||||
->service()
|
||||
@ -90,7 +106,7 @@ class ApplyCreditPayment implements ShouldQueue
|
||||
->client
|
||||
->service()
|
||||
->adjustCreditBalance($this->amount * -1)
|
||||
->save();
|
||||
->save();
|
||||
|
||||
/* Update Payment Applied Amount*/
|
||||
$this->payment->save();
|
||||
|
Loading…
x
Reference in New Issue
Block a user