X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=sales%2Fincludes%2Fdb%2Fsales_delivery_db.inc;h=3a000103adb4d253361dc2354b79f34e8c737d24;hb=d32bf132413c22c5a19966160fcd574346f63b24;hp=8276eb5113d335a30e46aa0c9d61cbb51fd2c7f5;hpb=203767c14f89edb2740c8ca1dcbba0e55468aa3e;p=fa-stable.git diff --git a/sales/includes/db/sales_delivery_db.inc b/sales/includes/db/sales_delivery_db.inc index 8276eb51..3a000103 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($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*/