Skip to content

Commit

Permalink
chore: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
deepeshgarg007 committed Oct 22, 2023
1 parent dbe7000 commit 683600f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
7 changes: 4 additions & 3 deletions erpnext/assets/doctype/asset/test_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ def test_purchase_of_grouped_asset(self):
def test_is_fixed_asset_set(self):
asset = create_asset(is_existing_asset=1)
doc = frappe.new_doc("Purchase Invoice")
doc.company = "_Test Company"
doc.supplier = "_Test Supplier"
doc.append("items", {"item_code": "Macbook Pro", "qty": 1, "asset": asset.name})

Expand Down Expand Up @@ -566,7 +567,8 @@ def test_cwip_accounting(self):
pr.submit()

expected_gle = (
("Asset Received But Not Billed - _TC", 0.0, 5250.0),
("_Test Account Shipping Charges - _TC", 0.0, 250.0),
("Asset Received But Not Billed - _TC", 0.0, 5000.0),
("CWIP Account - _TC", 5250.0, 0.0),
)

Expand All @@ -585,9 +587,8 @@ def test_cwip_accounting(self):
expected_gle = (
("_Test Account Service Tax - _TC", 250.0, 0.0),
("_Test Account Shipping Charges - _TC", 250.0, 0.0),
("Asset Received But Not Billed - _TC", 5250.0, 0.0),
("Asset Received But Not Billed - _TC", 5000.0, 0.0),
("Creditors - _TC", 0.0, 5500.0),
("Expenses Included In Asset Valuation - _TC", 0.0, 250.0),
)

pi_gle = frappe.db.sql(
Expand Down
14 changes: 9 additions & 5 deletions erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def make_item_gl_entries(self, gl_entries, warehouse_account=None):
def validate_account(account_type):
frappe.throw(_("{0} account not found while submitting purchase receipt").format(account_type))

def make_item_asset_inward_entries(item, stock_value_diff, stock_asset_account_name):
def make_item_asset_inward_gl_entry(item, stock_value_diff, stock_asset_account_name):
account_currency = get_account_currency(stock_asset_account_name)

if not stock_asset_account_name:
Expand All @@ -356,7 +356,6 @@ def make_stock_received_but_not_billed_entry(item):
)
account_currency = get_account_currency(account)

outgoing_amount = item.base_net_amount
# GL Entry for from warehouse or Stock Received but not billed
# Intentionally passed negative debit amount to avoid incorrect GL Entry validation
credit_amount = (
Expand All @@ -365,6 +364,7 @@ def make_stock_received_but_not_billed_entry(item):
else flt(item.net_amount, item.precision("net_amount"))
)

outgoing_amount = item.base_net_amount
if self.is_internal_transfer() and item.valuation_rate:
outgoing_amount = abs(get_stock_value_difference(self.name, item.name, item.from_warehouse))
credit_amount = outgoing_amount
Expand All @@ -381,7 +381,7 @@ def make_stock_received_but_not_billed_entry(item):
credit=0.0,
remarks=remarks,
against_account=stock_asset_account_name,
debit_in_account_currency=-1 * credit_amount,
debit_in_account_currency=-1 * flt(outgoing_amount, item.precision("base_net_amount")),
account_currency=account_currency,
item=item,
)
Expand Down Expand Up @@ -569,7 +569,11 @@ def make_divisional_loss_gl_entry(item):
account_type, asset_category=d.asset_category, company=self.company
)

stock_value_diff = flt(d.net_amount) + flt(d.item_tax_amount / self.conversion_rate)
stock_value_diff = (
flt(d.net_amount)
+ flt(d.item_tax_amount / self.conversion_rate)
+ flt(d.landed_cost_voucher_amount)
)
elif warehouse_account.get(d.warehouse):
stock_value_diff = get_stock_value_difference(self.name, d.name, d.warehouse)
stock_asset_account_name = warehouse_account[d.warehouse]["account"]
Expand All @@ -589,7 +593,7 @@ def make_divisional_loss_gl_entry(item):
continue

if (flt(d.valuation_rate) or self.is_return or d.is_fixed_asset) and flt(d.qty):
make_item_asset_inward_entries(d, stock_value_diff, stock_asset_account_name)
make_item_asset_inward_gl_entry(d, stock_value_diff, stock_asset_account_name)
make_stock_received_but_not_billed_entry(d)
make_landed_cost_gl_entries(d)
make_rate_difference_entry(d)
Expand Down

0 comments on commit 683600f

Please sign in to comment.