X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=sales%2Fcustomer_invoice.php;h=e6ded2d3a4e025315f2adc6241c7c53145d0cf6d;hb=6c40a3be4a79826087d7abbdd11b483f19decc2a;hp=9ec89b569eede7069de04c40653e9714a729ca54;hpb=a9d55e1c13cbd6a6305b9322ec8621a06516f9f3;p=fa-stable.git diff --git a/sales/customer_invoice.php b/sales/customer_invoice.php index 9ec89b56..e6ded2d3 100644 --- a/sales/customer_invoice.php +++ b/sales/customer_invoice.php @@ -160,16 +160,15 @@ if ( (isset($_GET['DeliveryNumber']) && ($_GET['DeliveryNumber'] > 0) ) } else { $order_no = $_GET['InvoicePrepayments']; - $payments = get_payments_for($_GET['InvoicePrepayments'], ST_SALESORDER); } processing_start(); - $_SESSION['Items'] = new Cart(ST_SALESORDER, $order_no, ST_SALESINVOICE); + $_SESSION['Items'] = new cart(ST_SALESORDER, $order_no, ST_SALESINVOICE); $_SESSION['Items']->order_no = $order_no; $_SESSION['Items']->src_docs = array($order_no); $_SESSION['Items']->trans_no = 0; $_SESSION['Items']->trans_type = ST_SALESINVOICE; - $_SESSION['Items']->prepayments = $payments; + $_SESSION['Items']->update_payments(); copy_from_cart(); @@ -205,7 +204,8 @@ function check_quantities() $max = $itm->quantity; } else { $min = 0; - $max = $itm->quantity - $itm->qty_done; + // Fixing floating point problem in PHP. + $max = round2($itm->quantity - $itm->qty_done, get_qty_dec($itm->stock_id)); } if (check_num('Line'.$line_no, $min, $max)) { $_SESSION['Items']->line_items[$line_no]->qty_dispatched = @@ -234,7 +234,7 @@ function set_delivery_shipping_sum($delivery_notes) foreach($delivery_notes as $delivery_num) { - $myrow = get_customer_trans($delivery_num, 13); + $myrow = get_customer_trans($delivery_num, ST_CUSTDELIVERY); $shipping += $myrow['ov_freight']; } @@ -342,7 +342,7 @@ function check_data() return false; } } else { - if (($_SESSION['Items']->payment_terms['days_before_due'] < 0) && !count($_SESSION['Items']->prepayments)) { + if (($_SESSION['Items']->payment_terms['days_before_due'] == -1) && !count($_SESSION['Items']->prepayments)) { display_error(_("There is no non-invoiced payments for this order. If you want to issue final invoice, select delayed or cash payment terms.")); return false; } @@ -355,6 +355,7 @@ function check_data() if (isset($_POST['process_invoice']) && check_data()) { $newinvoice= $_SESSION['Items']->trans_no == 0; copy_to_cart(); + if ($newinvoice) new_doc_date($_SESSION['Items']->document_date); @@ -649,10 +650,10 @@ if ($prepaid) $allocs += $pmt['amt']; } } - label_row(_("Payments received:"), implode(',', $list)); label_row(_("Invoiced here:"), price_format($_SESSION['Items']->prep_amount), 'class=label'); - label_row(_("Left to be invoiced:"), price_format($_SESSION['Items']->get_trans_total()-max($_SESSION['Items']->prep_amount, $allocs)), 'class=label'); + label_row($_SESSION['Items']->payment_terms['days_before_due'] == -1 ? _("Left to be invoiced:") : _("Invoiced so far:"), + price_format($_SESSION['Items']->get_trans_total()-max($_SESSION['Items']->prep_amount, $allocs)), 'class=label'); } textarea_row(_("Memo:"), 'Comments', null, 50, 4);