Merge pull request #48357 from aerele/fix-pos-merge-log

fix: add company field on POS Invoice Merge Log
This commit is contained in:
Diptanil Saha
2025-07-06 14:26:50 +05:30
committed by GitHub
5 changed files with 53 additions and 5 deletions

View File

@@ -5,6 +5,7 @@
"editable_grid": 1, "editable_grid": 1,
"engine": "InnoDB", "engine": "InnoDB",
"field_order": [ "field_order": [
"company",
"posting_date", "posting_date",
"posting_time", "posting_time",
"merge_invoices_based_on", "merge_invoices_based_on",
@@ -113,12 +114,22 @@
"label": "Posting Time", "label": "Posting Time",
"no_copy": 1, "no_copy": 1,
"reqd": 1 "reqd": 1
},
{
"fieldname": "company",
"fieldtype": "Link",
"in_standard_filter": 1,
"label": "Company",
"options": "Company",
"print_hide": 1,
"remember_last_selected_value": 1,
"reqd": 1
} }
], ],
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2024-03-27 13:10:15.620564", "modified": "2025-07-02 17:08:04.747202",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "POS Invoice Merge Log", "name": "POS Invoice Merge Log",
@@ -179,8 +190,9 @@
"write": 1 "write": 1
} }
], ],
"row_format": "Dynamic",
"sort_field": "creation", "sort_field": "creation",
"sort_order": "DESC", "sort_order": "DESC",
"states": [], "states": [],
"track_changes": 1 "track_changes": 1
} }

View File

@@ -29,11 +29,10 @@ class POSInvoiceMergeLog(Document):
if TYPE_CHECKING: if TYPE_CHECKING:
from frappe.types import DF from frappe.types import DF
from erpnext.accounts.doctype.pos_invoice_reference.pos_invoice_reference import ( from erpnext.accounts.doctype.pos_invoice_reference.pos_invoice_reference import POSInvoiceReference
POSInvoiceReference,
)
amended_from: DF.Link | None amended_from: DF.Link | None
company: DF.Link
consolidated_credit_note: DF.Link | None consolidated_credit_note: DF.Link | None
consolidated_invoice: DF.Link | None consolidated_invoice: DF.Link | None
customer: DF.Link customer: DF.Link
@@ -584,6 +583,7 @@ def create_merge_logs(invoice_by_customer, closing_entry=None):
merge_log.posting_time = ( merge_log.posting_time = (
get_time(closing_entry.get("posting_time")) if closing_entry else nowtime() get_time(closing_entry.get("posting_time")) if closing_entry else nowtime()
) )
merge_log.company = closing_entry.get("company") if closing_entry else None
merge_log.customer = customer merge_log.customer = customer
merge_log.pos_closing_entry = closing_entry.get("name") if closing_entry else None merge_log.pos_closing_entry = closing_entry.get("name") if closing_entry else None
merge_log.set("pos_invoices", _invoices) merge_log.set("pos_invoices", _invoices)

View File

@@ -491,3 +491,26 @@ class TestPOSInvoiceMergeLog(IntegrationTestCase):
self.assertTrue(frappe.db.exists("Sales Invoice", pos_inv3.consolidated_invoice)) self.assertTrue(frappe.db.exists("Sales Invoice", pos_inv3.consolidated_invoice))
self.assertTrue(pos_inv2.consolidated_invoice == pos_inv3.consolidated_invoice) self.assertTrue(pos_inv2.consolidated_invoice == pos_inv3.consolidated_invoice)
def test_company_in_pos_invoice_merge_log(self):
"""
Test if the company is fetched from POS Closing Entry
"""
test_user, pos_profile = init_user_and_profile()
opening_entry = create_opening_entry(pos_profile, test_user.name)
pos_inv = create_pos_invoice(rate=300, do_not_submit=1)
pos_inv.append("payments", {"mode_of_payment": "Cash", "account": "Cash - _TC", "amount": 300})
pos_inv.save()
pos_inv.submit()
closing_entry = make_closing_entry_from_opening(opening_entry)
closing_entry.insert()
closing_entry.submit()
self.assertTrue(frappe.db.exists("POS Invoice Merge Log", {"pos_closing_entry": closing_entry.name}))
pos_merge_log_company = frappe.db.get_value(
"POS Invoice Merge Log", {"pos_closing_entry": closing_entry.name}, "company"
)
self.assertEqual(pos_merge_log_company, closing_entry.company)

View File

@@ -424,3 +424,4 @@ execute:frappe.db.set_single_value("Accounts Settings", "confirm_before_resettin
erpnext.patches.v15_0.rename_pos_closing_entry_fields #2025-06-13 erpnext.patches.v15_0.rename_pos_closing_entry_fields #2025-06-13
erpnext.patches.v15_0.update_pegged_currencies erpnext.patches.v15_0.update_pegged_currencies
erpnext.patches.v15_0.set_status_cancelled_on_cancelled_pos_opening_entry_and_pos_closing_entry erpnext.patches.v15_0.set_status_cancelled_on_cancelled_pos_opening_entry_and_pos_closing_entry
erpnext.patches.v15_0.set_company_on_pos_inv_merge_log

View File

@@ -0,0 +1,12 @@
import frappe
def execute():
pos_invoice_merge_logs = frappe.db.get_all(
"POS Invoice Merge Log", {"docstatus": 1}, ["name", "pos_closing_entry"]
)
for log in pos_invoice_merge_logs:
if log.pos_closing_entry and frappe.db.exists("POS Closing Entry", log.pos_closing_entry):
company = frappe.db.get_value("POS Closing Entry", log.pos_closing_entry, "company")
frappe.db.set_value("POS Invoice Merge Log", log.name, "company", company)