Skip to content

Commit

Permalink
chore: v14 patch release (#38408)
Browse files Browse the repository at this point in the history
* feat: shift depreciation for assets [v14] [backport of #38327] (#38404)

feat: shift depreciation for assets

* fix: no fstring in translation (#38381)

fix: no fstring in translation (#38381)

(cherry picked from commit 8f00481)

Co-authored-by: Raffael Meyer <[email protected]>

* fix: debit credit mismatch in multi-currecy asset purchase receipt (#38342)

fix: debit credit mismatch in multi-currecy asset purchase receipt (#38342)

* fix: Debit credit mimatch in multicurrecy asset purchase receipt

* test: multi currency purchase receipt

* chore: update init files

* test: roolback

(cherry picked from commit add238c)

Co-authored-by: Deepesh Garg <[email protected]>

* fix(regional): use net figures for sales calc (#38260)

fix(regional): use net figures for sales calc (#38260)

(cherry picked from commit 663bb87)

Co-authored-by: Dany Robert <[email protected]>

---------

Co-authored-by: Anand Baburajan <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Raffael Meyer <[email protected]>
Co-authored-by: Dany Robert <[email protected]>
  • Loading branch information
5 people authored Nov 29, 2023
1 parent 9170ffc commit 44b1175
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 72 deletions.
103 changes: 36 additions & 67 deletions erpnext/assets/doctype/asset/test_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,7 @@ def test_purchase_asset(self):
("Creditors - _TC", 0.0, 100000.0),
)

gle = frappe.db.sql(
"""select account, debit, credit from `tabGL Entry`
where voucher_type='Purchase Invoice' and voucher_no = %s
order by account""",
pi.name,
)
gle = get_gl_entries("Purchase Invoice", pi.name)
self.assertSequenceEqual(gle, expected_gle)

pi.cancel()
Expand Down Expand Up @@ -249,12 +244,7 @@ def test_scrap_asset(self):
),
)

gle = frappe.db.sql(
"""select account, debit, credit from `tabGL Entry`
where voucher_type='Journal Entry' and voucher_no = %s
order by account""",
asset.journal_entry_for_scrap,
)
gle = get_gl_entries("Journal Entry", asset.journal_entry_for_scrap)
self.assertSequenceEqual(gle, expected_gle)

restore_asset(asset.name)
Expand Down Expand Up @@ -316,13 +306,7 @@ def test_gle_made_by_asset_sale(self):
("Debtors - _TC", 25000.0, 0.0),
)

gle = frappe.db.sql(
"""select account, debit, credit from `tabGL Entry`
where voucher_type='Sales Invoice' and voucher_no = %s
order by account""",
si.name,
)

gle = get_gl_entries("Sales Invoice", si.name)
self.assertSequenceEqual(gle, expected_gle)

si.cancel()
Expand Down Expand Up @@ -392,13 +376,7 @@ def test_gle_made_by_asset_sale_for_existing_asset(self):
("Debtors - _TC", 40000.0, 0.0),
)

gle = frappe.db.sql(
"""select account, debit, credit from `tabGL Entry`
where voucher_type='Sales Invoice' and voucher_no = %s
order by account""",
si.name,
)

gle = get_gl_entries("Sales Invoice", si.name)
self.assertSequenceEqual(gle, expected_gle)

def test_asset_with_maintenance_required_status_after_sale(self):
Expand Down Expand Up @@ -526,13 +504,7 @@ def test_cwip_accounting(self):
("CWIP Account - _TC", 5250.0, 0.0),
)

pr_gle = frappe.db.sql(
"""select account, debit, credit from `tabGL Entry`
where voucher_type='Purchase Receipt' and voucher_no = %s
order by account""",
pr.name,
)

pr_gle = get_gl_entries("Purchase Receipt", pr.name)
self.assertSequenceEqual(pr_gle, expected_gle)

pi = make_invoice(pr.name)
Expand All @@ -545,13 +517,7 @@ def test_cwip_accounting(self):
("Creditors - _TC", 0.0, 5500.0),
)

pi_gle = frappe.db.sql(
"""select account, debit, credit from `tabGL Entry`
where voucher_type='Purchase Invoice' and voucher_no = %s
order by account""",
pi.name,
)

pi_gle = get_gl_entries("Purchase Invoice", pi.name)
self.assertSequenceEqual(pi_gle, expected_gle)

asset = frappe.db.get_value("Asset", {"purchase_receipt": pr.name, "docstatus": 0}, "name")
Expand All @@ -578,13 +544,7 @@ def test_cwip_accounting(self):

expected_gle = (("_Test Fixed Asset - _TC", 5250.0, 0.0), ("CWIP Account - _TC", 0.0, 5250.0))

gle = frappe.db.sql(
"""select account, debit, credit from `tabGL Entry`
where voucher_type='Asset' and voucher_no = %s
order by account""",
asset_doc.name,
)

gle = get_gl_entries("Asset", asset_doc.name)
self.assertSequenceEqual(gle, expected_gle)

def test_asset_cwip_toggling_cases(self):
Expand All @@ -607,10 +567,7 @@ def test_asset_cwip_toggling_cases(self):
asset_doc.available_for_use_date = nowdate()
asset_doc.calculate_depreciation = 0
asset_doc.submit()
gle = frappe.db.sql(
"""select name from `tabGL Entry` where voucher_type='Asset' and voucher_no = %s""",
asset_doc.name,
)
gle = get_gl_entries("Asset", asset_doc.name)
self.assertFalse(gle)

# case 1 -- PR with cwip disabled, Asset with cwip enabled
Expand All @@ -624,10 +581,7 @@ def test_asset_cwip_toggling_cases(self):
asset_doc.available_for_use_date = nowdate()
asset_doc.calculate_depreciation = 0
asset_doc.submit()
gle = frappe.db.sql(
"""select name from `tabGL Entry` where voucher_type='Asset' and voucher_no = %s""",
asset_doc.name,
)
gle = get_gl_entries("Asset", asset_doc.name)
self.assertFalse(gle)

# case 2 -- PR with cwip enabled, Asset with cwip disabled
Expand All @@ -640,10 +594,7 @@ def test_asset_cwip_toggling_cases(self):
asset_doc.available_for_use_date = nowdate()
asset_doc.calculate_depreciation = 0
asset_doc.submit()
gle = frappe.db.sql(
"""select name from `tabGL Entry` where voucher_type='Asset' and voucher_no = %s""",
asset_doc.name,
)
gle = get_gl_entries("Asset", asset_doc.name)
self.assertTrue(gle)

# case 3 -- PI with cwip disabled, Asset with cwip enabled
Expand All @@ -656,10 +607,7 @@ def test_asset_cwip_toggling_cases(self):
asset_doc.available_for_use_date = nowdate()
asset_doc.calculate_depreciation = 0
asset_doc.submit()
gle = frappe.db.sql(
"""select name from `tabGL Entry` where voucher_type='Asset' and voucher_no = %s""",
asset_doc.name,
)
gle = get_gl_entries("Asset", asset_doc.name)
self.assertFalse(gle)

# case 4 -- PI with cwip enabled, Asset with cwip disabled
Expand All @@ -672,10 +620,7 @@ def test_asset_cwip_toggling_cases(self):
asset_doc.available_for_use_date = nowdate()
asset_doc.calculate_depreciation = 0
asset_doc.submit()
gle = frappe.db.sql(
"""select name from `tabGL Entry` where voucher_type='Asset' and voucher_no = %s""",
asset_doc.name,
)
gle = get_gl_entries("Asset", asset_doc.name)
self.assertTrue(gle)

frappe.db.set_value("Asset Category", "Computers", "enable_cwip_accounting", cwip)
Expand Down Expand Up @@ -1644,6 +1589,30 @@ def test_manual_depreciation_with_incorrect_jv_voucher_type(self):

self.assertRaises(frappe.ValidationError, jv.insert)

def test_multi_currency_asset_pr_creation(self):
pr = make_purchase_receipt(
item_code="Macbook Pro",
qty=1,
rate=100.0,
location="Test Location",
supplier="_Test Supplier USD",
currency="USD",
)

pr.submit()
self.assertTrue(get_gl_entries("Purchase Receipt", pr.name))


def get_gl_entries(doctype, docname):
gl_entry = frappe.qb.DocType("GL Entry")
return (
frappe.qb.from_(gl_entry)
.select(gl_entry.account, gl_entry.debit, gl_entry.credit)
.where((gl_entry.voucher_type == doctype) & (gl_entry.voucher_no == docname))
.orderby(gl_entry.account)
.run()
)


def create_asset_data():
if not frappe.db.exists("Asset Category", "Computers"):
Expand Down
6 changes: 3 additions & 3 deletions erpnext/regional/report/uae_vat_201/uae_vat_201.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def get_total_emiratewise(filters):
return frappe.db.sql(
"""
select
s.vat_emirate as emirate, sum(i.base_amount) as total, sum(i.tax_amount)
s.vat_emirate as emirate, sum(i.base_net_amount) as total, sum(i.tax_amount)
from
`tabSales Invoice Item` i inner join `tabSales Invoice` s
on
Expand Down Expand Up @@ -356,7 +356,7 @@ def get_zero_rated_total(filters):
frappe.db.sql(
"""
select
sum(i.base_amount) as total
sum(i.base_net_amount) as total
from
`tabSales Invoice Item` i inner join `tabSales Invoice` s
on
Expand All @@ -383,7 +383,7 @@ def get_exempt_total(filters):
frappe.db.sql(
"""
select
sum(i.base_amount) as total
sum(i.base_net_amount) as total
from
`tabSales Invoice Item` i inner join `tabSales Invoice` s
on
Expand Down
2 changes: 1 addition & 1 deletion erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ def make_divisional_loss_gl_entry(item, outgoing_amount):
)

stock_value_diff = (
flt(d.net_amount)
flt(d.base_net_amount)
+ flt(d.item_tax_amount / self.conversion_rate)
+ flt(d.landed_cost_voucher_amount)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,4 @@ def create_reposting_entries(rows, company):

if entries:
entries = ", ".join(entries)
frappe.msgprint(_(f"Reposting entries created: {entries}"))
frappe.msgprint(_("Reposting entries created: {0}").format(entries))

0 comments on commit 44b1175

Please sign in to comment.