Customer Payment, Supplier Payment: early discount support.
[fa-stable.git] / sales / customer_payments.php
index 1d23a3829e66296e6ed3cd9e7f36599773b1e090..68b0c624df23bcfe6df21f892401c75d5997c531 100644 (file)
@@ -198,20 +198,9 @@ function can_process()
                }       
        }
 
-       if (@$_POST['discount'] == "") 
-       {
-               $_POST['discount'] = 0;
-       }
-
-       if (!check_num('discount')) {
-               display_error(_("The entered discount is not a valid number."));
-               set_focus('discount');
-               return false;
-       }
-
        if (input_num('amount') <= 0) {
                display_error(_("The balance of the amount and discount is zero or negative. Please enter valid amounts."));
-               set_focus('discount');
+               set_focus('amount');
                return false;
        }
 
@@ -249,7 +238,7 @@ if (get_post('AddPaymentItem') && can_process()) {
        $new_pmt = !$_SESSION['alloc']->trans_no;
 
        $payment_no =  save_cust_payment($_SESSION['alloc'], get_post('customer_id'), get_post('BranchID'), get_post('bank_account'),
-               get_post('DateBanked'), get_post('ref'), input_num('amount'), input_num('discount'), get_post('memo_'),
+               get_post('DateBanked'), get_post('ref'), input_num('amount'), get_post('memo_'),
                input_num('charge'), input_num('bank_amount', input_num('amount')));
 
        unset($_SESSION['alloc']);
@@ -305,6 +294,7 @@ if (isset($_GET['trans_no']) && $_GET['trans_no'] > 0 )
        }
 }
 
+
 //----------------------------------------------------------------------------------------------
 $new = !$_SESSION['alloc']->trans_no;
 start_form();
@@ -376,13 +366,15 @@ div_end();
 
 start_table(TABLESTYLE, "width='60%'");
 
-amount_row(_("Amount of Discount:"), 'discount', null, '', $cust_currency);
+label_row(_("Total Discount:"), price_format(input_num('discount')), '','', 0, 'discount');
 
 amount_row(_("Amount:"), 'amount', null, '', $cust_currency);
 
 textarea_row(_("Memo:"), 'memo_', null, 22, 4);
 end_table(1);
 
+hidden('discount', null);
+
 if ($new)
        submit_center('AddPaymentItem', _("Add Payment"), true, '', 'default');
 else