diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index 9e027a98f381..a7e52f7d63ce 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -206,6 +206,9 @@ class InvoiceService if($this->invoice->balance == 0) $this->setStatus(Invoice::STATUS_PAID); + if($this->invoice->balance > 0 && $this->invoice->balance < $this->invoice->amount) + $this->setStatus(Invoice::STATUS_PARTIAL); + return $this; } diff --git a/app/Services/Payment/UpdateInvoicePayment.php b/app/Services/Payment/UpdateInvoicePayment.php index ed6c69d316c2..341e3c746595 100644 --- a/app/Services/Payment/UpdateInvoicePayment.php +++ b/app/Services/Payment/UpdateInvoicePayment.php @@ -73,6 +73,8 @@ class UpdateInvoicePayment $pivot_invoice->pivot->amount = $paid_amount; $pivot_invoice->pivot->save(); + $this->payment->applied += $paid_amount; + $invoice->service() //caution what if we amount paid was less than partial - we wipe it! ->clearPartial() ->updateBalance($paid_amount * -1) @@ -82,6 +84,8 @@ class UpdateInvoicePayment event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars())); }); + + $this->payment->save(); return $this->payment; } diff --git a/resources/views/portal/ninja2020/gateways/stripe/credit_card.blade.php b/resources/views/portal/ninja2020/gateways/stripe/credit_card.blade.php index 77c91ba8e5c3..5169466ee6d3 100644 --- a/resources/views/portal/ninja2020/gateways/stripe/credit_card.blade.php +++ b/resources/views/portal/ninja2020/gateways/stripe/credit_card.blade.php @@ -31,6 +31,28 @@