Skip to content

Commit

Permalink
test: Purchase Receipt Provisional Accounting GL Entries
Browse files Browse the repository at this point in the history
  • Loading branch information
s-aga-r committed Sep 13, 2023
1 parent 64c9513 commit d88ac29
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions erpnext/buying/doctype/supplier/test_supplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ def create_supplier(**args):
{
"doctype": "Supplier",
"supplier_name": args.supplier_name,
"default_currency": args.default_currency,
"supplier_group": args.supplier_group or "Services",
"supplier_type": args.supplier_type or "Company",
"tax_withholding_category": args.tax_withholding_category,
Expand Down
41 changes: 41 additions & 0 deletions erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2017,6 +2017,47 @@ def test_purchase_receipt_with_backdated_landed_cost_voucher(self):
ste7.reload()
self.assertEqual(ste7.items[0].valuation_rate, valuation_rate)

def test_purchase_receipt_provisional_accounting(self):
# Step - 1: Create Supplier
from erpnext.buying.doctype.supplier.test_supplier import create_supplier

supplier = create_supplier(default_currency="USD")

# Step - 2: Create Company with Provisional Accounting
from erpnext.accounts.report.trial_balance.test_trial_balance import create_company

company_name = create_company(company_name="Test Company With Provisional Accounting")
frappe.db.set_value(
"Company",
company_name,
{
"enable_provisional_accounting_for_non_stock_items": 1,
"default_provisional_account": "Stock Received But Not Billed - TCWPA",
},
)

# Step - 3: Create Non-Stock Item
item = make_item(properties={"is_stock_item": 0})

# Step - 4: Create Purchase Receipt
pr = make_purchase_receipt(
qty=2,
item_code=item.name,
company=company_name,
supplier=supplier.name,
warehouse="Stores - TCWPA",
currency=supplier.default_currency,
)

# Test - 1: Total and Base Total should not be the same as the currency is different
self.assertNotEqual(flt(pr.total, 2), flt(pr.base_total, 2))
self.assertEqual(flt(pr.total * pr.conversion_rate, 2), flt(pr.base_total, 2))

# Test - 2: Sum of Debit or Credit should be equal to PR Base Total
amount = frappe.db.get_value("GL Entry", {"docstatus": 1, "voucher_no": pr.name}, ["sum(debit)"])
expected_amount = pr.base_total
self.assertEqual(amount, expected_amount)


def prepare_data_for_internal_transfer():
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_internal_supplier
Expand Down

0 comments on commit d88ac29

Please sign in to comment.