diff --git a/erpnext/accounts/doctype/budget/budget.py b/erpnext/accounts/doctype/budget/budget.py index 5fc4fbf319..15d6f106df 100644 --- a/erpnext/accounts/doctype/budget/budget.py +++ b/erpnext/accounts/doctype/budget/budget.py @@ -63,7 +63,7 @@ def validate_expense_against_budget(args): and frappe.db.get_value("Account", {"name": args.account, "root_type": "Expense"}): if args.project: - condition = "and exists(select name from `tabProject` where name=b.project)" + condition = "and b.project='%s'" % frappe.db.escape(args.project) args.budget_against_field = "Project" elif args.cost_center: @@ -88,12 +88,13 @@ def validate_expense_against_budget(args): """.format(condition=condition, budget_against_field=frappe.scrub(args.get("budget_against_field"))), (args.fiscal_year, args.account), as_dict=True) - - validate_budget_records(args, budget_records) + + if budget_records: + validate_budget_records(args, budget_records) def validate_budget_records(args, budget_records): for budget in budget_records: - if budget.budget_amount: + if flt(budget.budget_amount): yearly_action = budget.action_if_annual_budget_exceeded monthly_action = budget.action_if_accumulated_monthly_budget_exceeded diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index db6d594580..c5aa7ea893 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -651,32 +651,34 @@ class SalesInvoice(SellingController): def make_pos_gl_entries(self, gl_entries): if cint(self.is_pos): for payment_mode in self.payments: - # POS, make payment entries - gl_entries.append( - self.get_gl_dict({ - "account": self.debit_to, - "party_type": "Customer", - "party": self.customer, - "against": payment_mode.account, - "credit": payment_mode.base_amount, - "credit_in_account_currency": payment_mode.base_amount \ - if self.party_account_currency==self.company_currency \ - else payment_mode.amount, - "against_voucher": self.return_against if cint(self.is_return) else self.name, - "against_voucher_type": self.doctype, - }, self.party_account_currency) - ) + if payment_mode.amount: + # POS, make payment entries + gl_entries.append( + self.get_gl_dict({ + "account": self.debit_to, + "party_type": "Customer", + "party": self.customer, + "against": payment_mode.account, + "credit": payment_mode.base_amount, + "credit_in_account_currency": payment_mode.base_amount \ + if self.party_account_currency==self.company_currency \ + else payment_mode.amount, + "against_voucher": self.return_against if cint(self.is_return) else self.name, + "against_voucher_type": self.doctype, + }, self.party_account_currency) + ) - payment_mode_account_currency = get_account_currency(payment_mode.account) - gl_entries.append( - self.get_gl_dict({ - "account": payment_mode.account, - "against": self.customer, - "debit": payment_mode.base_amount, - "debit_in_account_currency": payment_mode.base_amount \ - if payment_mode_account_currency==self.company_currency else payment_mode.amount - }, payment_mode_account_currency) - ) + payment_mode_account_currency = get_account_currency(payment_mode.account) + gl_entries.append( + self.get_gl_dict({ + "account": payment_mode.account, + "against": self.customer, + "debit": payment_mode.base_amount, + "debit_in_account_currency": payment_mode.base_amount \ + if payment_mode_account_currency==self.company_currency \ + else payment_mode.amount + }, payment_mode_account_currency) + ) def make_gle_for_change_amount(self, gl_entries): if cint(self.is_pos) and self.change_amount: