From d8b7f8eb77003e22300d97798f180346222da524 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 5 Aug 2011 11:13:27 +0530 Subject: [PATCH] fn reordered in sales common --- selling/doctype/sales_common/sales_common.py | 42 ++++++++++---------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/selling/doctype/sales_common/sales_common.py b/selling/doctype/sales_common/sales_common.py index 25dd960bdc..7a1af22448 100644 --- a/selling/doctype/sales_common/sales_common.py +++ b/selling/doctype/sales_common/sales_common.py @@ -329,6 +329,28 @@ class DocType(TransactionBase): il.append([warehouse, d.item_code, qty, reserved_qty, d.stock_uom, d.batch_no, d.serial_no]) return il + # --------------------------------------------------------------------------------------------- + # get qty, amount already billed or delivered against curr line item for current doctype + # For Eg: SO-RV get total qty, amount from SO and also total qty, amount against that SO in RV + # --------------------------------------------------------------------------------------------- + def get_curr_and_ref_doc_details(self, curr_doctype, ref_tab_fname, ref_tab_dn, ref_doc_tname, curr_parent_name, curr_parent_doctype): + # Get total qty, amt of current doctype (eg RV) except for qty, amt of this transaction + if curr_parent_doctype == 'Installation Note': + curr_det = sql("select sum(qty) from `tab%s` where %s = '%s' and docstatus = 1 and parent != '%s'"% (curr_doctype, ref_tab_fname, ref_tab_dn, curr_parent_name)) + qty, amt = curr_det and flt(curr_det[0][0]) or 0, 0 + else: + curr_det = sql("select sum(qty), sum(amount) from `tab%s` where %s = '%s' and docstatus = 1 and parent != '%s'"% (curr_doctype, ref_tab_fname, ref_tab_dn, curr_parent_name)) + qty, amt = curr_det and flt(curr_det[0][0]) or 0, curr_det and flt(curr_det[0][1]) or 0 + + # get total qty of ref doctype + ref_det = sql("select qty, amount from `tab%s` where name = '%s' and docstatus = 1"% (ref_doc_tname, ref_tab_dn)) + max_qty, max_amt = ref_det and flt(ref_det[0][0]) or 0, ref_det and flt(ref_det[0][1]) or 0 + + return qty, max_qty, amt, max_amt + + + + # ----------------------- # add packing list items @@ -458,26 +480,6 @@ class DocType(TransactionBase): def update_prevdoc_detail(self, is_submit, obj): StatusUpdater(obj, is_submit).update() - # --------------------------------------------------------------------------------------------- - # get qty, amount already billed or delivered against curr line item for current doctype - # For Eg: SO-RV get total qty, amount from SO and also total qty, amount against that SO in RV - # --------------------------------------------------------------------------------------------- - def get_curr_and_ref_doc_details(self, curr_doctype, ref_tab_fname, ref_tab_dn, ref_doc_tname, curr_parent_name, curr_parent_doctype): - # Get total qty, amt of current doctype (eg RV) except for qty, amt of this transaction - if curr_parent_doctype == 'Installation Note': - curr_det = sql("select sum(qty) from `tab%s` where %s = '%s' and docstatus = 1 and parent != '%s'"% (curr_doctype, ref_tab_fname, ref_tab_dn, curr_parent_name)) - qty, amt = curr_det and flt(curr_det[0][0]) or 0, 0 - else: - curr_det = sql("select sum(qty), sum(amount) from `tab%s` where %s = '%s' and docstatus = 1 and parent != '%s'"% (curr_doctype, ref_tab_fname, ref_tab_dn, curr_parent_name)) - qty, amt = curr_det and flt(curr_det[0][0]) or 0, curr_det and flt(curr_det[0][1]) or 0 - - # get total qty of ref doctype - ref_det = sql("select qty, amount from `tab%s` where name = '%s' and docstatus = 1"% (ref_doc_tname, ref_tab_dn)) - max_qty, max_amt = ref_det and flt(ref_det[0][0]) or 0, ref_det and flt(ref_det[0][1]) or 0 - - return qty, max_qty, amt, max_amt - -