X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=sales%2Fincludes%2Fcart_class.inc;h=40fb2a3f2fef9bf9798e92440b23cf2d76280467;hb=aa2ff78063656a7843d763859e3b9b4c15a3f920;hp=248b5c5b5f8a0499c737c9320325642a462ab29a;hpb=168de3c992863ee03e42c9dfb060ecf53c674db8;p=fa-stable.git diff --git a/sales/includes/cart_class.inc b/sales/includes/cart_class.inc index 248b5c5b..40fb2a3f 100644 --- a/sales/includes/cart_class.inc +++ b/sales/includes/cart_class.inc @@ -153,7 +153,6 @@ class cart $line->quantity += $srcline['quantity'] - ($src_type==ST_SALESORDER ? $srcline['qty_sent'] : $srcline['qty_done']); // add free qty on src doc $line_no++; - break; } } @@ -244,10 +243,16 @@ class cart // $policy - 0 or 1: writeoff/return for IV, back order/cancel for DN function write($policy=0) { begin_transaction(); // prevents partial database changes in case of direct delivery/invoice + if ($this->reference != 'auto' && $this->trans_no == 0 && !is_new_reference($this->reference, $this->trans_type)) + { + commit_transaction(); + return -1; + } if (count($this->src_docs) == 0 && ($this->trans_type == ST_SALESINVOICE || $this->trans_type == ST_CUSTDELIVERY)) { // this is direct document - first add parent $ref = $this->reference; $date = $this->document_date; + $due_date = $this->due_date; $this->trans_type = get_parent_type($this->trans_type); $this->reference = 'auto'; @@ -257,6 +262,7 @@ class cart $this->read($this->trans_type, $trans_no, true); $this->document_date = $date; $this->reference = $ref; + $this->due_date = $due_date; } $this->reference = @html_entity_decode($this->reference, ENT_QUOTES); $this->Comments = @html_entity_decode($this->Comments, ENT_QUOTES); @@ -486,7 +492,7 @@ class cart if ($tax_items != null) { foreach ($tax_items as $item_tax) { $index = $item_tax['tax_type_id']; - if (isset($this->tax_group_array[$index])) { + if (isset($this->tax_group_array[$index]['rate'])) { $tax_rate += $item_tax['rate']; } }