From: Janusz Dobrowolski Date: Thu, 16 Nov 2017 18:56:08 +0000 (+0100) Subject: Fixed rounding differences in sales delivery and invoice. X-Git-Tag: v2.4.4~58 X-Git-Url: https://delta.frontaccounting.com/gitweb/?p=fa-stable.git;a=commitdiff_plain;h=2d01d55a1449c6187b25743f8e08ccf8d79bd713 Fixed rounding differences in sales delivery and invoice. --- diff --git a/sales/includes/db/sales_delivery_db.inc b/sales/includes/db/sales_delivery_db.inc index 8276eb51..15b4736d 100644 --- a/sales/includes/db/sales_delivery_db.inc +++ b/sales/includes/db/sales_delivery_db.inc @@ -70,20 +70,21 @@ function write_sales_delivery(&$delivery,$bo_policy) } foreach ($delivery->line_items as $line_no => $delivery_line) { + $qty = $delivery_line->qty_dispatched; $line_price = $delivery_line->line_price(); $line_taxfree_price = get_tax_free_price_for_item($delivery_line->stock_id, - $delivery_line->price, 0, $delivery->tax_included, + $delivery_line->price*$qty, 0, $delivery->tax_included $delivery->tax_group_array); - $line_tax = get_full_price_for_item($delivery_line->stock_id, $delivery_line->price, - 0, $delivery->tax_included, $delivery->tax_group_array) - $line_taxfree_price; + $line_tax = get_full_price_for_item(ST_CUSTDELIVERY, $delivery_line->stock_id, + $delivery_line->price * $qty, 0, $delivery->tax_included, $delivery->tax_group_array) - $line_taxfree_price $delivery_line->standard_cost = get_unit_cost($delivery_line->stock_id); /* add delivery details for all lines */ write_customer_trans_detail_item(ST_CUSTDELIVERY, $delivery_no, $delivery_line->stock_id, $delivery_line->item_description, $delivery_line->qty_dispatched, - $delivery_line->line_price(), $line_tax, + $delivery_line->line_price(), $qty ? $line_tax/$qty : 0, $delivery_line->discount_percent, $delivery_line->standard_cost, $delivery_line->src_id, $trans_no ? $delivery_line->id : 0); @@ -119,8 +120,7 @@ function write_sales_delivery(&$delivery,$bo_policy) $sales_account = ($branch_data['sales_account'] != "" ? $branch_data['sales_account'] : $stock_gl_code['sales_account']); $total += add_gl_trans_customer(ST_CUSTDELIVERY, $delivery_no, $delivery->document_date, $sales_account, $dim, $dim2, - -$line_taxfree_price*$delivery_line->qty_dispatched, // FIXME - calculation order should be exactly like in invoice to minimalize roundings - $delivery->customer_id, "The sales price GL posting could not be inserted"); + -$line_taxfree_price, $delivery->customer_id, "The sales price GL posting could not be inserted"); } /* insert gl_trans to credit stock and debit cost of sales at standard cost*/