mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-22 06:29:20 +00:00
test(gross profit): valuation rate from different warehouse
(cherry picked from commit 577ce5ccd4)
# Conflicts:
# erpnext/accounts/report/gross_profit/test_gross_profit.py
This commit is contained in:
@@ -557,4 +557,55 @@ class TestGrossProfit(FrappeTestCase):
|
|||||||
"gross_profit_%": 12.5,
|
"gross_profit_%": 12.5,
|
||||||
}
|
}
|
||||||
gp_entry = [x for x in data if x.parent_invoice == sinv.name]
|
gp_entry = [x for x in data if x.parent_invoice == sinv.name]
|
||||||
|
<<<<<<< HEAD
|
||||||
self.assertDictContainsSubset(expected_entry, gp_entry[0])
|
self.assertDictContainsSubset(expected_entry, gp_entry[0])
|
||||||
|
=======
|
||||||
|
self.assertEqual(gp_entry[0], gp_entry[0] | expected_entry)
|
||||||
|
|
||||||
|
def test_valuation_rate_without_previous_sle(self):
|
||||||
|
"""
|
||||||
|
Test Valuation rate calculation when stock ledger is empty and invoices are against different warehouses
|
||||||
|
"""
|
||||||
|
stock_settings = frappe.get_doc("Stock Settings")
|
||||||
|
stock_settings.valuation_method = "FIFO"
|
||||||
|
stock_settings.save()
|
||||||
|
|
||||||
|
item = create_item(
|
||||||
|
item_code="_Test Wirebound Notebook",
|
||||||
|
is_stock_item=1,
|
||||||
|
)
|
||||||
|
item.allow_negative_stock = True
|
||||||
|
item.save()
|
||||||
|
self.item = item.item_code
|
||||||
|
|
||||||
|
item.reload()
|
||||||
|
item.valuation_rate = 1900
|
||||||
|
item.save()
|
||||||
|
sinv1 = self.create_sales_invoice(qty=1, rate=2000, posting_date=nowdate(), do_not_submit=True)
|
||||||
|
sinv1.update_stock = 1
|
||||||
|
sinv1.set_warehouse = self.warehouse
|
||||||
|
sinv1.items[0].warehouse = self.warehouse
|
||||||
|
sinv1.save().submit()
|
||||||
|
|
||||||
|
item.reload()
|
||||||
|
item.valuation_rate = 1800
|
||||||
|
item.save()
|
||||||
|
sinv2 = self.create_sales_invoice(qty=1, rate=2000, posting_date=nowdate(), do_not_submit=True)
|
||||||
|
sinv2.update_stock = 1
|
||||||
|
sinv2.set_warehouse = self.finished_warehouse
|
||||||
|
sinv2.items[0].warehouse = self.finished_warehouse
|
||||||
|
sinv2.save().submit()
|
||||||
|
|
||||||
|
filters = frappe._dict(
|
||||||
|
company=self.company, from_date=nowdate(), to_date=nowdate(), group_by="Invoice"
|
||||||
|
)
|
||||||
|
columns, data = execute(filters=filters)
|
||||||
|
|
||||||
|
item_from_sinv1 = [x for x in data if x.parent_invoice == sinv1.name]
|
||||||
|
self.assertEqual(len(item_from_sinv1), 1)
|
||||||
|
self.assertEqual(1900, item_from_sinv1[0].valuation_rate)
|
||||||
|
|
||||||
|
item_from_sinv2 = [x for x in data if x.parent_invoice == sinv2.name]
|
||||||
|
self.assertEqual(len(item_from_sinv2), 1)
|
||||||
|
self.assertEqual(1800, item_from_sinv2[0].valuation_rate)
|
||||||
|
>>>>>>> 577ce5ccd4 (test(gross profit): valuation rate from different warehouse)
|
||||||
|
|||||||
Reference in New Issue
Block a user