mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-06 23:10:26 +00:00
fix: make ledger entries submittable and cleanup invalid test submissions (#52921)
* fix: enable submittability for ledger entries and cleanup invalid test submissions * fix: reverted child table submittability * fix: added ignore_links flag for back gl entry * fix: add ignore_links for reconcile,cancelled PLE,cancelled SLE * fix: update test_recreate_stock_ledgers to use db.delete instead of doc.delete * chore: temporary test against frappe PR 37009 * fix: make Advance Payment Ledger Entry submittable * refactor: add extra line for create_shipping_rule * chore: revert temporary test against frappe PR 37009 * fix: use parent doc save with ignore_validate_update_after_submit for child table updates * chore: temporary test against frappe PR 37009 * chore: revert temporary test against frappe PR 37009 * fix: use skip_docstatus_validation
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
"doctype": "DocType",
|
||||
"document_type": "Document",
|
||||
"engine": "InnoDB",
|
||||
"is_submittable": 1,
|
||||
"field_order": [
|
||||
"closing_date",
|
||||
"account",
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"creation": "2024-10-16 16:57:12.085072",
|
||||
"doctype": "DocType",
|
||||
"engine": "InnoDB",
|
||||
"is_submittable": 1,
|
||||
"field_order": [
|
||||
"company",
|
||||
"voucher_type",
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"doctype": "DocType",
|
||||
"document_type": "Document",
|
||||
"engine": "InnoDB",
|
||||
"is_submittable": 1,
|
||||
"field_order": [
|
||||
"dates_section",
|
||||
"posting_date",
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"is_submittable": 1,
|
||||
"field_order": [
|
||||
"posting_date",
|
||||
"company",
|
||||
|
||||
@@ -867,11 +867,16 @@ class POSInvoice(SalesInvoice):
|
||||
|
||||
idx = self.payments[-1].idx if self.payments else -1
|
||||
|
||||
self.reload()
|
||||
self.flags.ignore_validate_update_after_submit = True
|
||||
|
||||
for d in payments:
|
||||
idx += 1
|
||||
payment = create_payments_on_invoice(self, idx, frappe._dict(d))
|
||||
paid_amount += flt(payment.amount)
|
||||
payment.submit()
|
||||
self.append("payments", payment)
|
||||
|
||||
self.save()
|
||||
|
||||
paid_amount = flt(flt(paid_amount), self.precision("paid_amount"))
|
||||
base_paid_amount = flt(flt(paid_amount * self.conversion_rate), self.precision("base_paid_amount"))
|
||||
|
||||
@@ -85,5 +85,5 @@ def create_shipping_rule(shipping_rule_type, shipping_rule_name):
|
||||
},
|
||||
)
|
||||
sr.insert(ignore_permissions=True)
|
||||
sr.submit()
|
||||
|
||||
return sr
|
||||
|
||||
@@ -197,6 +197,7 @@ class TaxWithholdingEntry(Document):
|
||||
|
||||
new_entry = frappe.copy_doc(old_entry)
|
||||
new_entry.update(values_to_update)
|
||||
new_entry.skip_docstatus_validation = True
|
||||
new_entry.insert()
|
||||
|
||||
docs_needing_reindex.add((old_entry.parenttype, old_entry.parent))
|
||||
@@ -335,6 +336,7 @@ class TaxWithholdingEntry(Document):
|
||||
"withholding_date": None,
|
||||
}
|
||||
new_entry.update(values_to_update)
|
||||
new_entry.skip_docstatus_validation = True
|
||||
new_entry.insert()
|
||||
|
||||
docs_needing_reindex.add((entry.parenttype, entry.parent))
|
||||
|
||||
@@ -429,6 +429,8 @@ def make_entry(args, adv_adj, update_outstanding, from_repost=False):
|
||||
gle.flags.adv_adj = adv_adj
|
||||
gle.flags.update_outstanding = update_outstanding or "Yes"
|
||||
gle.flags.notify_update = False
|
||||
if gle.is_cancelled:
|
||||
gle.flags.ignore_links = True
|
||||
gle.submit()
|
||||
|
||||
if (
|
||||
|
||||
@@ -692,11 +692,9 @@ class TestAccountsReceivable(AccountsTestMixin, IntegrationTestCase):
|
||||
)
|
||||
|
||||
def test_sales_person(self):
|
||||
sales_person = (
|
||||
frappe.get_doc({"doctype": "Sales Person", "sales_person_name": "John Clark", "enabled": True})
|
||||
.insert()
|
||||
.submit()
|
||||
)
|
||||
sales_person = frappe.get_doc(
|
||||
{"doctype": "Sales Person", "sales_person_name": "John Clark", "enabled": True}
|
||||
).insert()
|
||||
si = self.create_sales_invoice(do_not_submit=True)
|
||||
si.append("sales_team", {"sales_person": sales_person.name, "allocated_percentage": 100})
|
||||
si.save().submit()
|
||||
@@ -772,18 +770,14 @@ class TestAccountsReceivable(AccountsTestMixin, IntegrationTestCase):
|
||||
|
||||
def test_party_account_filter(self):
|
||||
si1 = self.create_sales_invoice()
|
||||
self.customer2 = (
|
||||
frappe.get_doc(
|
||||
{
|
||||
"doctype": "Customer",
|
||||
"customer_name": "Jane Doe",
|
||||
"type": "Individual",
|
||||
"default_currency": "USD",
|
||||
}
|
||||
)
|
||||
.insert()
|
||||
.submit()
|
||||
)
|
||||
self.customer2 = frappe.get_doc(
|
||||
{
|
||||
"doctype": "Customer",
|
||||
"customer_name": "Jane Doe",
|
||||
"type": "Individual",
|
||||
"default_currency": "USD",
|
||||
}
|
||||
).insert()
|
||||
|
||||
si2 = self.create_sales_invoice(do_not_submit=True)
|
||||
si2.posting_date = add_days(today(), -1)
|
||||
@@ -995,18 +989,14 @@ class TestAccountsReceivable(AccountsTestMixin, IntegrationTestCase):
|
||||
self.assertEqual(expected_data, report_output)
|
||||
|
||||
def test_future_payments_on_foreign_currency(self):
|
||||
self.customer2 = (
|
||||
frappe.get_doc(
|
||||
{
|
||||
"doctype": "Customer",
|
||||
"customer_name": "Jane Doe",
|
||||
"type": "Individual",
|
||||
"default_currency": "USD",
|
||||
}
|
||||
)
|
||||
.insert()
|
||||
.submit()
|
||||
)
|
||||
self.customer2 = frappe.get_doc(
|
||||
{
|
||||
"doctype": "Customer",
|
||||
"customer_name": "Jane Doe",
|
||||
"type": "Individual",
|
||||
"default_currency": "USD",
|
||||
}
|
||||
).insert()
|
||||
|
||||
si = self.create_sales_invoice(do_not_submit=True)
|
||||
si.posting_date = add_days(today(), -1)
|
||||
|
||||
@@ -2142,6 +2142,7 @@ def create_payment_ledger_entry(
|
||||
if is_immutable_ledger_enabled():
|
||||
ple.delinked = 0
|
||||
ple.posting_date = frappe.form_dict.get("posting_date") or getdate()
|
||||
ple.flags.ignore_links = True
|
||||
|
||||
ple.flags.ignore_permissions = 1
|
||||
ple.flags.adv_adj = adv_adj
|
||||
|
||||
@@ -721,6 +721,7 @@ class SubcontractingInwardController:
|
||||
"Subcontracting Inward Order Item", item.against_fg, "item_code"
|
||||
),
|
||||
)
|
||||
scio_rm.skip_docstatus_validation = True
|
||||
scio_rm.insert()
|
||||
scio_rm.submit()
|
||||
item.db_set("scio_detail", scio_rm.name)
|
||||
@@ -867,6 +868,7 @@ class SubcontractingInwardController:
|
||||
warehouse=extra_item.s_warehouse,
|
||||
is_additional_item=True,
|
||||
)
|
||||
doc.skip_docstatus_validation = True
|
||||
doc.insert()
|
||||
doc.submit()
|
||||
|
||||
@@ -954,6 +956,7 @@ class SubcontractingInwardController:
|
||||
"Work Order", self.work_order, "subcontracting_inward_order_item"
|
||||
),
|
||||
)
|
||||
doc.skip_docstatus_validation = True
|
||||
doc.insert()
|
||||
doc.submit()
|
||||
|
||||
|
||||
@@ -2483,7 +2483,7 @@ class TestAccountsController(IntegrationTestCase):
|
||||
def test_document_naming_rule_based_on_posting_date(self):
|
||||
frappe.new_doc(
|
||||
"Document Naming Rule", document_type="Sales Invoice", prefix="SI-.MM.-.YYYY.-"
|
||||
).submit()
|
||||
).insert()
|
||||
|
||||
si = create_sales_invoice(do_not_save=True)
|
||||
si.set_posting_time = 1
|
||||
|
||||
@@ -2068,9 +2068,11 @@ class WorkOrder(Document):
|
||||
if row.item_code not in required_items:
|
||||
additional_items.setdefault(row.item_code, []).append(row)
|
||||
|
||||
self.flags.ignore_validate_update_after_submit = True
|
||||
|
||||
for item_code, rows in additional_items.items():
|
||||
for row in rows:
|
||||
child_row = self.append(
|
||||
self.append(
|
||||
"required_items",
|
||||
{
|
||||
"item_code": item_code,
|
||||
@@ -2081,15 +2083,13 @@ class WorkOrder(Document):
|
||||
"rate": row.basic_rate,
|
||||
"amount": row.amount,
|
||||
"description": row.description,
|
||||
"docstatus": 1,
|
||||
"is_additional_item": 1,
|
||||
"voucher_detail_reference": row.name,
|
||||
},
|
||||
)
|
||||
|
||||
child_row.insert()
|
||||
|
||||
stock_entry.reload()
|
||||
self.save()
|
||||
stock_entry.reload()
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
|
||||
@@ -4278,8 +4278,7 @@ class TestPurchaseReceipt(IntegrationTestCase):
|
||||
self.assertTrue(sles)
|
||||
|
||||
for row in sles:
|
||||
doc = frappe.get_doc("Stock Ledger Entry", row)
|
||||
doc.delete()
|
||||
frappe.db.delete("Stock Ledger Entry", {"name": row})
|
||||
|
||||
sles = frappe.get_all(
|
||||
"Stock Ledger Entry",
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
"doctype": "DocType",
|
||||
"document_type": "Other",
|
||||
"engine": "InnoDB",
|
||||
"is_submittable": 1,
|
||||
"field_order": [
|
||||
"item_code",
|
||||
"warehouse",
|
||||
|
||||
@@ -230,6 +230,8 @@ def make_entry(args, allow_negative_stock=False, via_landed_cost_voucher=False):
|
||||
sle.flags.ignore_permissions = 1
|
||||
sle.allow_negative_stock = allow_negative_stock
|
||||
sle.via_landed_cost_voucher = via_landed_cost_voucher
|
||||
if args.get("is_cancelled"):
|
||||
sle.flags.ignore_links = True
|
||||
sle.submit()
|
||||
|
||||
# Added to handle the case when the stock ledger entry is created from the repostig
|
||||
|
||||
Reference in New Issue
Block a user