Merge branch 'rebrand-ui' of https://github.com/frappe/erpnext into rebrand-ui
diff --git a/erpnext/manufacturing/doctype/work_order/test_work_order.py b/erpnext/manufacturing/doctype/work_order/test_work_order.py
index a77bd15..e562d6c 100644
--- a/erpnext/manufacturing/doctype/work_order/test_work_order.py
+++ b/erpnext/manufacturing/doctype/work_order/test_work_order.py
@@ -550,6 +550,48 @@
frappe.db.set_value("Manufacturing Settings", None, "material_consumption", 0)
+ def test_extra_material_transfer(self):
+ frappe.db.set_value("Manufacturing Settings", None, "material_consumption", 0)
+ frappe.db.set_value("Manufacturing Settings", None, "backflush_raw_materials_based_on",
+ "Material Transferred for Manufacture")
+
+ wo_order = make_wo_order_test_record(planned_start_date=now(), qty=4)
+
+ ste_cancel_list = []
+ ste1 = test_stock_entry.make_stock_entry(item_code="_Test Item",
+ target="_Test Warehouse - _TC", qty=20, basic_rate=5000.0)
+ ste2 = test_stock_entry.make_stock_entry(item_code="_Test Item Home Desktop 100",
+ target="_Test Warehouse - _TC", qty=20, basic_rate=1000.0)
+
+ ste_cancel_list.extend([ste1, ste2])
+
+ itemwise_qty = {}
+ s = frappe.get_doc(make_stock_entry(wo_order.name, "Material Transfer for Manufacture", 4))
+ for row in s.items:
+ row.qty = row.qty + 2
+ itemwise_qty.setdefault(row.item_code, row.qty)
+
+ s.submit()
+ ste_cancel_list.append(s)
+
+ ste3 = frappe.get_doc(make_stock_entry(wo_order.name, "Manufacture", 2))
+ for ste_row in ste3.items:
+ if itemwise_qty.get(ste_row.item_code) and ste_row.s_warehouse:
+ self.assertEquals(ste_row.qty, itemwise_qty.get(ste_row.item_code) / 2)
+
+ ste3.submit()
+ ste_cancel_list.append(ste3)
+
+ ste2 = frappe.get_doc(make_stock_entry(wo_order.name, "Manufacture", 2))
+ for ste_row in ste2.items:
+ if itemwise_qty.get(ste_row.item_code) and ste_row.s_warehouse:
+ self.assertEquals(ste_row.qty, itemwise_qty.get(ste_row.item_code) / 2)
+
+ for ste_doc in ste_cancel_list:
+ ste_doc.cancel()
+
+ frappe.db.set_value("Manufacturing Settings", None, "backflush_raw_materials_based_on", "BOM")
+
def get_scrap_item_details(bom_no):
scrap_items = {}
for item in frappe.db.sql("""select item_code, stock_qty from `tabBOM Scrap Item`
diff --git a/erpnext/regional/india/e_invoice/utils.py b/erpnext/regional/india/e_invoice/utils.py
index 2366fcb..c8e7e14 100644
--- a/erpnext/regional/india/e_invoice/utils.py
+++ b/erpnext/regional/india/e_invoice/utils.py
@@ -161,7 +161,7 @@
item.description = d.item_name.replace('"', '\\"')
item.qty = abs(item.qty)
- item.discount_amount = abs(item.discount_amount * item.qty)
+ item.discount_amount = 0
item.unit_rate = abs(item.base_net_amount / item.qty)
item.gross_amount = abs(item.base_net_amount)
item.taxable_value = abs(item.base_net_amount)
@@ -221,11 +221,12 @@
if invoice.apply_discount_on == 'Net Total' and invoice.discount_amount:
invoice_value_details.base_total = abs(invoice.base_total)
+ invoice_value_details.invoice_discount_amt = invoice.base_discount_amount
else:
invoice_value_details.base_total = abs(invoice.base_net_total)
+ # since tax already considers discount amount
+ invoice_value_details.invoice_discount_amt = 0
- # since tax already considers discount amount
- invoice_value_details.invoice_discount_amt = 0 # invoice.base_discount_amount
invoice_value_details.round_off = invoice.base_rounding_adjustment
invoice_value_details.base_grand_total = abs(invoice.base_rounded_total) or abs(invoice.base_grand_total)
invoice_value_details.grand_total = abs(invoice.rounded_total) or abs(invoice.grand_total)
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index d623d5c..d77b70f 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -1200,7 +1200,10 @@
else:
qty = (req_qty_each * flt(self.fg_completed_qty)) - remaining_qty
else:
- qty = req_qty_each * flt(self.fg_completed_qty)
+ if self.flags.backflush_based_on == "Material Transferred for Manufacture":
+ qty = (item.qty/trans_qty) * flt(self.fg_completed_qty)
+ else:
+ qty = req_qty_each * flt(self.fg_completed_qty)
elif backflushed_materials.get(item.item_code):
for d in backflushed_materials.get(item.item_code):
@@ -1208,7 +1211,8 @@
if (qty > req_qty):
qty = (qty/trans_qty) * flt(self.fg_completed_qty)
- if consumed_qty:
+ if consumed_qty and frappe.db.get_single_value("Manufacturing Settings",
+ "material_consumption"):
qty -= consumed_qty
if cint(frappe.get_cached_value('UOM', item.stock_uom, 'must_be_whole_number')):