+ if ($type == ST_SALESINVOICE) {
+ $this->due_date = get_invoice_duedate($this->payment, $this->document_date);
+ }
+
+ if ($type == ST_CUSTCREDIT)
+ $this->src_date = $this->document_date;
+
+ $this->src_docs = $this->trans_no;
+ $this->trans_no = 0;
+ }
+
+ //
+ // Prepares transaction for reedition updating with parent transaction data
+ //
+ function set_parent_constraints($sodata, $src_no) {
+
+ $src_type = get_parent_type($this->trans_type);
+ if ($src_type == ST_SALESORDER || $src_type == 0) { // get src data from sales_orders
+ $this->src_docs = array( $sodata['order_no']=>$sodata['version']);
+ $srcdetails = get_sales_order_details($this->order_no, $this->trans_type);
+ } else { // get src_data from debtor_trans
+ $this->src_docs = get_customer_trans_version($src_type,
+ get_parent_trans($this->trans_type, $src_no));
+ $srcdetails = get_customer_trans_details($src_type, array_keys($this->src_docs));
+ }
+ // calculate & save: qtys on other docs and free qtys on src doc
+ for($line_no = 0; $srcline = db_fetch($srcdetails); $line_no++) {
+ $line = &$this->line_items[$line_no];
+
+ $line->src_id = $srcline['id']; // save src line ids for update
+ if ($this->trans_type == ST_SALESINVOICE)
+ $line->src_no = $srcline['debtor_trans_no'];
+ $line->qty_old = $line->qty_dispatched = $line->quantity;
+ $line->quantity += $srcline['quantity'] - $srcline['qty_done']; // add free qty on src doc
+ }
+ }