diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 9534f514c1f..762fa994632 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -779,7 +779,7 @@ def get_paid_amount(dt, dn, party_type, party, account, due_date): dr_or_cr = "credit_in_account_currency - debit_in_account_currency" else: dr_or_cr = "debit_in_account_currency - credit_in_account_currency" - + paid_amount = frappe.db.sql(""" select ifnull(sum({dr_or_cr}), 0) as paid_amount from `tabGL Entry` diff --git a/erpnext/accounts/doctype/payment_schedule/payment_schedule.py b/erpnext/accounts/doctype/payment_schedule/payment_schedule.py index 75bacc64067..41740170f03 100644 --- a/erpnext/accounts/doctype/payment_schedule/payment_schedule.py +++ b/erpnext/accounts/doctype/payment_schedule/payment_schedule.py @@ -3,8 +3,8 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe from frappe.model.document import Document + class PaymentSchedule(Document): pass diff --git a/erpnext/accounts/doctype/payment_term/payment_term.js b/erpnext/accounts/doctype/payment_term/payment_term.js index 564a2a6d3be..054c2d11917 100644 --- a/erpnext/accounts/doctype/payment_term/payment_term.js +++ b/erpnext/accounts/doctype/payment_term/payment_term.js @@ -1,8 +1,2 @@ // Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt - -frappe.ui.form.on('Payment Term', { - refresh: function(frm) { - - } -}); diff --git a/erpnext/accounts/doctype/payment_term/payment_term.py b/erpnext/accounts/doctype/payment_term/payment_term.py index 93a7529a113..5d4df053fb2 100644 --- a/erpnext/accounts/doctype/payment_term/payment_term.py +++ b/erpnext/accounts/doctype/payment_term/payment_term.py @@ -3,8 +3,8 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe from frappe.model.document import Document + class PaymentTerm(Document): pass diff --git a/erpnext/accounts/doctype/payment_term/test_payment_term.py b/erpnext/accounts/doctype/payment_term/test_payment_term.py index c4d5d375942..d9baa5907b9 100644 --- a/erpnext/accounts/doctype/payment_term/test_payment_term.py +++ b/erpnext/accounts/doctype/payment_term/test_payment_term.py @@ -2,9 +2,8 @@ # Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt from __future__ import unicode_literals - -import frappe import unittest + class TestPaymentTerm(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/payment_terms_template/payment_terms_template.py b/erpnext/accounts/doctype/payment_terms_template/payment_terms_template.py index 3300a1122c8..d2344d6c77b 100644 --- a/erpnext/accounts/doctype/payment_terms_template/payment_terms_template.py +++ b/erpnext/accounts/doctype/payment_terms_template/payment_terms_template.py @@ -3,8 +3,8 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe from frappe.model.document import Document + class PaymentTermsTemplate(Document): pass diff --git a/erpnext/accounts/doctype/payment_terms_template/test_payment_terms_template.py b/erpnext/accounts/doctype/payment_terms_template/test_payment_terms_template.py index 33d256c58ac..ec370668a0e 100644 --- a/erpnext/accounts/doctype/payment_terms_template/test_payment_terms_template.py +++ b/erpnext/accounts/doctype/payment_terms_template/test_payment_terms_template.py @@ -2,9 +2,8 @@ # Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors # See license.txt from __future__ import unicode_literals - -import frappe import unittest + class TestPaymentTermsTemplate(unittest.TestCase): pass diff --git a/erpnext/accounts/doctype/payment_terms_template_detail/payment_terms_template_detail.py b/erpnext/accounts/doctype/payment_terms_template_detail/payment_terms_template_detail.py index 1242cc1a08a..54c0fda0119 100644 --- a/erpnext/accounts/doctype/payment_terms_template_detail/payment_terms_template_detail.py +++ b/erpnext/accounts/doctype/payment_terms_template_detail/payment_terms_template_detail.py @@ -3,8 +3,8 @@ # For license information, please see license.txt from __future__ import unicode_literals -import frappe from frappe.model.document import Document + class PaymentTermsTemplateDetail(Document): pass diff --git a/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py index 82a3d653abf..9ec69c32c71 100644 --- a/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py @@ -252,6 +252,7 @@ class TestPricingRule(unittest.TestCase): self.assertEquals(so.items[0].rate, 100) def test_pricing_rule_with_margin_and_discount(self): + frappe.delete_doc_if_exists('Pricing Rule', '_Test Pricing Rule') make_pricing_rule(selling=1, margin_type="Percentage", margin_rate_or_amount=10) si = create_sales_invoice(do_not_save=True) si.items[0].price_list_rate = 1000 diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index bc3531778d1..8c57cab83bf 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe, erpnext import frappe.defaults -from frappe.utils import cint, flt, getdate +from frappe.utils import cint, flt from frappe import _, msgprint, throw from erpnext.accounts.party import get_party_account, get_due_date from erpnext.controllers.stock_controller import update_gl_entries_after diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 38258288a71..00d52d1a1cc 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -616,7 +616,8 @@ def get_outstanding_invoices(party_type, party, account, condition=None): }, as_dict=True) for d in invoice_list: - print d.voucher_no, d.invoice_amount, d.payment_amount + due_date = d.due_date or (frappe.db.get_value(d.voucher_type, d.voucher_no, + "posting_date" if party_type=="Employee" else "due_date")) outstanding_invoices.append(frappe._dict({ 'voucher_no': d.voucher_no, 'voucher_type': d.voucher_type, @@ -624,8 +625,7 @@ def get_outstanding_invoices(party_type, party, account, condition=None): 'invoice_amount': flt(d.invoice_amount), 'payment_amount': flt(d.payment_amount), 'outstanding_amount': flt(d.invoice_amount - d.payment_amount, precision), - 'due_date': d.due_date or (frappe.db.get_value(d.voucher_type, d.voucher_no, - "posting_date" if party_type=="Employee" else "due_date")), + 'due_date': due_date })) outstanding_invoices = sorted(outstanding_invoices, key=lambda k: k['due_date'] or getdate(nowdate())) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index c5390ffe47e..25ec8637f53 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -643,7 +643,7 @@ class AccountsController(TransactionBase): total += flt(d.payment_amount) if total != self.grand_total: - frappe.throw(_("Total Payment Amount in Payment Schdule must be equal to Grand Total")) + frappe.throw(_("Total Payment Amount in Payment Schedule must be equal to Grand Total")) @frappe.whitelist() @@ -824,7 +824,7 @@ def get_payment_terms(terms_template, posting_date=None, grand_total=None): terms_doc = frappe.get_doc("Payment Terms Template", terms_template) schedule = [] - for i, d in enumerate(terms_doc.get("terms")): + for d in terms_doc.get("terms"): term_details = get_payment_term_details(d, posting_date, grand_total) schedule.append(term_details)