Customer Allocation Inquiry, Supplier Allocation Inquiry: fixed payment forms initial...
[fa-stable.git] / sales / customer_payments.php
index 1f60e058068e745caccce1e6099f48a0690e033f..bf15289a690f68d6c739666555a6c1b26de30192 100644 (file)
@@ -49,18 +49,19 @@ if (!isset($_POST['bank_account'])) { // first page call
        if (isset($_GET['SInvoice'])) {
                //  get date and supplier
                $inv = get_customer_trans($_GET['SInvoice'], ST_SALESINVOICE);
+               $dflt_act = get_default_bank_account($inv['curr_code']);
+               $_POST['bank_account'] = $dflt_act['id'];
                if($inv) {
-                       $_POST['customer_id'] = $inv['debtor_no'];
+                       $_SESSION['alloc']->person_id = $_POST['customer_id'] = $inv['debtor_no'];
+                       $_SESSION['alloc']->read();
                        $_POST['DateBanked'] = sql2date($inv['tran_date']);
                        foreach($_SESSION['alloc']->allocs as $line => $trans) {
                                if ($trans->type == ST_SALESINVOICE && $trans->type_no == $_GET['SInvoice']) {
                                        $un_allocated = $trans->amount - $trans->amount_allocated;
-                                       if($un_allocated){
-                                       $_POST['amount'] = $_SESSION['alloc']->amount = 
-//                                             price_format($trans->amount);
-                                       $_SESSION['alloc']->allocs[$line]->current_allocated =
-//                                             $trans->amount;
-                                               price_format($un_allocated);}
+                                       if ($un_allocated){
+                                               $_SESSION['alloc']->allocs[$line]->current_allocated = $un_allocated;
+                                               $_POST['amount'] = $_POST['amount'.$line] = price_format($un_allocated);
+                                       }
                                        break;
                                }
                        }