mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 10:34:30 -04:00
Delete invoice when payments are applied
This commit is contained in:
parent
045fd56304
commit
e7707a919b
@ -114,6 +114,7 @@ class PaymentRepository extends BaseRepository {
|
|||||||
|
|
||||||
/*Iterate through invoices and apply payments*/
|
/*Iterate through invoices and apply payments*/
|
||||||
if (array_key_exists('invoices', $data) && is_array($data['invoices']) && count($data['invoices']) > 0) {
|
if (array_key_exists('invoices', $data) && is_array($data['invoices']) && count($data['invoices']) > 0) {
|
||||||
|
|
||||||
$invoice_totals = array_sum(array_column($data['invoices'], 'amount'));
|
$invoice_totals = array_sum(array_column($data['invoices'], 'amount'));
|
||||||
|
|
||||||
$invoices = Invoice::whereIn('id', array_column($data['invoices'], 'invoice_id'))->get();
|
$invoices = Invoice::whereIn('id', array_column($data['invoices'], 'invoice_id'))->get();
|
||||||
@ -125,7 +126,10 @@ class PaymentRepository extends BaseRepository {
|
|||||||
$invoice = Invoice::whereId($paid_invoice['invoice_id'])->first();
|
$invoice = Invoice::whereId($paid_invoice['invoice_id'])->first();
|
||||||
|
|
||||||
if ($invoice) {
|
if ($invoice) {
|
||||||
$invoice = $invoice->service()->markSent()->applyPayment($payment, $paid_invoice['amount'])->save();
|
$invoice = $invoice->service()
|
||||||
|
->markSent()
|
||||||
|
->applyPayment($payment, $paid_invoice['amount'])
|
||||||
|
->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -101,6 +101,8 @@ class InvoiceService
|
|||||||
*/
|
*/
|
||||||
public function applyPayment(Payment $payment, float $payment_amount)
|
public function applyPayment(Payment $payment, float $payment_amount)
|
||||||
{
|
{
|
||||||
|
$this->deletePdf();
|
||||||
|
|
||||||
$this->invoice = (new ApplyPayment($this->invoice, $payment, $payment_amount))->run();
|
$this->invoice = (new ApplyPayment($this->invoice, $payment, $payment_amount))->run();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -295,6 +297,7 @@ class InvoiceService
|
|||||||
|
|
||||||
public function deletePdf()
|
public function deletePdf()
|
||||||
{
|
{
|
||||||
|
nlog("delete PDF");
|
||||||
//UnlinkFile::dispatchNow(config('filesystems.default'), $this->invoice->client->invoice_filepath() . $this->invoice->numberFormatter().'.pdf');
|
//UnlinkFile::dispatchNow(config('filesystems.default'), $this->invoice->client->invoice_filepath() . $this->invoice->numberFormatter().'.pdf');
|
||||||
Storage::disk(config('filesystems.default'))->delete($this->invoice->client->invoice_filepath() . $this->invoice->numberFormatter().'.pdf');
|
Storage::disk(config('filesystems.default'))->delete($this->invoice->client->invoice_filepath() . $this->invoice->numberFormatter().'.pdf');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user