mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-18 17:55:40 +00:00
test: reposted acc entries for pi
(cherry picked from commit c66c438575)
# Conflicts:
# erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
This commit is contained in:
committed by
ruthra kumar
parent
6c8a65e03b
commit
a512d27dbb
@@ -60,7 +60,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying.
|
||||
}
|
||||
|
||||
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({
|
||||
@@ -70,7 +70,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying.
|
||||
freeze_message: __('Reposting...'),
|
||||
callback: (r) => {
|
||||
if (!r.exc) {
|
||||
frappe.msgprint(__('Accounting Entries are reposted'));
|
||||
frappe.msgprint(__('Accounting Entries are reposted.'));
|
||||
me.frm.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1710,6 +1710,65 @@ class TestPurchaseInvoice(unittest.TestCase, StockTestMixin):
|
||||
|
||||
self.assertTrue(return_pi.docstatus == 1)
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
def test_advance_entries_as_asset(self):
|
||||
from erpnext.accounts.doctype.payment_entry.test_payment_entry import create_payment_entry
|
||||
|
||||
account = create_account(
|
||||
parent_account="Current Assets - _TC",
|
||||
account_name="Advances Paid",
|
||||
company="_Test Company",
|
||||
account_type="Receivable",
|
||||
)
|
||||
|
||||
set_advance_flag(company="_Test Company", flag=1, default_account=account)
|
||||
|
||||
pe = create_payment_entry(
|
||||
company="_Test Company",
|
||||
payment_type="Pay",
|
||||
party_type="Supplier",
|
||||
party="_Test Supplier",
|
||||
paid_from="Cash - _TC",
|
||||
paid_to="Creditors - _TC",
|
||||
paid_amount=500,
|
||||
)
|
||||
pe.submit()
|
||||
|
||||
pi = make_purchase_invoice(
|
||||
company="_Test Company",
|
||||
do_not_save=True,
|
||||
do_not_submit=True,
|
||||
rate=1000,
|
||||
price_list_rate=1000,
|
||||
qty=1,
|
||||
)
|
||||
pi.base_grand_total = 1000
|
||||
pi.grand_total = 1000
|
||||
pi.set_advances()
|
||||
for advance in pi.advances:
|
||||
advance.allocated_amount = 500 if advance.reference_name == pe.name else 0
|
||||
pi.save()
|
||||
pi.submit()
|
||||
|
||||
self.assertEqual(pi.advances[0].allocated_amount, 500)
|
||||
|
||||
# Check GL Entry against payment doctype
|
||||
expected_gle = [
|
||||
["Advances Paid - _TC", 0.0, 500, nowdate()],
|
||||
["Cash - _TC", 0.0, 500, nowdate()],
|
||||
["Creditors - _TC", 500, 0.0, nowdate()],
|
||||
["Creditors - _TC", 500, 0.0, nowdate()],
|
||||
]
|
||||
|
||||
check_gl_entries(self, pe.name, expected_gle, nowdate(), voucher_type="Payment Entry")
|
||||
|
||||
pi.load_from_db()
|
||||
self.assertEqual(pi.outstanding_amount, 500)
|
||||
|
||||
set_advance_flag(company="_Test Company", flag=0, default_account="")
|
||||
|
||||
>>>>>>> c66c438575 (test: reposted acc entries for pi)
|
||||
def test_gl_entries_for_standalone_debit_note(self):
|
||||
make_purchase_invoice(qty=5, rate=500, update_stock=True)
|
||||
|
||||
@@ -1796,7 +1855,6 @@ class TestPurchaseInvoice(unittest.TestCase, StockTestMixin):
|
||||
|
||||
pi = make_purchase_invoice(
|
||||
company="_Test Company",
|
||||
customer="_Test Supplier",
|
||||
do_not_save=True,
|
||||
do_not_submit=True,
|
||||
rate=1000,
|
||||
@@ -1826,6 +1884,32 @@ class TestPurchaseInvoice(unittest.TestCase, StockTestMixin):
|
||||
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 check_gl_entries(
|
||||
doc,
|
||||
|
||||
Reference in New Issue
Block a user