Merge pull request #7442 from nabinhait/hotfix

Fix for Budget against Project
This commit is contained in:
Nabin Hait 2017-01-11 10:30:44 +05:30 committed by GitHub
commit ffa5ffe607
2 changed files with 32 additions and 29 deletions

View File

@ -63,7 +63,7 @@ def validate_expense_against_budget(args):
and frappe.db.get_value("Account", {"name": args.account, "root_type": "Expense"}): and frappe.db.get_value("Account", {"name": args.account, "root_type": "Expense"}):
if args.project: 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" args.budget_against_field = "Project"
elif args.cost_center: elif args.cost_center:
@ -88,12 +88,13 @@ def validate_expense_against_budget(args):
""".format(condition=condition, """.format(condition=condition,
budget_against_field=frappe.scrub(args.get("budget_against_field"))), budget_against_field=frappe.scrub(args.get("budget_against_field"))),
(args.fiscal_year, args.account), as_dict=True) (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): def validate_budget_records(args, budget_records):
for budget in budget_records: for budget in budget_records:
if budget.budget_amount: if flt(budget.budget_amount):
yearly_action = budget.action_if_annual_budget_exceeded yearly_action = budget.action_if_annual_budget_exceeded
monthly_action = budget.action_if_accumulated_monthly_budget_exceeded monthly_action = budget.action_if_accumulated_monthly_budget_exceeded

View File

@ -651,32 +651,34 @@ class SalesInvoice(SellingController):
def make_pos_gl_entries(self, gl_entries): def make_pos_gl_entries(self, gl_entries):
if cint(self.is_pos): if cint(self.is_pos):
for payment_mode in self.payments: for payment_mode in self.payments:
# POS, make payment entries if payment_mode.amount:
gl_entries.append( # POS, make payment entries
self.get_gl_dict({ gl_entries.append(
"account": self.debit_to, self.get_gl_dict({
"party_type": "Customer", "account": self.debit_to,
"party": self.customer, "party_type": "Customer",
"against": payment_mode.account, "party": self.customer,
"credit": payment_mode.base_amount, "against": payment_mode.account,
"credit_in_account_currency": payment_mode.base_amount \ "credit": payment_mode.base_amount,
if self.party_account_currency==self.company_currency \ "credit_in_account_currency": payment_mode.base_amount \
else payment_mode.amount, if self.party_account_currency==self.company_currency \
"against_voucher": self.return_against if cint(self.is_return) else self.name, else payment_mode.amount,
"against_voucher_type": self.doctype, "against_voucher": self.return_against if cint(self.is_return) else self.name,
}, self.party_account_currency) "against_voucher_type": self.doctype,
) }, self.party_account_currency)
)
payment_mode_account_currency = get_account_currency(payment_mode.account) payment_mode_account_currency = get_account_currency(payment_mode.account)
gl_entries.append( gl_entries.append(
self.get_gl_dict({ self.get_gl_dict({
"account": payment_mode.account, "account": payment_mode.account,
"against": self.customer, "against": self.customer,
"debit": payment_mode.base_amount, "debit": payment_mode.base_amount,
"debit_in_account_currency": payment_mode.base_amount \ "debit_in_account_currency": payment_mode.base_amount \
if payment_mode_account_currency==self.company_currency else payment_mode.amount if payment_mode_account_currency==self.company_currency \
}, payment_mode_account_currency) else payment_mode.amount
) }, payment_mode_account_currency)
)
def make_gle_for_change_amount(self, gl_entries): def make_gle_for_change_amount(self, gl_entries):
if cint(self.is_pos) and self.change_amount: if cint(self.is_pos) and self.change_amount: