mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 01:17:30 -05:00 
			
		
		
		
	improved logic for post payment actions
This commit is contained in:
		
							parent
							
								
									b696bdbb3b
								
							
						
					
					
						commit
						e1fe17cc3d
					
				@ -122,7 +122,7 @@ class ApplyPayment
 | 
			
		||||
 | 
			
		||||
        $this->payment
 | 
			
		||||
                 ->ledger()
 | 
			
		||||
                 ->updatePaymentBalance($this->amount_applied * -1);
 | 
			
		||||
                 ->updatePaymentBalance($this->amount_applied * -1, "ApplyPaymentCredit");
 | 
			
		||||
 | 
			
		||||
        $this->payment
 | 
			
		||||
                 ->client
 | 
			
		||||
 | 
			
		||||
@ -73,7 +73,7 @@ class ApplyPayment extends AbstractService
 | 
			
		||||
 | 
			
		||||
        $this->payment
 | 
			
		||||
             ->ledger()
 | 
			
		||||
             ->updatePaymentBalance($amount_paid);
 | 
			
		||||
             ->updatePaymentBalance($amount_paid, "ApplyPaymentInvoice");
 | 
			
		||||
 | 
			
		||||
        $this->invoice
 | 
			
		||||
             ->client
 | 
			
		||||
 | 
			
		||||
@ -101,7 +101,7 @@ class ApplyPaymentAmount extends AbstractService
 | 
			
		||||
        /* Update Invoice balance */
 | 
			
		||||
 | 
			
		||||
        $payment->ledger()
 | 
			
		||||
                ->updatePaymentBalance($payment->amount * -1);
 | 
			
		||||
                ->updatePaymentBalance($payment->amount * -1, "ApplyPaymentInvoice-");
 | 
			
		||||
 | 
			
		||||
        $this->invoice->service()->workFlow()->save();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -213,7 +213,7 @@ class AutoBillInvoice extends AbstractService
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $payment->ledger()
 | 
			
		||||
            ->updatePaymentBalance($amount * -1)
 | 
			
		||||
            ->updatePaymentBalance($amount * -1, "AutoBill")
 | 
			
		||||
            ->save();
 | 
			
		||||
 | 
			
		||||
        $this->invoice
 | 
			
		||||
 | 
			
		||||
@ -107,7 +107,7 @@ class MarkPaid extends AbstractService
 | 
			
		||||
                ->save();
 | 
			
		||||
 | 
			
		||||
        $payment->ledger()
 | 
			
		||||
                ->updatePaymentBalance($this->payable_balance * -1);
 | 
			
		||||
                ->updatePaymentBalance($this->payable_balance * -1, "Marked Paid Activity");
 | 
			
		||||
 | 
			
		||||
        //06-09-2022
 | 
			
		||||
        $this->invoice
 | 
			
		||||
 | 
			
		||||
@ -69,7 +69,7 @@ class PaymentService
 | 
			
		||||
 | 
			
		||||
        $this->payment
 | 
			
		||||
             ->ledger()
 | 
			
		||||
             ->updatePaymentBalance($this->payment->amount);
 | 
			
		||||
             ->updatePaymentBalance($this->payment->amount, "PaymentService");
 | 
			
		||||
 | 
			
		||||
        $client->service()
 | 
			
		||||
            ->updateBalance($this->payment->amount)
 | 
			
		||||
 | 
			
		||||
@ -78,19 +78,18 @@ class UpdateInvoicePayment
 | 
			
		||||
            //caution what if we amount paid was less than partial - we wipe it!
 | 
			
		||||
            $invoice->balance -= $paid_amount;
 | 
			
		||||
            $invoice->paid_to_date += $paid_amount;
 | 
			
		||||
            $invoice->save();
 | 
			
		||||
            $invoice->saveQuietly();
 | 
			
		||||
 | 
			
		||||
            $invoice_service = $invoice->service()
 | 
			
		||||
            $invoice = $invoice->service()
 | 
			
		||||
                               ->clearPartial()
 | 
			
		||||
                               ->updateStatus()
 | 
			
		||||
                               ->workFlow();
 | 
			
		||||
                               ->workFlow()
 | 
			
		||||
                               ->save();
 | 
			
		||||
 | 
			
		||||
            if ($has_partial) {
 | 
			
		||||
                $invoice_service->checkReminderStatus();
 | 
			
		||||
                $invoice->service()->checkReminderStatus()->save();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $invoice = $invoice_service->save();
 | 
			
		||||
 | 
			
		||||
            if ($invoice->is_proforma) {
 | 
			
		||||
                //keep proforma's hidden
 | 
			
		||||
                if (property_exists($this->payment_hash->data, 'pre_payment') && $this->payment_hash->data->pre_payment == "1") {
 | 
			
		||||
@ -145,7 +144,7 @@ class UpdateInvoicePayment
 | 
			
		||||
            /* Updates the company ledger */
 | 
			
		||||
            $this->payment
 | 
			
		||||
                 ->ledger()
 | 
			
		||||
                 ->updatePaymentBalance($paid_amount * -1);
 | 
			
		||||
                 ->updatePaymentBalance($paid_amount * -1, "UpdateInvoicePayment");
 | 
			
		||||
 | 
			
		||||
            $pivot_invoice = $this->payment->invoices->first(function ($inv) use ($paid_invoice) {
 | 
			
		||||
                return $inv->hashed_id == $paid_invoice->invoice_id;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user