Recurrent Invoices: fixed buggy call to non existing function and payment terms type...
[fa-stable.git] / sales / sales_order_entry.php
index 77e975d4258566c64c342b88ca9011ce993148c5..6f434d86a63f9065087ff174f5af5106f4131ed5 100644 (file)
@@ -63,7 +63,6 @@ if (isset($_GET['NewDelivery']) && is_numeric($_GET['NewDelivery'])) {
 
        $_SESSION['page_title'] = _($help_context = "Direct Sales Delivery");
        create_cart(ST_CUSTDELIVERY, $_GET['NewDelivery']);
-
 } elseif (isset($_GET['NewInvoice']) && is_numeric($_GET['NewInvoice'])) {
 
        create_cart(ST_SALESINVOICE, $_GET['NewInvoice']);
@@ -272,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;
@@ -391,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');
@@ -453,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;
@@ -471,7 +470,7 @@ if (isset($_POST['ProcessOrder']) && can_process()) {
        $modified = ($_SESSION['Items']->trans_no != 0);
        $so_type = $_SESSION['Items']->so_type;
 
-       $ret = $_SESSION['Items']->write(1);
+       $ret = write_sales_trans($_SESSION['Items'], 1);
        if ($ret == -1)
        {
                display_error(_("The entered reference is already in use."));
@@ -665,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;