invoice = $invoice; $this->payment = $payment; } /** * Execute the job. * * * @return void */ public function handle() { $adjustment = $this->payment->amount * -1; $partial = max(0, $this->invoice->partial - $this->payment->amount); //check if partial exists if($this->invoice->partial > 0) { //if payment amount = partial if( $this->formatvalue($this->invoice->partial,4) == $this->formatValue($this->payment->amount,4) ) { $this->invoice->partial = 0; } //if payment amount < partial amount if( $this->formatvalue($this->invoice->partial,4) > $this->formatValue($this->payment->amount,4) ) { //set the new partial amount to the balance $this->invoice->partial = $partial; } $this->partial_due_date = null; $this->due_date = } $this->balance = $this->balance + $adjustment; } }