Merge branch 'develop' of https://github.com/frappe/erpnext into rebrand-ui

This commit is contained in:
Suraj Shetty 2021-02-01 15:10:52 +05:30
commit 055b81da7b
3 changed files with 52 additions and 5 deletions

View File

@ -550,6 +550,48 @@ class TestWorkOrder(unittest.TestCase):
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`

View File

@ -161,7 +161,7 @@ def get_item_list(invoice):
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 @@ def get_invoice_value_details(invoice):
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 # invoice.base_discount_amount
invoice_value_details.invoice_discount_amt = 0
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)

View File

@ -1199,6 +1199,9 @@ class StockEntry(StockController):
qty =0
else:
qty = (req_qty_each * flt(self.fg_completed_qty)) - remaining_qty
else:
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)
@ -1208,7 +1211,8 @@ class StockEntry(StockController):
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')):