3 /* Definition of the Supplier Transactions class to hold all the information for an accounts payable invoice or credit note
6 include_once($path_to_root . "/taxes/tax_calc.inc");
11 var $grn_items; /*array of objects of class GRNDetails using the GRN No as the pointer */
12 var $gl_codes; /*array of objects of class gl_codes using a counter as the pointer */
15 var $terms_description;
32 var $gl_codes_counter=0;
36 /*Constructor function initialises a new Supplier Transaction object */
37 $this->grn_items = array();
38 $this->gl_codes = array();
41 function add_grn_to_trans($grn_item_id, $po_detail_item, $item_code, $item_description,
42 $qty_recd, $prev_quantity_inv, $this_quantity_inv, $order_price, $chg_price,
43 $Complete, $std_cost_unit, $gl_code)
45 $this->grn_items[$grn_item_id] = new grn_item($grn_item_id, $po_detail_item,
46 $item_code, $item_description, $qty_recd, $prev_quantity_inv, $this_quantity_inv,
47 $order_price, $chg_price, $Complete, $std_cost_unit, $gl_code);
51 function add_gl_codes_to_trans($gl_code, $gl_act_name, $gl_dim, $gl_dim2, $amount, $memo_)
53 $this->gl_codes[$this->gl_codes_counter] = new gl_codes($this->gl_codes_counter,
54 $gl_code, $gl_act_name, $gl_dim, $gl_dim2, $amount, $memo_);
55 $this->gl_codes_counter++;
59 function remove_grn_from_trans(&$grn_item_id)
61 unset($this->grn_items[$grn_item_id]);
63 function remove_gl_codes_from_trans(&$gl_code_counter)
65 unset($this->gl_codes[$gl_code_counter]);
68 function is_valid_trans_to_post()
70 return (count($this->grn_items) > 0 || count($this->gl_codes) > 0 ||
71 ($this->ov_amount != 0) || ($this->ov_discount > 0));
74 function clear_items()
76 unset($this->grn_items);
77 unset($this->gl_codes);
78 $this->ov_amount = $this->ov_discount = $this->supplier_id = 0;
80 $this->grn_items = array();
81 $this->gl_codes = array();
84 function get_taxes($tax_group_id=null, $shipping_cost=0)
89 if ($tax_group_id == null)
90 $tax_group_id = $this->tax_group_id;
92 // preload the taxgroup !
93 $tax_group = get_tax_group_items_as_array($tax_group_id);
95 foreach ($this->grn_items as $ln_itm)
97 $items[] = $ln_itm->item_code;
98 $prices[] =round( ($ln_itm->this_quantity_inv * $ln_itm->taxfree_charge_price($tax_group_id, $tax_group)),
102 if ($tax_group_id == null)
103 $tax_group_id = $this->tax_group_id;
105 $taxes = get_tax_for_items($items, $prices, $shipping_cost, $tax_group_id);
110 function get_total_charged($tax_group_id=null)
114 // preload the taxgroup !
115 if ($tax_group_id != null)
116 $tax_group = get_tax_group_items_as_array($tax_group_id);
120 foreach ($this->grn_items as $ln_itm)
121 $total += round(($ln_itm->this_quantity_inv * $ln_itm->taxfree_charge_price($tax_group_id, $tax_group)),
124 foreach ($this->gl_codes as $gl_line)
125 $total += $gl_line->amount;
130 } /* end of class defintion */
135 /* Contains relavent information from the purch_order_details as well to provide in cached form,
136 all the info to do the necessary entries without looking up ie additional queries of the database again */
141 var $item_description;
143 var $prev_quantity_inv;
144 var $this_quantity_inv;
151 function grn_item ($id, $po_detail_item, $item_code, $item_description, $qty_recd,
152 $prev_quantity_inv, $this_quantity_inv, $order_price, $chg_price, $Complete,
153 $std_cost_unit, $gl_code)
157 $this->po_detail_item = $po_detail_item;
158 $this->item_code = $item_code;
159 $this->item_description = $item_description;
160 $this->qty_recd = $qty_recd;
161 $this->prev_quantity_inv = $prev_quantity_inv;
162 $this->this_quantity_inv = $this_quantity_inv;
163 $this->order_price =$order_price;
164 $this->chg_price = $chg_price;
165 $this->Complete = $Complete;
166 $this->std_cost_unit = $std_cost_unit;
167 $this->gl_code = $gl_code;
170 function full_charge_price($tax_group_id, $tax_group=null)
172 return get_full_price_for_item($this->item_code,
173 $this->chg_price, $tax_group_id, 0, $tax_group);
176 function taxfree_charge_price($tax_group_id, $tax_group=null)
178 // if ($tax_group_id==null)
179 // return $this->chg_price;
180 return get_tax_free_price_for_item($this->item_code, $this->chg_price,
181 $tax_group_id, 0, $tax_group);
197 function gl_codes ($Counter, $gl_code, $gl_act_name, $gl_dim, $gl_dim2, $amount, $memo_)
200 /* Constructor function to add a new gl_codes object with passed params */
201 $this->Counter = $Counter;
202 $this->gl_code = $gl_code;
203 $this->gl_act_name = $gl_act_name;
204 $this->gl_dim = $gl_dim;
205 $this->gl_dim2 = $gl_dim2;
206 $this->amount = $amount;
207 $this->memo_= $memo_;