From 9b18ed4ffe05e77f62f1fa8beb489868f4431f04 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 16 Nov 2016 11:27:05 +0530 Subject: [PATCH 01/11] [Fix] Payment entry, exchange rate is not set properly --- .../accounts/doctype/payment_entry/payment_entry.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js index 6ecd8fa5ee..ce0cb50e20 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.js +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js @@ -406,7 +406,10 @@ frappe.ui.form.on('Payment Entry', { if(!frm.doc.paid_amount && frm.doc.paid_from_account_currency == frm.doc.paid_to_account_currency) { frm.set_value("paid_amount", frm.doc.received_amount); - frm.set_value("source_exchange_rate", frm.doc.target_exchange_rate); + + if(frm.doc.target_exchange_rate) { + frm.set_value("source_exchange_rate", frm.doc.target_exchange_rate); + } frm.set_value("base_paid_amount", frm.doc.base_received_amount); } @@ -426,7 +429,10 @@ frappe.ui.form.on('Payment Entry', { (frm.doc.paid_from_account_currency == frm.doc.paid_to_account_currency)) { frm.set_value("received_amount", frm.doc.paid_amount); - frm.set_value("target_exchange_rate", frm.doc.source_exchange_rate); + + if(frm.doc.source_exchange_rate) { + frm.set_value("target_exchange_rate", frm.doc.source_exchange_rate); + } frm.set_value("base_received_amount", frm.doc.base_paid_amount); } From 866c2959896a7a5075ce0fc8d0826cb49d69f4dd Mon Sep 17 00:00:00 2001 From: Saurabh Date: Tue, 15 Nov 2016 17:18:44 +0530 Subject: [PATCH 02/11] [fix] on jv cancel remove linkings from advance table of Sales/Purchase Invoice --- .../accounts/doctype/journal_entry/journal_entry.py | 13 +++++++++++-- erpnext/utilities/transaction_base.py | 9 +++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index 145ed81564..a30fec90b6 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -64,11 +64,20 @@ class JournalEntry(AccountsController): from erpnext.accounts.utils import unlink_ref_doc_from_payment_entries from erpnext.hr.doctype.salary_slip.salary_slip import unlink_ref_doc_from_salary_slip unlink_ref_doc_from_payment_entries(self.doctype, self.name) - unlink_ref_doc_from_salary_slip(self.name) + unlink_ref_doc_from_salary_slip(self.name) self.make_gl_entries(1) self.update_advance_paid() self.update_expense_claim() - + self.unlink_advance_entry_reference() + + def unlink_advance_entry_reference(self): + for d in self.get("accounts"): + if d.is_advance and d.reference_type in ("Sales Invoice", "Purchase Invoice"): + doc = frappe.get_doc(d.reference_type, d.reference_name) + doc.delink_advance_entries(self.name) + d.reference_type = '' + d.reference_name = '' + d.db_update() def validate_party(self): for d in self.get("accounts"): diff --git a/erpnext/utilities/transaction_base.py b/erpnext/utilities/transaction_base.py index 3cc79ef713..28d30efee7 100644 --- a/erpnext/utilities/transaction_base.py +++ b/erpnext/utilities/transaction_base.py @@ -125,6 +125,15 @@ class TransactionBase(StatusUpdater): ret = None return ret + + def delink_advance_entries(self, jv): + total_allocated_amount = 0 + for adv in self.advances: + if adv.reference_name == jv: + frappe.db.sql("""delete from `tab{0} Advance` + where name = %s""".format(self.doctype), adv.name) + total_allocated_amount += flt(adv.allocated_amount, adv.precision("allocated_amount")) + self.db_set("total_advance", total_allocated_amount) def delete_events(ref_type, ref_name): frappe.delete_doc("Event", frappe.db.sql_list("""select name from `tabEvent` From 8adbfa8a0995b09faea2cbd5f2af2c7f0d329bf3 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Wed, 16 Nov 2016 13:42:44 +0530 Subject: [PATCH 03/11] [test-case] test cases for delinking advance payments --- .../doctype/journal_entry/journal_entry.py | 2 +- .../purchase_invoice/test_purchase_invoice.py | 32 ++++++++++++++++++ .../sales_invoice/test_sales_invoice.py | 33 +++++++++++++++++++ erpnext/utilities/transaction_base.py | 9 +++-- 4 files changed, 73 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index a30fec90b6..28028351d2 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -69,7 +69,7 @@ class JournalEntry(AccountsController): self.update_advance_paid() self.update_expense_claim() self.unlink_advance_entry_reference() - + def unlink_advance_entry_reference(self): for d in self.get("accounts"): if d.is_advance and d.reference_type in ("Sales Invoice", "Purchase Invoice"): diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index b4b8444e77..e82d55edcd 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -437,6 +437,38 @@ class TestPurchaseInvoice(unittest.TestCase): self.assertEquals(frappe.db.get_value("Serial No", pi.get("items")[0].rejected_serial_no, "warehouse"), pi.get("items")[0].rejected_warehouse) + + def test_outstanding_amount_after_advance_jv_cancelation(self): + from erpnext.accounts.doctype.journal_entry.test_journal_entry \ + import test_records as jv_test_records + + jv = frappe.copy_doc(jv_test_records[1]) + jv.insert() + jv.submit() + + pi = frappe.copy_doc(test_records[0]) + pi.append("advances", { + "reference_type": "Journal Entry", + "reference_name": jv.name, + "reference_row": jv.get("accounts")[0].name, + "advance_amount": 400, + "allocated_amount": 300, + "remarks": jv.remark + }) + pi.insert() + pi.submit() + pi.load_from_db() + + #check outstanding after advance allocation + self.assertEqual(flt(pi.outstanding_amount), flt(pi.grand_total - pi.total_advance, pi.precision("outstanding_amount"))) + + #added to avoid Document has been modified exception + jv = frappe.get_doc("Journal Entry", jv.name) + jv.cancel() + + pi.load_from_db() + #check outstanding after advance cancellation + self.assertEqual(flt(pi.outstanding_amount), flt(pi.grand_total + pi.total_advance, pi.precision("outstanding_amount"))) def unlink_payment_on_cancel_of_invoice(enable=1): accounts_settings = frappe.get_doc("Accounts Settings") diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index 0011dfe736..12b90edd10 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -980,6 +980,39 @@ class TestSalesInvoice(unittest.TestCase): pe.submit() self.assertEquals(frappe.db.get_value('Customer', customer.name, 'status'), 'Active') + + def test_outstanding_amount_after_advance_jv_cancelation(self): + from erpnext.accounts.doctype.journal_entry.test_journal_entry \ + import test_records as jv_test_records + + jv = frappe.copy_doc(jv_test_records[0]) + jv.insert() + jv.submit() + + si = frappe.copy_doc(test_records[0]) + si.append("advances", { + "doctype": "Sales Invoice Advance", + "reference_type": "Journal Entry", + "reference_name": jv.name, + "reference_row": jv.get("accounts")[0].name, + "advance_amount": 400, + "allocated_amount": 300, + "remarks": jv.remark + }) + si.insert() + si.submit() + si.load_from_db() + + #check outstanding after advance allocation + self.assertEqual(flt(si.outstanding_amount), flt(si.grand_total - si.total_advance, si.precision("outstanding_amount"))) + + #added to avoid Document has been modified exception + jv = frappe.get_doc("Journal Entry", jv.name) + jv.cancel() + + si.load_from_db() + #check outstanding after advance cancellation + self.assertEqual(flt(si.outstanding_amount), flt(si.grand_total + si.total_advance, si.precision("outstanding_amount"))) def create_sales_invoice(**args): si = frappe.new_doc("Sales Invoice") diff --git a/erpnext/utilities/transaction_base.py b/erpnext/utilities/transaction_base.py index 28d30efee7..f85edfd0f4 100644 --- a/erpnext/utilities/transaction_base.py +++ b/erpnext/utilities/transaction_base.py @@ -129,11 +129,16 @@ class TransactionBase(StatusUpdater): def delink_advance_entries(self, jv): total_allocated_amount = 0 for adv in self.advances: + consider_for_total_advance = True if adv.reference_name == jv: frappe.db.sql("""delete from `tab{0} Advance` where name = %s""".format(self.doctype), adv.name) - total_allocated_amount += flt(adv.allocated_amount, adv.precision("allocated_amount")) - self.db_set("total_advance", total_allocated_amount) + consider_for_total_advance = False + + if consider_for_total_advance: + total_allocated_amount += flt(adv.allocated_amount, adv.precision("allocated_amount")) + + frappe.db.set_value(self.doctype, self.name, "total_advance", total_allocated_amount, update_modified=False) def delete_events(ref_type, ref_name): frappe.delete_doc("Event", frappe.db.sql_list("""select name from `tabEvent` From 98f499a43e728f189c3ce3686ae8d870fe90c56d Mon Sep 17 00:00:00 2001 From: Kanchan Chauhan Date: Wed, 16 Nov 2016 15:17:55 +0530 Subject: [PATCH 04/11] [Fix]Product thumbnail in Shopping Cart --- erpnext/templates/includes/order/order_macros.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/templates/includes/order/order_macros.html b/erpnext/templates/includes/order/order_macros.html index 70a1fd8b4c..e77b8b4801 100644 --- a/erpnext/templates/includes/order/order_macros.html +++ b/erpnext/templates/includes/order/order_macros.html @@ -4,7 +4,7 @@
- {{ product_image_square(d.image) }} + {{ product_image_square(d.thumbnail or d.image) }}
@@ -18,7 +18,7 @@
- {{ product_image_square(d.image) }} + {{ product_image_square(d.thumbnail or d.image) }}
From 7652b857c8b7bdb88e648bc2fdcb8f1b5d0e0986 Mon Sep 17 00:00:00 2001 From: Kanchan Chauhan Date: Wed, 16 Nov 2016 15:29:01 +0530 Subject: [PATCH 05/11] [Fix] Filters to get employee in Payroll --- erpnext/controllers/queries.py | 4 +++- .../doctype/process_payroll/process_payroll.py | 6 +++--- .../salary_structure/salary_structure.js | 18 +++++++++--------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py index 6da496ba17..98390ff2d2 100644 --- a/erpnext/controllers/queries.py +++ b/erpnext/controllers/queries.py @@ -32,12 +32,13 @@ def get_filters_cond(doctype, filters, conditions): # searches for active employees def employee_query(doctype, txt, searchfield, start, page_len, filters): + conditions = [] return frappe.db.sql("""select name, employee_name from `tabEmployee` where status = 'Active' and docstatus < 2 and ({key} like %(txt)s or employee_name like %(txt)s) - {mcond} + {fcond} {mcond} order by if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999), if(locate(%(_txt)s, employee_name), locate(%(_txt)s, employee_name), 99999), @@ -45,6 +46,7 @@ def employee_query(doctype, txt, searchfield, start, page_len, filters): name, employee_name limit %(start)s, %(page_len)s""".format(**{ 'key': searchfield, + 'fcond': get_filters_cond(doctype, filters, conditions), 'mcond': get_match_cond(doctype) }), { 'txt': "%%%s%%" % txt, diff --git a/erpnext/hr/doctype/process_payroll/process_payroll.py b/erpnext/hr/doctype/process_payroll/process_payroll.py index 3554669cca..2077982f13 100644 --- a/erpnext/hr/doctype/process_payroll/process_payroll.py +++ b/erpnext/hr/doctype/process_payroll/process_payroll.py @@ -22,7 +22,7 @@ class ProcessPayroll(Document): sal_struct = frappe.db.sql(""" select name from `tabSalary Structure` - where docstatus != 2 and company = %(company)s and + where docstatus != 2 and is_active = 'Yes' and company = %(company)s and ifnull(salary_slip_based_on_timesheet,0) = %(salary_slip_based_on_timesheet)s""", {"company": self.company, "salary_slip_based_on_timesheet":self.salary_slip_based_on_timesheet}) @@ -51,8 +51,8 @@ class ProcessPayroll(Document): def get_joining_releiving_condition(self): cond = """ - and ifnull(t1.date_of_joining, '0000-00-00') <= '%(from_date)s' - and ifnull(t1.relieving_date, '2199-12-31') >= '%(to_date)s' + and ifnull(t1.date_of_joining, '0000-00-00') <= '%(to_date)s' + and ifnull(t1.relieving_date, '2199-12-31') >= '%(from_date)s' """ % {"from_date": self.from_date, "to_date": self.to_date} return cond diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.js b/erpnext/hr/doctype/salary_structure/salary_structure.js index 334e8a513d..c5df2e6518 100755 --- a/erpnext/hr/doctype/salary_structure/salary_structure.js +++ b/erpnext/hr/doctype/salary_structure/salary_structure.js @@ -28,7 +28,15 @@ frappe.ui.form.on('Salary Structure', { type: "deduction" } } - }) + }); + frm.set_query("employee", "employees", function(doc) { + return { + query: "erpnext.controllers.queries.employee_query", + filters: { + company: doc.company + } + } + }); }, refresh: function(frm) { @@ -182,11 +190,3 @@ frappe.ui.form.on('Salary Detail', { calculate_totals(frm.doc); } }) - -frappe.ui.form.on('Salary Structure Employee', { - onload: function(frm) { - frm.set_query("employee","employees", function(doc,cdt,cdn) { - return{ query: "erpnext.controllers.queries.employee_query" } - }) - } -}); From e9747a8a6e809dae4e61cae8f5cef69c7984b577 Mon Sep 17 00:00:00 2001 From: mbauskar Date: Wed, 16 Nov 2016 17:19:47 +0530 Subject: [PATCH 06/11] [minor] fixes in validate selling price --- erpnext/controllers/selling_controller.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py index 68e91550a8..60cd68c635 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -164,14 +164,18 @@ class SellingController(StockController): frappe.throw(_("Maxiumm discount for Item {0} is {1}%").format(d.item_code, discount)) def validate_selling_price(self): + def throw_message(item_name, rate, ref_rate_field): + frappe.throw(_("""Selling price for item {0} is lower than its {1}. Selling price should be atleast {2}""") + .format(item_name, ref_rate_field, rate)) + if not frappe.db.get_single_value("Selling Settings", "validate_selling_price"): return for it in self.get("items"): - last_purchase_rate, is_stock_item = frappe.db.get_value("Item", it.name, ["last_purchase_rate", "is_stock_item"]) + last_purchase_rate, is_stock_item = frappe.db.get_value("Item", it.item_code, ["last_purchase_rate", "is_stock_item"]) if flt(it.base_rate) < flt(last_purchase_rate): - throw(it.name, last_purchase_rate, "last purchase rate") + throw_message(it.item_name, last_purchase_rate, "last purchase rate") last_valuation_rate = frappe.db.sql(""" SELECT valuation_rate FROM `tabStock Ledger Entry` WHERE item_code = %s @@ -182,9 +186,6 @@ class SellingController(StockController): if is_stock_item and flt(it.base_rate) < flt(last_valuation_rate): throw_message(it.name, last_valuation_rate, "valuation rate") - def throw_message(item_name, rate, ref_rate_field): - frappe.throw(_("""Selling price for item {0} is lower than its {1}. Selling price should be atleast {2}""") - .format(item_name, ref_rate_field, rate)) def get_item_list(self): il = [] From aa6805891092987b15383fec55be6f7bedae7615 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 16 Nov 2016 17:41:08 +0530 Subject: [PATCH 07/11] Updated modified_datetime in production planning tool --- .../production_planning_tool/production_planning_tool.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.json b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.json index 8d844cda7e..d9f3082d04 100644 --- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.json +++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.json @@ -816,7 +816,7 @@ "issingle": 1, "istable": 0, "max_attachments": 0, - "modified": "2016-08-17 05:35:34.331954", + "modified": "2016-11-16 05:35:34.331954", "modified_by": "Administrator", "module": "Manufacturing", "name": "Production Planning Tool", From 7fc05d643268a368ba32d2948a1b03705aa756fb Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 17 Nov 2016 12:16:52 +0530 Subject: [PATCH 08/11] Update update_missing_salary_component_type.py --- erpnext/patches/v7_1/update_missing_salary_component_type.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/patches/v7_1/update_missing_salary_component_type.py b/erpnext/patches/v7_1/update_missing_salary_component_type.py index f0e3f6a4ad..25624f56ea 100644 --- a/erpnext/patches/v7_1/update_missing_salary_component_type.py +++ b/erpnext/patches/v7_1/update_missing_salary_component_type.py @@ -9,6 +9,8 @@ earnings or deductions in existing salary slips ''' def execute(): + frappe.reload_doc("accounts", "doctype", "salary_component_account") + for s in frappe.db.sql('''select name, type, salary_component_abbr from `tabSalary Component` where ifnull(type, "")="" or ifnull(salary_component_abbr, "") = ""''', as_dict=1): @@ -43,4 +45,4 @@ def execute(): component.salary_component_abbr = abbr - component.save() \ No newline at end of file + component.save() From 1d210968de71819d4ad7da8a69ef4d3e4d60ff57 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Thu, 17 Nov 2016 13:40:43 +0530 Subject: [PATCH 09/11] [fix] on advance payment entry cancellation delink invoice and pyament entry references --- .../doctype/payment_entry/payment_entry.py | 9 +++- .../purchase_invoice/test_purchase_invoice.py | 51 ++++++++++++++++++- .../sales_invoice/test_sales_invoice.py | 47 +++++++++++++++++ erpnext/utilities/transaction_base.py | 4 +- 4 files changed, 106 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 7b9bf16bff..d4f8edbb6f 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -60,7 +60,14 @@ class PaymentEntry(AccountsController): self.setup_party_account_field() self.make_gl_entries(cancel=1) self.update_advance_paid() - + self.delink_advance_entry_references() + + def delink_advance_entry_references(self): + for reference in self.references: + if reference.reference_doctype in ("Sales Invoice", "Purchase Invoice"): + doc = frappe.get_doc(reference.reference_doctype, reference.reference_name) + doc.delink_advance_entries(self.name) + def set_missing_values(self): if self.payment_type == "Internal Transfer": for field in ("party", "party_balance", "total_allocated_amount", diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index e82d55edcd..d8c9b04800 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -460,7 +460,7 @@ class TestPurchaseInvoice(unittest.TestCase): pi.load_from_db() #check outstanding after advance allocation - self.assertEqual(flt(pi.outstanding_amount), flt(pi.grand_total - pi.total_advance, pi.precision("outstanding_amount"))) + self.assertEqual(flt(pi.outstanding_amount), flt(pi.grand_total - pi.total_advance)) #added to avoid Document has been modified exception jv = frappe.get_doc("Journal Entry", jv.name) @@ -468,7 +468,54 @@ class TestPurchaseInvoice(unittest.TestCase): pi.load_from_db() #check outstanding after advance cancellation - self.assertEqual(flt(pi.outstanding_amount), flt(pi.grand_total + pi.total_advance, pi.precision("outstanding_amount"))) + self.assertEqual(flt(pi.outstanding_amount), flt(pi.grand_total + pi.total_advance)) + + def test_outstanding_amount_after_advance_payment_entry_cancelation(self): + pe = frappe.get_doc({ + "doctype": "Payment Entry", + "payment_type": "Pay", + "party_type": "Supplier", + "party": "_Test Supplier", + "company": "_Test Company", + "paid_from_account_currency": "INR", + "paid_to_account_currency": "INR", + "source_exchange_rate": 1, + "target_exchange_rate": 1, + "reference_no": "1", + "reference_date": nowdate(), + "received_amount": 300, + "paid_amount": 300, + "paid_from": "_Test Cash - _TC", + "paid_to": "_Test Payable - _TC" + }) + pe.insert() + pe.submit() + + pi = frappe.copy_doc(test_records[0]) + pi.is_pos = 0 + pi.append("advances", { + "doctype": "Purchase Invoice Advance", + "reference_type": "Payment Entry", + "reference_name": pe.name, + "advance_amount": 300, + "allocated_amount": 300, + "remarks": pe.remarks + }) + pi.insert() + pi.submit() + + pi.load_from_db() + + #check outstanding after advance allocation + self.assertEqual(flt(pi.outstanding_amount), flt(pi.grand_total - pi.total_advance)) + + #added to avoid Document has been modified exception + pe = frappe.get_doc("Payment Entry", pe.name) + pe.cancel() + + pi.load_from_db() + #check outstanding after advance cancellation + self.assertEqual(flt(pi.outstanding_amount), flt(pi.grand_total + pi.total_advance)) def unlink_payment_on_cancel_of_invoice(enable=1): accounts_settings = frappe.get_doc("Accounts Settings") diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index 12b90edd10..511eeaab9f 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -1013,6 +1013,53 @@ class TestSalesInvoice(unittest.TestCase): si.load_from_db() #check outstanding after advance cancellation self.assertEqual(flt(si.outstanding_amount), flt(si.grand_total + si.total_advance, si.precision("outstanding_amount"))) + + def test_outstanding_amount_after_advance_payment_entry_cancelation(self): + pe = frappe.get_doc({ + "doctype": "Payment Entry", + "payment_type": "Receive", + "party_type": "Customer", + "party": "_Test Customer", + "company": "_Test Company", + "paid_from_account_currency": "INR", + "paid_to_account_currency": "INR", + "source_exchange_rate": 1, + "target_exchange_rate": 1, + "reference_no": "1", + "reference_date": nowdate(), + "received_amount": 300, + "paid_amount": 300, + "paid_from": "_Test Receivable - _TC", + "paid_to": "_Test Cash - _TC" + }) + pe.insert() + pe.submit() + + si = frappe.copy_doc(test_records[0]) + si.is_pos = 0 + si.append("advances", { + "doctype": "Sales Invoice Advance", + "reference_type": "Payment Entry", + "reference_name": pe.name, + "advance_amount": 300, + "allocated_amount": 300, + "remarks": pe.remarks + }) + si.insert() + si.submit() + + si.load_from_db() + + #check outstanding after advance allocation + self.assertEqual(flt(si.outstanding_amount), flt(si.grand_total - si.total_advance, si.precision("outstanding_amount"))) + + #added to avoid Document has been modified exception + pe = frappe.get_doc("Payment Entry", pe.name) + pe.cancel() + + si.load_from_db() + #check outstanding after advance cancellation + self.assertEqual(flt(si.outstanding_amount), flt(si.grand_total + si.total_advance, si.precision("outstanding_amount"))) def create_sales_invoice(**args): si = frappe.new_doc("Sales Invoice") diff --git a/erpnext/utilities/transaction_base.py b/erpnext/utilities/transaction_base.py index f85edfd0f4..051334ca86 100644 --- a/erpnext/utilities/transaction_base.py +++ b/erpnext/utilities/transaction_base.py @@ -126,11 +126,11 @@ class TransactionBase(StatusUpdater): return ret - def delink_advance_entries(self, jv): + def delink_advance_entries(self, linked_doc_name): total_allocated_amount = 0 for adv in self.advances: consider_for_total_advance = True - if adv.reference_name == jv: + if adv.reference_name == linked_doc_name: frappe.db.sql("""delete from `tab{0} Advance` where name = %s""".format(self.doctype), adv.name) consider_for_total_advance = False From 2b63e14089420be39f69e19645519baf559991df Mon Sep 17 00:00:00 2001 From: robert schouten Date: Thu, 17 Nov 2016 17:53:38 +0800 Subject: [PATCH 10/11] dh drop guest from student attendance so disabling acedemic user disables all school doctypes (#6974) --- .../student_applicant/student_applicant.json | 23 +------------------ 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/erpnext/schools/doctype/student_applicant/student_applicant.json b/erpnext/schools/doctype/student_applicant/student_applicant.json index e60a54ec37..5c6e2769e4 100644 --- a/erpnext/schools/doctype/student_applicant/student_applicant.json +++ b/erpnext/schools/doctype/student_applicant/student_applicant.json @@ -920,7 +920,7 @@ "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2016-10-10 06:19:19.319038", + "modified": "2016-11-17 10:26:13.225135", "modified_by": "Administrator", "module": "Schools", "name": "Student Applicant", @@ -947,27 +947,6 @@ "share": 1, "submit": 1, "write": 1 - }, - { - "amend": 0, - "apply_user_permissions": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "email": 1, - "export": 0, - "if_owner": 1, - "import": 0, - "is_custom": 0, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 0, - "role": "Guest", - "set_user_permissions": 0, - "share": 0, - "submit": 0, - "write": 0 } ], "quick_entry": 1, From f2b7ec919add1892847e38d7b824a225678c05fd Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 17 Nov 2016 16:24:07 +0600 Subject: [PATCH 11/11] bumped to version 7.1.14 --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index d0fec441e7..fab544fde1 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals import frappe -__version__ = '7.1.13' +__version__ = '7.1.14' def get_default_company(user=None): '''Get default company for user'''