Payment terms related functions moved to separate file, common function for calculati...
[fa-stable.git] / sales / includes / db / recurrent_invoices_db.inc
index 66a6a87f40581aefea23b568fd4426f62ff36f1d..7aca37cf46f21723a8537e682effbe926b4de997 100644 (file)
@@ -177,7 +177,7 @@ function check_sales_order_type($order_no)
 {
        $myrow = get_sales_order_header($order_no, ST_SALESORDER);
 
-       return !$myrow['prepaid'];
+       return !$myrow['prepaid'] && ! $myrow['cash_sale'];
 }
 
 function create_template_invoice($customer_id, $branch_id, $order_no, $tmpl_no, $date, $from, $to, $memo)
@@ -194,7 +194,7 @@ function create_template_invoice($customer_id, $branch_id, $order_no, $tmpl_no,
        $doc->trans_no = 0;
        $doc->document_date = $date;
 
-       $doc->due_date = get_invoice_duedate($doc->payment, $doc->document_date);
+       $doc->due_date = get_payment_due_date($doc->payment, $doc->document_date);
 
        $doc->reference = $Refs->get_next($doc->trans_type, null, array('customer' => $customer_id, 'branch' => $branch_id,
                'date' => $date));
@@ -210,7 +210,6 @@ function create_template_invoice($customer_id, $branch_id, $order_no, $tmpl_no,
        $cart = $doc;
        $cart->trans_type = ST_SALESINVOICE;
        $cart->reference = $Refs->get_next($cart->trans_type);
-       $cart->payment_terms['cash_sale'] = false; // no way to register cash payment with recurrent invoice at once
 
        $invno = $cart->write(1);