Various small code cleanups.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Sat, 14 Sep 2013 16:07:13 +0000 (18:07 +0200)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 16 Sep 2013 11:51:39 +0000 (13:51 +0200)
gl/bank_transfer.php
gl/includes/db/gl_db_banking.inc
purchasing/supplier_payment.php
sales/customer_payments.php
sales/inquiry/customer_inquiry.php

index 6deb5fe2ed1321e69b0fddb3ebdb90e77b987d3f..281c671d3435745f766c2d44f256bb86b9b1d4d8 100644 (file)
@@ -87,7 +87,7 @@ function gl_payment_controls()
                amount_row(_("Amount:"), 'amount', null, null, $from_currency);
                amount_row(_("Bank Charge:"), 'charge', null, null, $from_currency);
 
-               amount_row("Incomming Amount:", 'target_amount', null, '', $to_currency, 2);
+               amount_row(_("Incomming Amount:"), 'target_amount', null, '', $to_currency, 2);
        } 
        else 
        {
index 5774de8577aa229c0f77b859c088e6784459023d..13fbd6de688a201682d1cb57b01dd77dc4e37438 100644 (file)
@@ -35,7 +35,7 @@ function add_exchange_variation($trans_no, $date_, $acc_id, $account,
        }       
        $amount = get_gl_trans_from_to("", $date_, $account);
        $diff = $amount - $for_amount;
-       if ($diff != 0)
+       if (floatcmp($diff,0))
        {
                if ($trans_no == null)
                        $trans_no = get_next_trans_no(ST_JOURNAL);
@@ -45,8 +45,9 @@ function add_exchange_variation($trans_no, $date_, $acc_id, $account,
                -$diff, null, $person_type_id, $person_id);
        add_gl_trans(ST_JOURNAL, $trans_no, $date_, get_company_pref('exchange_diff_act'), 0, 0, 
                _("Exchange Variance"), $diff, null, $person_type_id, $person_id);
+               return true;
        }
-       return ($diff != 0);
+       return false;
 }
 
 //------------- New helper functions for revaluation of customer/supplier currencies 2011-05-08 Joe Hunt.
index c68e482ffcd39d386092aaab3457e0f41aa8c92b..86d102de11f9a64efdf535a0e5fcb4c1b70dabd6 100644 (file)
@@ -143,13 +143,6 @@ function check_inputs()
                }       
        }
 
-//     if (isset($_POST['_ex_rate']) && !check_num('_ex_rate', 0.000001))
-//     {
-//             display_error(_("The exchange rate must be numeric and greater than zero."));
-//             set_focus('_ex_rate');
-//             return false;
-//     }
-
        if ($_POST['discount'] == "") 
        {
                $_POST['discount'] = 0;
@@ -162,7 +155,6 @@ function check_inputs()
                return false;
        }
 
-       //if (input_num('amount') - input_num('discount') <= 0) 
        if (input_num('amount') <= 0) 
        {
                display_error(_("The total of the amount and the discount is zero or negative. Please enter positive values."));
@@ -228,19 +220,6 @@ function check_inputs()
 
 function handle_add_payment()
 {
-       $supp_currency = get_supplier_currency($_POST['supplier_id']);
-       $bank_currency = get_bank_account_currency($_POST['bank_account']);
-       $comp_currency = get_company_currency();
-
-       if ($comp_currency != $bank_currency && $bank_currency != $supp_currency)
-               $rate = 0;
-       else
-       {
-               $rate = input_num('_ex_rate');
-               $supplier_amount = input_num('bank_amount'); 
-                       if($supplier_amount) $rate = input_num('amount')/$supplier_amount;
-       }
-
        $payment_id = write_supp_payment(0, $_POST['supplier_id'], $_POST['bank_account'],
                $_POST['DatePaid'], $_POST['ref'], input_num('amount'), input_num('discount'), $_POST['memo_'], 
                input_num('charge'), input_num('bank_amount', input_num('amount')));
index 549062589b3f52b97c2edd7f733441c537a77221..4e707158c7c580d7181248f0814bfefeaf44b4fc 100644 (file)
@@ -249,14 +249,6 @@ if (isset($_POST['_customer_id_button'])) {
 //----------------------------------------------------------------------------------------------
 
 if (get_post('AddPaymentItem') && can_process()) {
-       
-       $cust_currency = get_customer_currency($_POST['customer_id']);
-       $bank_currency = get_bank_account_currency($_POST['bank_account']);
-       $comp_currency = get_company_currency();
-//     if ($comp_currency != $bank_currency && $bank_currency != $cust_currency)
-//             $rate = 0;
-//     else
-//             $rate = input_num('_ex_rate');
 
        new_doc_date($_POST['DateBanked']);
 
index 3ebc84b5c0b624034f7904947c314836bb126cb5..6c9a97cc1b4796df0debb90629ac59a8b890ef12 100644 (file)
@@ -167,36 +167,29 @@ function credit_link($row)
 
 function edit_link($row)
 {
-       $str = '';
-
-       if (@$_GET['popup'])
+       if (@$_GET['popup'] || get_voided_entry($row['type'], $row["trans_no"]) || is_closed_trans($row['type'], $row["trans_no"]))
                return '';
+
+       $str = '';
        switch($row['type']) {
-       case ST_SALESINVOICE:
-               if (get_voided_entry(ST_SALESINVOICE, $row["trans_no"]) === false && $row['Allocated'] == 0)
+               case ST_SALESINVOICE:
                        $str = "/sales/customer_invoice.php?ModifyInvoice=".$row['trans_no'];
                break;
-       case ST_CUSTCREDIT:
-               if (get_voided_entry(ST_CUSTCREDIT, $row["trans_no"]) === false && $row['Allocated'] == 0) // 2008-11-19 Joe Hunt
-               {        
+               case ST_CUSTCREDIT:
                        if ($row['order_']==0) // free-hand credit note
                            $str = "/sales/credit_note_entry.php?ModifyCredit=".$row['trans_no'];
                        else    // credit invoice
                            $str = "/sales/customer_credit_invoice.php?ModifyCredit=".$row['trans_no'];
-               }           
                break;
-       case ST_CUSTDELIVERY:
-               if (get_voided_entry(ST_CUSTDELIVERY, $row["trans_no"]) === false)
+               case ST_CUSTDELIVERY:
                        $str = "/sales/customer_delivery.php?ModifyDelivery=".$row['trans_no'];
                break;
-       case ST_CUSTPAYMENT:
-               if (get_voided_entry(ST_CUSTPAYMENT, $row["trans_no"]) === false)
+               case ST_CUSTPAYMENT:
                        $str = "/sales/customer_payments.php?trans_no=".$row['trans_no'];
                break;
-       }               
-       if ($str != "" && !is_closed_trans($row['type'], $row["trans_no"]))
-               return pager_link(_('Edit'), $str, ICON_EDIT);
-       return '';      
+       }
+
+       return $str ? pager_link(_('Edit'), $str, ICON_EDIT) : '';
 }
 
 function prt_link($row)