X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=purchasing%2Fincludes%2Fdb%2Finvoice_db.inc;h=c4e4c1c918d9b1d6d52fcb25d4f3aa0494d3a8d3;hb=9ff22040ec9e77b56c71df9bd95f9b2c2d50bd7e;hp=eadf5724a8a5ee1c2d9209d3ce2c470430606a87;hpb=4f8c525912353e56d6b78f2020a126012f1acca9;p=fa-stable.git diff --git a/purchasing/includes/db/invoice_db.inc b/purchasing/includes/db/invoice_db.inc index eadf5724..c4e4c1c9 100644 --- a/purchasing/includes/db/invoice_db.inc +++ b/purchasing/includes/db/invoice_db.inc @@ -16,7 +16,7 @@ include_once($path_to_root . "/admin/db/attachments_db.inc"); function read_supplier_details_to_trans(&$supp_trans, $supplier_id) { - $sql = "SELECT supp.supp_name, terms.terms, terms.days_before_due, + $sql = "SELECT supp.supp_name, terms.terms, terms.days_before_due, supp.dimension_id, supp.dimension2_id, terms.day_in_following_month, supp.tax_included, supp.tax_group_id, tax_group.name AS tax_group_name, supp.credit_limit - Sum(IFNULL(IF(trans.type=".ST_SUPPCREDIT.", -1, 1) @@ -55,7 +55,9 @@ function read_supplier_details_to_trans(&$supp_trans, $supplier_id) $supp_trans->tax_description = $myrow['tax_group_name']; $supp_trans->tax_group_id = $myrow['tax_group_id']; - + $supp_trans->dimension = $myrow['dimension_id']; + $supp_trans->dimension2 = $myrow['dimension2_id']; + } //------------------------------------------------------------------------------------------------- @@ -70,10 +72,10 @@ function update_supp_received_items_for_invoice($id, $po_detail_item, $qty_invoi $sql = "SELECT act_price, unit_price FROM ".TB_PREF."purch_order_details WHERE po_detail_item = ".db_escape($po_detail_item); $result = db_query($sql, "The old actual price of the purchase order line could not be retrieved"); - $row = db_fetch_row($result); - $ret = $row[0]; + $row = db_fetch($result); + $ret = $row['act_price']; - $unit_price = $row[1]; //Added by Rasmus + $unit_price = $row['unit_price']; //Added by Rasmus $sql = "SELECT delivery_date FROM ".TB_PREF."grn_batch grn," @@ -81,8 +83,8 @@ function update_supp_received_items_for_invoice($id, $po_detail_item, $qty_invoi WHERE grn.id = line.grn_batch_id AND line.id=".db_escape($id); $result = db_query($sql, "The old delivery date from the received record cout not be retrieved"); - $row = db_fetch_row($result); - $date = $row[0]; + $row = db_fetch($result); + $date = $row['delivery_date']; } else { @@ -135,7 +137,7 @@ function add_supp_invoice(&$supp_trans) $tax_total = 0; $taxes = $supp_trans->get_taxes($supp_trans->tax_group_id); if ($trans_no) { - $allocs = get_payments_for($trans_no, $trans_type); // save allocations + $allocs = get_payments_for($trans_no, $trans_type, $supp_trans->supplier_id); // save allocations void_transaction($trans_type, $trans_no, Today(), _("Document reentered.")); $Refs->restore_last($trans_type, $trans_no); } else @@ -393,11 +395,7 @@ function add_supp_invoice(&$supp_trans) } } -//_vd($allocs); - reallocate_payments($invoice_id, ST_SUPPINVOICE, $date_, $to_allocate, $allocs); -//_vd(get_payments_for($sales_order, ST_PURCHORDER)); -//_vd(get_payments_for($invoice_id, ST_SUPPINVOICE)); -//exit; + reallocate_payments($invoice_id, ST_SUPPINVOICE, $date_, $to_allocate, $allocs, $supp_trans->supplier_id); $supp_trans->trans_no = $invoice_id; hook_db_postwrite($supp_trans, $supp_trans->trans_type); commit_transaction(); @@ -451,7 +449,7 @@ function get_tax_overrides($trans_type, $trans_no) function read_supp_invoice($trans_no, $trans_type, &$supp_trans) { - $sql = "SELECT trans.*, supp_name + $sql = "SELECT trans.*, supp_name, dimension_id, dimension2_id FROM ".TB_PREF."supp_trans trans," .TB_PREF."suppliers sup WHERE trans_no = ".db_escape($trans_no)." AND type = ".db_escape($trans_type)." @@ -474,6 +472,8 @@ function read_supp_invoice($trans_no, $trans_type, &$supp_trans) $supp_trans->ov_discount = $trans_row["ov_discount"]; $supp_trans->ov_gst = $trans_row["ov_gst"]; $supp_trans->tax_included = $trans_row["tax_included"]; + $supp_trans->dimension = $trans_row["dimension_id"]; + $supp_trans->dimension2 = $trans_row["dimension2_id"]; $id = $trans_row["trans_no"];