From 84d8d0538feb7f279d5623193e5a8f246c838c68 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 6 Nov 2012 15:21:55 +0530 Subject: [PATCH] gross profit report fix --- selling/search_criteria/gross_profit/gross_profit.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/selling/search_criteria/gross_profit/gross_profit.py b/selling/search_criteria/gross_profit/gross_profit.py index c0909a697b..34719226e3 100644 --- a/selling/search_criteria/gross_profit/gross_profit.py +++ b/selling/search_criteria/gross_profit/gross_profit.py @@ -66,9 +66,15 @@ def get_purchase_cost(dn, item, wh, qty, dn_item_row_id): else: packing_items = [[item, qty]] for d in sle: - if d['voucher_no'] == dn and [d['item_code'], flt(abs(d['actual_qty']))] in packing_items: - if not d['voucher_detail_no'] or d['voucher_detail_no'] == dn_item_row_id: + if packing_items: + if d['voucher_no'] == dn \ + and [d['item_code'], flt(abs(d['actual_qty']))] in packing_items \ + and (not d['voucher_detail_no'] or d['voucher_detail_no'] == dn_item_row_id): purchase_cost += flt(d['incoming_rate'])*flt(abs(d['actual_qty'])) + packing_items.remove([d['item_code'], flt(abs(d['actual_qty']))]) + else: + break + return purchase_cost out, tot_amount, tot_pur_cost = [], 0, 0