From a9671009908d0915e93a3062d37c0c63aa654d71 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 27 Nov 2013 12:05:15 +0530 Subject: [PATCH 1/3] Update payment_collection_with_ageing.py --- .../payment_collection_with_ageing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/accounts/report/payment_collection_with_ageing/payment_collection_with_ageing.py b/accounts/report/payment_collection_with_ageing/payment_collection_with_ageing.py index 41c5f3e18a..0c2078bbab 100644 --- a/accounts/report/payment_collection_with_ageing/payment_collection_with_ageing.py +++ b/accounts/report/payment_collection_with_ageing/payment_collection_with_ageing.py @@ -21,7 +21,7 @@ def execute(filters=None): d.debit, d.credit, d.cheque_no, d.cheque_date, d.remark] if d.against_invoice: - row += get_ageing_data(against_invoice_date, d.posting_date, d.credit or -1*d.debit) + row += get_ageing_data(d.posting_date, against_invoice_date, d.credit or -1*d.debit) else: row += ["", "", "", "", ""] @@ -74,4 +74,4 @@ def get_si_posting_date_map(): for t in webnotes.conn.sql("""select name, posting_date from `tabSales Invoice`"""): si_posting_date_map[t[0]] = t[1] - return si_posting_date_map \ No newline at end of file + return si_posting_date_map From a07a5084c14dd9861edc3f279013884c1437a4b3 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 27 Nov 2013 12:05:32 +0530 Subject: [PATCH 2/3] Update payment_made_with_ageing.py --- .../payment_made_with_ageing/payment_made_with_ageing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/accounts/report/payment_made_with_ageing/payment_made_with_ageing.py b/accounts/report/payment_made_with_ageing/payment_made_with_ageing.py index 8d3618f4dd..a7e79bfc19 100644 --- a/accounts/report/payment_made_with_ageing/payment_made_with_ageing.py +++ b/accounts/report/payment_made_with_ageing/payment_made_with_ageing.py @@ -21,7 +21,7 @@ def execute(filters=None): d.debit, d.credit, d.cheque_no, d.cheque_date, d.remark] if d.against_voucher: - row += get_ageing_data(against_voucher_date, d.posting_date, d.debit or -1*d.credit) + row += get_ageing_data(d.posting_date, against_voucher_date, d.debit or -1*d.credit) else: row += ["", "", "", "", ""] @@ -73,4 +73,4 @@ def get_pi_posting_date_map(): for t in webnotes.conn.sql("""select name, posting_date from `tabPurchase Invoice`"""): pi_posting_date_map[t[0]] = t[1] - return pi_posting_date_map \ No newline at end of file + return pi_posting_date_map From a8386c12830820fcc082ac342264eff2696c251c Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 27 Nov 2013 17:28:27 +0530 Subject: [PATCH 3/3] [fix] [minor] serial no fix for status update --- stock/doctype/serial_no/serial_no.py | 39 +++++++++++++++------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/stock/doctype/serial_no/serial_no.py b/stock/doctype/serial_no/serial_no.py index e196f6c7ee..9d34abfc25 100644 --- a/stock/doctype/serial_no/serial_no.py +++ b/stock/doctype/serial_no/serial_no.py @@ -129,32 +129,35 @@ class DocType(StockController): "delivery_date", "delivery_time", "customer", "customer_name", "warranty_expiry_date"): self.doc.fields[fieldname] = None - + def get_last_sle(self): entries = {} + sle_dict = self.get_stock_ledger_entries() + if sle_dict.get("incoming", []): + entries["purchase_sle"] = sle_dict["incoming"][0] - for sle in self.get_stock_ledger_entries(): - if self.doc.name in get_serial_nos(sle.serial_no): - if not entries.get("last_sle"): - entries["last_sle"] = sle - - if not entries.get("purchase_sle") and sle.actual_qty > 0: - entries["purchase_sle"] = sle - elif not entries.get("delivery_sle") and sle.actual_qty < 0 \ - and sle.voucher_type in ('Delivery Note', 'Sales Invoice'): - entries["delivery_sle"] = sle - - if entries.get("last_sle") and entries.get("purchase_sle") \ - and entries.get("delivery_sle"): - break + if len(sle_dict.get("incoming", [])) - len(sle_dict.get("outgoing", [])) > 0: + entries["last_sle"] = sle_dict["incoming"][0] + else: + entries["last_sle"] = sle_dict["outgoing"][0] + entries["delivery_sle"] = sle_dict["outgoing"][0] return entries def get_stock_ledger_entries(self): - return webnotes.conn.sql("""select * from `tabStock Ledger Entry` + sle_dict = {} + for sle in webnotes.conn.sql("""select * from `tabStock Ledger Entry` where serial_no like %s and item_code=%s and ifnull(is_cancelled, 'No')='No' - order by name desc""", ("%%%s%%" % self.doc.name, self.doc.item_code), as_dict=1) - + order by posting_date desc, posting_time desc, name desc""", + ("%%%s%%" % self.doc.name, self.doc.item_code), as_dict=1): + if self.doc.name in get_serial_nos(sle.serial_no): + if sle.actual_qty > 0: + sle_dict.setdefault("incoming", []).append(sle) + else: + sle_dict.setdefault("outgoing", []).append(sle) + + return sle_dict + def on_trash(self): if self.doc.status == 'Delivered': webnotes.throw(_("Delivered Serial No ") + self.doc.name + _(" can not be deleted"))