X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=purchasing%2Fincludes%2Fsupp_trans_class.inc;h=8a70e41488f47b4565511838be523cf5f42c8fe4;hb=95f98ed74ac6379b95e2ceb1eb0c9bbcd36fd4a9;hp=a62688e467b41c41bf8084ed2c7c01a8a1c89000;hpb=28e5f95d81850e496e1b0387126e7bb836da61c5;p=fa-stable.git diff --git a/purchasing/includes/supp_trans_class.inc b/purchasing/includes/supp_trans_class.inc index a62688e4..8a70e414 100644 --- a/purchasing/includes/supp_trans_class.inc +++ b/purchasing/includes/supp_trans_class.inc @@ -22,16 +22,19 @@ class supp_trans var $supplier_id; var $supplier_name; var $terms; + var $ex_rate; var $tax_description; var $tax_group_id; var $tax_included; var $trans_type; // invoice or credit + var $trans_no; var $Comments; var $tran_date; var $due_date; + var $src_docs = array(); // source invoice for this credit note (if any) var $supp_reference; var $reference; @@ -40,14 +43,33 @@ class supp_trans var $ov_gst; var $gl_codes_counter=0; var $credit = 0; + var $currency; var $tax_overrides = array(); // array of taxes manually inserted during sales invoice entry - function supp_trans($trans_type) + var $dimension, + $dimension2; + + function __construct($trans_type, $trans_no=0) { $this->trans_type = $trans_type; /*Constructor function initialises a new Supplier Transaction object */ - $this->grn_items = array(); - $this->gl_codes = array(); + $this->read($trans_type, $trans_no); + } + + function read($trans_type, $trans_no) + { + $this->trans_type = $trans_type; + $this->trans_no = $trans_no; + $this->grn_items = array(); + $this->gl_codes = array(); + if ($trans_no) { + read_supp_invoice($trans_no, $trans_type, $this); + if ($trans_type == ST_SUPPCREDIT) + { + $this->src_docs = find_src_invoices($trans_no); + } + read_supplier_details_to_trans($this, $this->supplier_id); + } } function add_grn_to_trans($grn_item_id, $po_detail_item, $item_code, $item_description, @@ -57,6 +79,9 @@ class supp_trans $this->grn_items[$grn_item_id] = new grn_item($grn_item_id, $po_detail_item, $item_code, $item_description, $qty_recd, $prev_quantity_inv, $this_quantity_inv, $order_price, $chg_price, $std_cost_unit, $gl_code, $this->tax_included); + + $this->src_docs = find_src_invoices($this); + unset($this->tax_overrides); // cancel tax overrides after cart change return 1; } @@ -120,23 +145,27 @@ class supp_trans $taxes = get_tax_for_items($items, $prices, $shipping_cost, $tax_group_id, $this->tax_included); - if ($gl_codes) + if (isset($this->tax_overrides)) + foreach($this->tax_overrides as $id => $value) // add values entered manually + { + $taxes[$id]['Override'] = $value; + } + + // Taxes included in gl_codes table have exact value, but count to overrides as well. + // Therefore when we want to now taxes only for items (gl_codes==false), + // we have to subtract gl_taxes from override values. + foreach ($this->gl_codes as $gl_code) { - foreach ($this->gl_codes as $gl_code) + $index = is_tax_account($gl_code->gl_code); + if ($index !== false) { - $index = is_tax_account($gl_code->gl_code); - if ($index !== false) - { + if ($gl_codes) $taxes[$index]['Value'] += $gl_code->amount; - } + elseif (isset($this->tax_overrides)) + $taxes[$index]['Override'] -= $gl_code->amount; } } - if(isset($this->tax_overrides)) - foreach($this->tax_overrides as $id => $value) // add values entered manually - { - $taxes[$id]['Override'] = $value; - } return $taxes; } // @@ -163,7 +192,9 @@ class supp_trans } return $total; } - + // + // Returns transaction total + // function get_items_total() { $total = 0; @@ -199,7 +230,7 @@ all the info to do the necessary entries without looking up ie additional querie var $gl_code; var $tax_included; - function grn_item ($id, $po_detail_item, $item_code, $item_description, $qty_recd, + function __construct($id, $po_detail_item, $item_code, $item_description, $qty_recd, $prev_quantity_inv, $this_quantity_inv, $order_price, $chg_price, $std_cost_unit, $gl_code, $tax_included) { @@ -243,7 +274,7 @@ class gl_codes var $amount; var $memo_; - function gl_codes ($Counter, $gl_code, $gl_act_name, $gl_dim, $gl_dim2, $amount, $memo_) + function __construct($Counter, $gl_code, $gl_act_name, $gl_dim, $gl_dim2, $amount, $memo_) { /* Constructor function to add a new gl_codes object with passed params */ @@ -257,4 +288,3 @@ class gl_codes } } -?>