X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=sales%2Fincludes%2Fcart_class.inc;h=6aefabf72f7fcffb65b7ca39c162c681e5ddbae0;hb=9f832e8ab3c679ab67e5d086a99774dac58e004a;hp=7d68e2a4622fc60cfccf6bee5298556fd1c079b5;hpb=19ddc3939071044c8e94b628f1d6a039f50cc493;p=fa-stable.git diff --git a/sales/includes/cart_class.inc b/sales/includes/cart_class.inc index 7d68e2a4..6aefabf7 100644 --- a/sales/includes/cart_class.inc +++ b/sales/includes/cart_class.inc @@ -285,12 +285,19 @@ class Cart // Makes parent documents for direct delivery/invoice by recurent call. // $policy - 0 or 1: writeoff/return for IV, back order/cancel for DN function write($policy=0) { - + + global $SysPrefs, $Refs; + 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 (!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)) + { + 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