Fixed current purchasing credit display.
authorJanusz Dobrowolski <janusz@frontaccouting.eu>
Mon, 11 Feb 2013 07:30:08 +0000 (08:30 +0100)
committerJanusz Dobrowolski <janusz@frontaccouting.eu>
Mon, 11 Feb 2013 07:30:08 +0000 (08:30 +0100)
purchasing/includes/db/invoice_db.inc
purchasing/includes/ui/po_ui.inc

index 3ffc35d3abc23a8ac628a5a5f2f9074bb51f1096..6cc3f15e094a72ca06df18a5fac65e1de643805a 100644 (file)
@@ -18,8 +18,7 @@ function read_supplier_details_to_trans(&$supp_trans, $supplier_id)
        $sql = "SELECT supp.supp_name, terms.terms, terms.days_before_due,
                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) 
-                       * (ov_amount + ov_gst + ov_discount),0)) as cur_credit
+               supp.credit_limit - Sum(IFNULL(ov_amount + ov_gst + ov_discount,0)) as cur_credit
                FROM ".TB_PREF."suppliers supp 
                        LEFT JOIN ".TB_PREF."supp_trans trans ON supp.supplier_id = trans.supplier_id, "
                        .TB_PREF."payment_terms terms, ".TB_PREF."tax_groups tax_group
@@ -38,7 +37,7 @@ function read_supplier_details_to_trans(&$supp_trans, $supplier_id)
                'description' => $myrow['terms'],
                'days_before_due' => $myrow['days_before_due'], 
                'day_in_following_month' => $myrow['day_in_following_month'] );
-               
+
        $supp_trans->credit = $myrow['cur_credit'];
 
        $supp_trans->tax_description = $myrow['tax_group_name'];
index ec2c600fd5514bff07584c643cd017bef1fd6f86..a7e383eb217008bd85480f3a547b145ba65554ac 100644 (file)
@@ -47,8 +47,7 @@ function copy_to_cart()
 function get_supplier_details_to_order(&$order, $supplier_id)
 {
        $sql = "SELECT curr_code, supp_name, tax_group_id, supp.tax_included,
-                       supp.credit_limit - Sum(IFNULL(IF(trans.type=".ST_SUPPCREDIT.", -1, 1) 
-                               * (ov_amount + ov_gst + ov_discount),0)) as cur_credit,
+                       supp.credit_limit - Sum(IFNULL(ov_amount + ov_gst + ov_discount,0)) as cur_credit,
                                terms.terms, terms.days_before_due, terms.day_in_following_month
                FROM ".TB_PREF."suppliers supp
                         LEFT JOIN ".TB_PREF."supp_trans trans ON supp.supplier_id = trans.supplier_id