Fixed amibiguity in few text messages to make translations easier, updated gettext...
[fa-stable.git] / purchasing / includes / db / suppliers_db.inc
index d02353babcfd7459e755765040e6f44d2331e4a5..733f5b159b44e85a533abd245fa02dcabd893a0a 100644 (file)
@@ -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)";
@@ -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];
+}
+