Recurrent Invoices: fixed buggy call to non existing function and payment terms type...
[fa-stable.git] / sales / sales_order_entry.php
index a604af695b2c3b10836fe9613ca55c025d8a0d1b..6f434d86a63f9065087ff174f5af5106f4131ed5 100644 (file)
@@ -271,7 +271,7 @@ function copy_to_cart()
                $cart->payment_terms = get_payment_terms($_POST['payment']);
                $newpayment = true;
        }
-       if ($cart->payment_terms['cash_sale']) {
+       if ($cart->payment_terms['type'] == PTT_CASH) {
                if ($newpayment) 
                {
                        $cart->due_date = $cart->document_date;
@@ -390,8 +390,8 @@ function can_process() {
                display_error(_("This document cannot be processed because there is insufficient quantity for items marked."));
                return false;
        }
-       if ($_SESSION['Items']->payment_terms['cash_sale'] == 0) {
-               if (!$_SESSION['Items']->is_started() && ($_SESSION['Items']->payment_terms['days_before_due'] == -1) && ((input_num('prep_amount')<=0) ||
+       if ($_SESSION['Items']->payment_terms['type'] != PTT_CASH) {
+               if (!$_SESSION['Items']->is_started() && ($_SESSION['Items']->payment_terms['type'] == PTT_PREPAY) && ((input_num('prep_amount')<=0) ||
                        input_num('prep_amount')>$_SESSION['Items']->get_trans_total())) {
                        display_error(_("Pre-payment required have to be positive and less than total amount."));
                        set_focus('prep_amount');
@@ -452,7 +452,7 @@ function can_process() {
                return false;
        }
 
-       if ($_SESSION['Items']->payment_terms['cash_sale'] && 
+       if ($_SESSION['Items']->payment_terms['type'] == PTT_CASH && 
                ($_SESSION['Items']->trans_type == ST_CUSTDELIVERY || $_SESSION['Items']->trans_type == ST_SALESINVOICE)) 
                $_SESSION['Items']->due_date = $_SESSION['Items']->document_date;
        return true;
@@ -664,7 +664,7 @@ function create_cart($type, $trans_no)
                $doc->trans_no = 0;
                $doc->document_date = new_doc_date();
                if ($type == ST_SALESINVOICE) {
-                       $doc->due_date = get_invoice_duedate($doc->payment, $doc->document_date);
+                       $doc->due_date = get_payment_due_date($doc->payment, $doc->document_date);
                        $doc->pos = get_sales_point(user_pos());
                } else
                        $doc->due_date = $doc->document_date;