test: reposted acc entries for pi
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
index d895a94..095617d 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
@@ -66,7 +66,7 @@
}
if (this.frm.doc.repost_required && this.frm.doc.docstatus===1) {
- this.frm.set_intro(__("Accounting entries for this invoice needs to be reposted. Please click on 'Repost' button to update."));
+ this.frm.set_intro(__("Accounting entries for this invoice need to be reposted. Please click on 'Repost' button to update."));
this.frm.add_custom_button(__('Repost Accounting Entries'),
() => {
this.frm.call({
@@ -76,7 +76,7 @@
freeze_message: __('Reposting...'),
callback: (r) => {
if (!r.exc) {
- frappe.msgprint(__('Accounting Entries are reposted'));
+ frappe.msgprint(__('Accounting Entries are reposted.'));
me.frm.refresh();
}
}
diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
index b4dd75a..0aaea06 100644
--- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
@@ -1744,7 +1744,6 @@
pi = make_purchase_invoice(
company="_Test Company",
- customer="_Test Supplier",
do_not_save=True,
do_not_submit=True,
rate=1000,
@@ -1862,7 +1861,6 @@
pi = make_purchase_invoice(
company="_Test Company",
- customer="_Test Supplier",
do_not_save=True,
do_not_submit=True,
rate=1000,
@@ -1892,6 +1890,32 @@
clear_dimension_defaults("Branch")
disable_dimension()
+ def test_repost_accounting_entries(self):
+ pi = make_purchase_invoice(
+ rate=1000,
+ price_list_rate=1000,
+ qty=1,
+ )
+ expected_gle = [
+ ["_Test Account Cost for Goods Sold - _TC", 1000, 0.0, nowdate()],
+ ["Creditors - _TC", 0.0, 1000, nowdate()],
+ ]
+ check_gl_entries(self, pi.name, expected_gle, nowdate())
+
+ pi.items[0].expense_account = "Service - _TC"
+ pi.save()
+ pi.load_from_db()
+ self.assertTrue(pi.repost_required)
+ pi.repost_accounting_entries()
+
+ expected_gle = [
+ ["Creditors - _TC", 0.0, 1000, nowdate()],
+ ["Service - _TC", 1000, 0.0, nowdate()],
+ ]
+ check_gl_entries(self, pi.name, expected_gle, nowdate())
+ pi.load_from_db()
+ self.assertFalse(pi.repost_required)
+
def set_advance_flag(company, flag, default_account):
frappe.db.set_value(