X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fui%2Fitems_cart.inc;h=a9bcc5798c1c8141084e1b61025487ac9bdc3207;hb=2917915beba9540193b520f1de59de9e6a33be56;hp=92cc1a462c2193a30f3b0ed8d5743eacf933fa2c;hpb=f0e1edfccbf3608463c9da99b40f9c65fd298bb3;p=fa-stable.git diff --git a/includes/ui/items_cart.inc b/includes/ui/items_cart.inc index 92cc1a46..a9bcc579 100644 --- a/includes/ui/items_cart.inc +++ b/includes/ui/items_cart.inc @@ -40,7 +40,7 @@ class items_cart var $fixed_asset; - function items_cart($type, $trans_no=0) + function __construct($type, $trans_no=0) { $this->trans_type = $type; $this->order_id = $trans_no; @@ -52,13 +52,13 @@ class items_cart // --------------- line item functions - function add_to_cart($line_no, $stock_id, $qty, $standard_cost, $description=null) + function add_to_cart($line_no, $stock_id, $qty, $unit_cost, $description=null) { if (isset($stock_id) && $stock_id != "" && isset($qty)) { $this->line_items[$line_no] = new line_item($stock_id, $qty, - $standard_cost, $description); + $unit_cost, $description); return true; } else @@ -79,10 +79,10 @@ class items_cart return null; } - function update_cart_item($line_no, $qty, $standard_cost) + function update_cart_item($line_no, $qty, $unit_cost) { $this->line_items[$line_no]->quantity = $qty; - $this->line_items[$line_no]->standard_cost = $standard_cost; + $this->line_items[$line_no]->unit_cost = $unit_cost; } function remove_from_cart($line_no) @@ -101,7 +101,7 @@ class items_cart $low_stock = array(); - if (!$SysPrefs->allow_negative_stock() || is_fixed_asset($line_item->mb_flag)) + if (!$SysPrefs->allow_negative_stock()) { foreach ($this->line_items as $line_no => $line_item) if (has_stock_holding($line_item->mb_flag) || is_fixed_asset($line_item->mb_flag)) @@ -224,7 +224,7 @@ class items_cart { foreach ($this->gl_items as $gl_item) { - if ($gl_item->person_id) + if (is_subledger_account($gl_item->code_id)) return true; } return false; @@ -309,7 +309,7 @@ class items_cart if (!isset($tax_info['tax_reg']) && isset($tax_info['person_type'])) $tax_info['tax_reg'] = $tax_info['person_type']==PT_CUSTOMER ? TR_OUTPUT : TR_INPUT; - if (count(@$tax_info['net_amount'])) // guess exempt sales/purchase if any tax has been found + if (count_array(@$tax_info['net_amount'])) // guess exempt sales/purchase if any tax has been found { $ex_net = abs($net_sum) - @array_sum($tax_info['net_amount']); if ($ex_net != 0) @@ -367,7 +367,7 @@ class items_cart $gl->date = $this->tran_date; $total_gl += add_gl_trans($this->trans_type, $this->order_id, $gl->date, $gl->code_id, $gl->dimension_id, $gl->dimension2_id, - $gl->reference, $gl->amount, $this->currency, $gl->person_type_id, $gl->person_id, "", $this->rate); + $gl->reference, $gl->amount, $this->currency, $gl->person_type_id, $gl->person_id, $this->rate); // post to first found bank account using given gl acount code. $is_bank_to = is_bank_account($gl->code_id); @@ -397,8 +397,7 @@ class items_cart // update bank ledger if used foreach($bank_trans as $bank_id => $amount) add_bank_trans($this->trans_type, $this->order_id, $bank_id, $this->reference, - $this->tran_date, $amount, 0, "", $this->currency, - "Cannot insert a destination bank transaction"); + $this->tran_date, $amount, 0, "", $this->currency); // add AP/AR for journal transaction if ($this->trans_type == ST_JOURNAL) @@ -407,7 +406,7 @@ class items_cart foreach($cust_trans as $branch_id => $amount) if (floatcmp($amount, 0)) write_cust_journal($this->trans_type, $this->order_id, $branch_id, $this->tran_date, - $this->reference, -$amount, $this->rate); + $this->reference, $amount, $this->rate); // update AP foreach($supp_trans as $supp_id => $amount) if (floatcmp($amount, 0)) @@ -446,7 +445,7 @@ class items_cart add_trans_tax_details($this->trans_type, $this->order_id, $tax_id, $this->tax_info['rate'][$tax_id], 0, $tax_nominal, $net, $this->rate, $this->tran_date, - $this->source_ref, $reg); + $this->source_ref, $reg, $this->tax_info['tax_group'], $this->tax_info['tax_category']); } } } @@ -463,9 +462,9 @@ class line_item var $quantity; var $price; - var $standard_cost; + var $unit_cost; - function line_item ($stock_id, $qty, $standard_cost=null, $description=null) + function __construct($stock_id, $qty, $unit_cost=null, $description=null) { $item_row = get_item($stock_id); @@ -480,10 +479,10 @@ class line_item else $this->item_description = $description; - if ($standard_cost == null) - $this->standard_cost = $item_row["purchase_cost"]; + if ($unit_cost == null) + $this->unit_cost = $item_row["purchase_cost"]; else - $this->standard_cost = $standard_cost; + $this->unit_cost = $unit_cost; $this->stock_id = $stock_id; $this->quantity = $qty; @@ -509,7 +508,7 @@ class gl_item var $branch_id; var $date; - function gl_item($code_id=null, $dimension_id=0, $dimension2_id=0, $amount=0, $memo='', + function __construct($code_id=null, $dimension_id=0, $dimension2_id=0, $amount=0, $memo='', $act_descr=null, $person_id=null, $date=null) { //echo "adding $index, $code_id, $dimension_id, $amount, $reference
";