X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=purchasing%2Fincludes%2Fdb%2Fsuppliers_db.inc;h=733f5b159b44e85a533abd245fa02dcabd893a0a;hb=477c1f221df891f39e9363f7b34e6ff1eb4ad4c7;hp=dd9e49c906fa3cbb4689ba5e95e2387d368555e3;hpb=f30537908e67494d74831f50490df4b965e657ff;p=fa-stable.git diff --git a/purchasing/includes/db/suppliers_db.inc b/purchasing/includes/db/suppliers_db.inc index dd9e49c9..733f5b15 100644 --- a/purchasing/includes/db/suppliers_db.inc +++ b/purchasing/includes/db/suppliers_db.inc @@ -27,7 +27,7 @@ function add_supplier($supp_name, $supp_ref, $address, $supp_address, $gst_no, .db_escape($website). ", " .db_escape($supp_account_no). ", " .db_escape($bank_account). ", " - .db_escape($credit_limit). ", " + .$credit_limit. ", " .db_escape($dimension_id). ", " .db_escape($dimension2_id). ", " .db_escape($curr_code). ", " @@ -91,7 +91,8 @@ function get_supplier_details($supplier_id, $to=null, $all=true) if ($all) $value = "(trans.ov_amount + trans.ov_gst + trans.ov_discount)"; else - $value = "IF (trans.type=".ST_SUPPINVOICE." OR trans.type=".ST_BANKDEPOSIT.", + $value = "IF (trans.type=".ST_SUPPINVOICE." OR trans.type=".ST_BANKDEPOSIT." + OR (trans.type=".ST_JOURNAL." AND (trans.ov_amount + trans.ov_gst + trans.ov_discount)>0), (trans.ov_amount + trans.ov_gst + trans.ov_discount - trans.alloc), (trans.ov_amount + trans.ov_gst + trans.ov_discount + trans.alloc))"; $due = "IF (trans.type=".ST_SUPPINVOICE." OR trans.type=".ST_SUPPCREDIT.",trans.due_date,trans.tran_date)"; @@ -99,9 +100,9 @@ function get_supplier_details($supplier_id, $to=null, $all=true) Sum(IFNULL($value,0)) AS Balance, - Sum(IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= 0,$value,0)) AS Due, - Sum(IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= $past1,$value,0)) AS Overdue1, - Sum(IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= $past2,$value,0)) AS Overdue2, + Sum(IF ((TO_DAYS('$todate') - TO_DAYS($due)) > 0,$value,0)) AS Due, + Sum(IF ((TO_DAYS('$todate') - TO_DAYS($due)) > $past1,$value,0)) AS Overdue1, + Sum(IF ((TO_DAYS('$todate') - TO_DAYS($due)) > $past2,$value,0)) AS Overdue2, supp.credit_limit - Sum(IFNULL(IF(trans.type=".ST_SUPPCREDIT.", -1, 1) * (ov_amount + ov_gst + ov_discount),0)) as cur_credit, supp.tax_group_id @@ -120,7 +121,6 @@ function get_supplier_details($supplier_id, $to=null, $all=true) ".TB_PREF."payment_terms.terms, ".TB_PREF."payment_terms.days_before_due, ".TB_PREF."payment_terms.day_in_following_month"; - $result = db_query($sql,"The customer details could not be retrieved"); $supp = db_fetch($result); @@ -179,4 +179,14 @@ function is_new_supplier($id) return !key_in_foreign_table($id, $tables, 'supplier_id'); } -?> \ No newline at end of file + +function get_supplier_currency($supplier_id) +{ + $sql = "SELECT curr_code FROM ".TB_PREF."suppliers WHERE supplier_id = ".db_escape($supplier_id); + + $result = db_query($sql, "Retreive currency of supplier $supplier_id"); + + $myrow=db_fetch_row($result); + return $myrow[0]; +} +