Skip to content

Commit

Permalink
test: validate buying workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninad1306 committed Nov 27, 2024
1 parent d049c97 commit 94d3fc9
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions erpnext/controllers/tests/test_accounts_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,7 @@ def test_15_gain_loss_on_different_posting_date(self):
"Stock Settings", {"allow_internal_transfer_at_arms_length_price": 1}
)
def test_16_internal_transfer_at_arms_length_price(self):
from erpnext.accounts.doctype.sales_invoice.sales_invoice import make_inter_company_purchase_invoice
from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse

prepare_data_for_internal_transfer()
Expand Down Expand Up @@ -842,6 +843,31 @@ def test_16_internal_transfer_at_arms_length_price(self):
# rate should reset to incoming rate
self.assertEqual(si.items[0].rate, 100)

si.update_stock = 0
si.save()
si.submit()

pi = make_inter_company_purchase_invoice(si.name)
pi.update_stock = 1
pi.items[0].rate = arms_length_price
pi.items[0].warehouse = target_warehouse
pi.items[0].from_warehouse = warehouse
pi.save()

self.assertEqual(pi.items[0].rate, 100)
self.assertEqual(pi.items[0].valuation_rate, 100)

frappe.db.set_single_value("Stock Settings", "allow_internal_transfer_at_arms_length_price", 1)
pi = make_inter_company_purchase_invoice(si.name)
pi.update_stock = 1
pi.items[0].rate = arms_length_price
pi.items[0].warehouse = target_warehouse
pi.items[0].from_warehouse = warehouse
pi.save()

self.assertEqual(pi.items[0].rate, arms_length_price)
self.assertEqual(pi.items[0].valuation_rate, 100)

def test_20_journal_against_sales_invoice(self):
# Invoice in Foreign Currency
si = self.create_sales_invoice(qty=1, conversion_rate=80, rate=1)
Expand Down

0 comments on commit 94d3fc9

Please sign in to comment.