[0003780] Sales Invoice to partial delivery was improperly issued as final prepayment...
[fa-stable.git] / sales / includes / cart_class.inc
index dc6e81a63adbc705d2a87071a1ff0325592c4ff9..b2d7a51f6a433749eab927143afa7a75a6592284 100644 (file)
@@ -636,12 +636,12 @@ class cart
                $remainder = prepaid_invoice_remainder($this->order_no);
 
                // recalculate prepaid part from payments
-               if ($this->payment_terms['days_before_due'] < 0)
+               if ($this->payment_terms['days_before_due'] == -1)
                {       // this is partial invoice for selected prepayments made.
                        $paid = 0;
                        foreach($this->prepayments as $payment)
                                $paid += $payment['amt'];
-                       $this->prep_amount = min($remainder, $paid);
+                       $this->prep_amount = $this->trans_no ? $paid : min($remainder, $paid);
                } else  // this is final invoice
                        $this->prep_amount = $remainder;
        }