feat: generate file name
diff --git a/erpnext/accounts/doctype/payment_order/regional/india.js b/erpnext/accounts/doctype/payment_order/regional/india.js
index e92145c..598223d 100644
--- a/erpnext/accounts/doctype/payment_order/regional/india.js
+++ b/erpnext/accounts/doctype/payment_order/regional/india.js
@@ -11,7 +11,7 @@
return frappe.call({
method: "erpnext.regional.india.bank_remittance_txt.generate_report",
args: {
- name: frm.doc.name,
+ name: frm.doc.name
},
freeze: true,
callback: function(r) {
diff --git a/erpnext/regional/india/bank_remittance_txt.py b/erpnext/regional/india/bank_remittance_txt.py
index 83f49fe..0fc7ce6 100644
--- a/erpnext/regional/india/bank_remittance_txt.py
+++ b/erpnext/regional/india/bank_remittance_txt.py
@@ -18,7 +18,7 @@
no_of_records = len(payment_order.get("references"))
total_amount = reduce(lambda x, y: x.get("amount") + y.get("amount"), payment_order.get("references"))
- header = get_header_row(payment_order)
+ header, file_name = get_header_row(payment_order)
batch = get_batch_row(payment_order, no_of_records, total_amount)
detail = []
@@ -28,12 +28,12 @@
trailer = get_trailer_row(no_of_records, total_amount)
detail_records = "\n".join(detail)
- return "\n".join([header, batch , detail_records, trailer])
+ return "\n".join([header, batch , detail_records, trailer]), file_name
@frappe.whitelist()
def generate_report(name):
- data = create_bank_remittance_txt(name)
- file_name = generate_file_name(name)
+ data, file_name = create_bank_remittance_txt(name)
+
f = frappe.get_doc({
'doctype': 'File',
'file_name': file_name+'.txt',
@@ -45,18 +45,18 @@
f.save()
download_file(f.file_url)
-def generate_file_name(name):
+def generate_file_name(name, date):
''' generate file name with format (account_code)_mmdd_(payment_order_no) '''
- return name
+ return date.strftime("%m%d")+sanitize_to_alphanumeric(name)
def get_header_row(doc):
client_code = "ELECTROLAB"
- file_name = generate_file_name(doc.name)
+ file_name = generate_file_name(doc.name, doc.posting_date)
header = ["H"]
header.append(cstr(client_code)[:20])
header += [''] * 3
header.append(cstr(file_name)[:20])
- return "~".join(header)
+ return "~".join(header), file_name
def get_batch_row(doc, no_of_records, total_amount):
product_code = "VENPAY"
@@ -78,7 +78,7 @@
'parenttype':'Address',
'parent': ('like', '%-Billing')
},'parent')
- supplier_billing_address = frappe.get_doc('Address', addr_link)
+ supplier_billing_address = frappe.get_cached_doc('Address', addr_link)
detail = OrderedDict(
record_identifier='D',
payment_ref_no=sanitize_to_alphanumeric(ref_doc.payment_entry),