Bug. Edit Journal -> orphaned attachments.
[fa-stable.git] / sales / includes / cart_class.inc
index 6aefabf72f7fcffb65b7ca39c162c681e5ddbae0..e867cea0ec6324159096b64c761448d419907108 100644 (file)
@@ -21,7 +21,7 @@ iv)  a delivery note
 include_once($path_to_root . "/inventory/includes/inventory_db.inc");
 include_once($path_to_root . "/taxes/tax_calc.inc");
 
-class Cart
+class Cart 
 {
        var $trans_type; // invoice, order, quotation, delivery note ...
        var $trans_no = array();// array (num1=>ver1,..) or 0 for new
@@ -71,17 +71,18 @@ class Cart
        var $dimension_id;
        var $dimension2_id;
        var $payment;
-       var $payment_terms; // cached payment terms
+       var $payment_terms = array('cash_sale' => false, 'days_before_due' => 0); // cached payment terms
        var $credit;
        // prepayment mode:
-       var $prepaid;           // true for documents issued in prepayment mode
-       var $prep_amount;       // prepayment required for SO, invoiced amount for prepaiament invoice
+       var $prepaid=false;     // true for documents issued in prepayment mode
+       var $prep_amount=0;     // prepayment required for SO, invoiced amount for prepaiament invoice
        var $sum_paid;          // sum of all allocated prepayments both to order and related invoices
        var $alloc;             // sum of payments allocated to this document
        var $prepayments = array(); // allocation records for this document
        var $ex_rate;
 
        var $fixed_asset = false;
+       var $bo_policy = null;
 
        //-------------------------------------------------------------------------
        //
@@ -224,7 +225,7 @@ class Cart
                                        $sodata = get_sales_order_header($this->order_no, ST_SALESORDER);
                                        $this->cust_ref = $sodata["customer_ref"];
                                // currently currency is hard linked to debtor account
-                                       $this->delivery_to = $sodata["deliver_to"];
+                                       $this->deliver_to = $sodata["deliver_to"];
                                        $this->delivery_address = $sodata["delivery_address"];
                                // child transaction reedition - update with parent info unless it is freehand
                                if (!$this->is_prepaid() && !$prepare_child) // this is read for view/reedition
@@ -293,11 +294,11 @@ class Cart
                {
                        if (!empty($SysPrefs->prefs['ref_no_auto_increase']))
                                $this->reference = $Refs->get_next($this->trans_type, null, array('date' => Today()));
-                       if (!is_new_reference($this->reference, $this->trans_type))     
+                       else    
                        {
                                commit_transaction();
                                return -1;
-                       }       
+                       }
                }
                if (count($this->src_docs) == 0 && ($this->trans_type == ST_SALESINVOICE || $this->trans_type == ST_CUSTDELIVERY) && !$this->is_prepaid()) {
                        // this is direct document - first add parent
@@ -565,7 +566,6 @@ class Cart
                $total = $this->get_items_total() + $this->freight_cost;
                $dec = user_price_dec();
                if (!$this->tax_included ) {
-                       $total += $this->get_shipping_tax();
                        $taxes = $this->get_taxes();
                        foreach($taxes as $tax)
                                $total += round($tax['Value'], $dec);