Fixed conflict
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index cf8a11c..bb5531f 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -291,7 +291,7 @@
self.precision("tax_amount", tax))
def adjust_discount_amount_loss(self, tax):
- discount_amount_loss = self.grand_total - flt(self.discount_amount) - tax.total
+ discount_amount_loss = self.grand_total - flt(self.base_discount_amount) - tax.total
tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount +
discount_amount_loss, self.precision("tax_amount", tax))
tax.total = flt(tax.total + discount_amount_loss, self.precision("total", tax))
@@ -475,7 +475,7 @@
max_allowed_amt = flt(ref_amt * (100 + tolerance) / 100)
if total_billed_amt - max_allowed_amt > 0.01:
- frappe.throw(_("Cannot overbill for Item {0} in row {0} more than {1}. To allow overbilling, please set in Stock Settings").format(item.item_code, item.idx, max_allowed_amt))
+ frappe.throw(_("Cannot overbill for Item {0} in row {1} more than {2}. To allow overbilling, please set in Stock Settings").format(item.item_code, item.idx, max_allowed_amt))
def get_company_default(self, fieldname):
from erpnext.accounts.utils import get_company_default
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index c3f449c..82da90e 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -115,7 +115,8 @@
def calculate_totals(self):
self.grand_total = flt(self.get("taxes")[-1].total if self.get("taxes") else self.net_total)
- self.grand_total_import = flt(self.grand_total / self.conversion_rate)
+ self.grand_total_import = flt(self.grand_total / self.conversion_rate) \
+ if self.get("taxes") else self.net_total_import
self.total_tax = flt(self.grand_total - self.net_total, self.precision("total_tax"))
diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py
index 937e026..328894c 100644
--- a/erpnext/controllers/selling_controller.py
+++ b/erpnext/controllers/selling_controller.py
@@ -232,16 +232,20 @@
def apply_discount_amount(self):
if self.discount_amount:
+ self.base_discount_amount = flt(self.discount_amount * self.conversion_rate, self.precision("base_discount_amount"))
+
grand_total_for_discount_amount = self.get_grand_total_for_discount_amount()
if grand_total_for_discount_amount:
# calculate item amount after Discount Amount
for item in self.get("items"):
- distributed_amount = flt(self.discount_amount) * item.base_amount / grand_total_for_discount_amount
+ distributed_amount = flt(self.base_discount_amount) * item.base_amount / grand_total_for_discount_amount
item.base_amount = flt(item.base_amount - distributed_amount, self.precision("base_amount", item))
self.discount_amount_applied = True
self._calculate_taxes_and_totals()
+ else:
+ self.base_discount_amount = 0
def get_grand_total_for_discount_amount(self):
actual_taxes_dict = {}
diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py
index 4b4be79..5bdd50b 100644
--- a/erpnext/controllers/stock_controller.py
+++ b/erpnext/controllers/stock_controller.py
@@ -167,7 +167,7 @@
else:
is_expense_account = frappe.db.get_value("Account",
item.get("expense_account"), "report_type")=="Profit and Loss"
- if self.doctype not in ("Purchase Receipt", "Stock Reconciliation") and not is_expense_account:
+ if self.doctype not in ("Purchase Receipt", "Stock Reconciliation", "Stock Entry") and not is_expense_account:
frappe.throw(_("Expense / Difference account ({0}) must be a 'Profit or Loss' account")
.format(item.get("expense_account")))
if is_expense_account and not item.get("cost_center"):
@@ -245,7 +245,7 @@
for entry in expected_gle:
for e in existing_gle:
if entry.account==e.account and entry.against_account==e.against_account \
- and entry.cost_center==e.cost_center \
+ and (not entry.cost_center or not e.cost_center or entry.cost_center==e.cost_center) \
and (entry.debit != e.debit or entry.credit != e.credit):
matched = False
break