diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json index d1e64bc520..e00f075f85 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json @@ -639,6 +639,126 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 1, + "collapsible_depends_on": "po_no", + "columns": 0, + "fieldname": "customer_po_details", + "fieldtype": "Section Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Customer PO Details", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 1, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "po_no", + "fieldtype": "Data", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Customer's Purchase Order", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 1, + "print_hide_if_no_value": 0, + "read_only": 1, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "column_break_23", + "fieldtype": "Column Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 1, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "po_date", + "fieldtype": "Date", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Customer's Purchase Order Date", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 1, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_bulk_edit": 0, "allow_on_submit": 0, @@ -4563,7 +4683,7 @@ "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2017-12-20 17:36:05.216046", + "modified": "2018-01-12 15:19:54.711885", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice", diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.html b/erpnext/accounts/report/accounts_receivable/accounts_receivable.html index 9d872a49f0..b622ab499e 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.html +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.html @@ -1,3 +1,11 @@ + +

{%= __(report.report_name) %}

{%= filters.customer || filters.supplier %}

@@ -6,17 +14,90 @@ {%= dateutil.str_to_user(filters.report_date) %}

+{% if(filters.show_pdc_in_print) { %} + {% var balance_row = data.slice(-1).pop(); + var range1 = report.columns[11].label; + var range2 = report.columns[12].label; + var range3 = report.columns[13].label; + var range4 = report.columns[14].label; + %} + {% if(balance_row) { %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
(Amount in {%= data[0][__("currency")] || "" %})
{%= __(" ") %}{%= __(range1) %}{%= __(range2) %}{%= __(range3) %}{%= __(range4) %}{%= __("Total") %}
{%= __("Total Outstanding") %}{%= format_currency(balance_row[range1]) %}{%= format_currency(balance_row[range2]) %}{%= format_currency(balance_row[range3]) %}{%= format_currency(balance_row[range4]) %} + {%= format_currency(flt(balance_row[__("Outstanding Amount")]), data[data.length-1]["currency"]) %} +
{%= __("PDC/LC") %} + {%= format_currency(flt(balance_row[__("PDC/LC Amount")]), data[data.length-1]["currency"]) %} +
+ {% } %} +{% } %} {% if(report.report_name === "Accounts Receivable" || report.report_name === "Accounts Payable") { %} - - - + + + - - - + {% if(!filters.show_pdc_in_print) { %} + + + {% } %} + + {% if(filters.show_pdc_in_print) { %} + {% if(report.report_name === "Accounts Receivable") { %} + + {% } %} + + + + {% } %} {% } else { %} @@ -48,23 +129,49 @@ - - + + {% if(!filters.show_pdc_in_print) { %} + + + {% } %} + + {% if(filters.show_pdc_in_print) { %} + {% if(report.report_name === "Accounts Receivable") { %} + + {% } %} + + + + {% } %} {% } else { %} - - + + {% if(!filters.show_pdc_in_print) { %} + + + {% } %} + + {% if(filters.show_pdc_in_print) { %} + {% if(report.report_name === "Accounts Receivable") { %} + + {% } %} + + + + {% } %} {% } %} {% } else { %} {% if(data[i][__("Customer")] || data[i][__("Supplier")]|| " ") { %} diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.js b/erpnext/accounts/report/accounts_receivable/accounts_receivable.js index fd5241b1ff..67483984b9 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.js +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.js @@ -64,6 +64,11 @@ frappe.query_reports["Accounts Receivable"] = { "fieldtype": "Int", "default": "90", "reqd": 1 + }, + { + "fieldname":"show_pdc_in_print", + "label": __("Show PDC in Print"), + "fieldtype": "Check", } ], diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index 0732b7dc09..e046755b15 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -72,6 +72,18 @@ class ReceivablePayableReport(object): "options": "Currency", "width": 100 }) + + columns += [ + _("PDC/LC Date") + ":Date:110", + _("PDC/LC Ref") + ":Data:110", + _("PDC/LC Amount") + ":Currency/currency:130", + _("Remaining Balance") + ":Currency/currency:130" + ] + + if args.get('party_type') == 'Customer': + columns += [_("Customer LPO") + ":Data:100"] + columns += [_("Delivery Note") + ":Data:100"] + if args.get("party_type") == "Customer": columns += [ _("Territory") + ":Link/Territory:80", @@ -89,7 +101,8 @@ class ReceivablePayableReport(object): currency_precision = get_currency_precision() or 2 dr_or_cr = "debit" if args.get("party_type") == "Customer" else "credit" - voucher_details = self.get_voucher_details(args.get("party_type")) + dn_details = get_dn_details(args.get("party_type")) + voucher_details = self.get_voucher_details(args.get("party_type"), dn_details) future_vouchers = self.get_entries_after(self.filters.report_date, args.get("party_type")) @@ -101,6 +114,8 @@ class ReceivablePayableReport(object): return_entries = self.get_return_entries(args.get("party_type")) data = [] + pdc_details = get_pdc_details(args.get("party_type")) + for gle in self.get_entries_till(self.filters.report_date, args.get("party_type")): if self.is_receivable_or_payable(gle, dr_or_cr, future_vouchers): outstanding_amount, credit_note_amount = self.get_outstanding_amount(gle, @@ -144,6 +159,18 @@ class ReceivablePayableReport(object): else: row.append(company_currency) + pdc = pdc_details.get(gle.voucher_no, {}) + remaining_balance = outstanding_amount - flt(pdc.get("pdc_amount")) + row += [pdc.get("pdc_date"), pdc.get("pdc_ref"), + flt(pdc.get("pdc_amount")), remaining_balance] + + if args.get('party_type') == 'Customer': + # customer LPO + row += [voucher_details.get(gle.voucher_no, {}).get("po_no")] + + # Delivery Note + row += [voucher_details.get(gle.voucher_no, {}).get("delivery_note")] + # customer territory / supplier type if args.get("party_type") == "Customer": row += [self.get_territory(gle.party), self.get_customer_group(gle.party)] @@ -225,12 +252,13 @@ class ReceivablePayableReport(object): return self.party_map - def get_voucher_details(self, party_type): + def get_voucher_details(self, party_type, dn_details): voucher_details = frappe._dict() if party_type == "Customer": - for si in frappe.db.sql("""select name, due_date + for si in frappe.db.sql("""select name, due_date, po_no from `tabSales Invoice` where docstatus=1""", as_dict=1): + si['delivery_note'] = dn_details.get(si.name) voucher_details.setdefault(si.name, si) if party_type == "Supplier": @@ -347,3 +375,39 @@ def get_ageing_data(first_range, second_range, third_range, age_as_on, entry_dat outstanding_range[index] = outstanding_amount return [age] + outstanding_range + +def get_pdc_details(party_type): + pdc_details = frappe._dict() + + for pdc in frappe.db.sql(""" + select + pref.reference_name as invoice_no, pent.party, pent.party_type, + max(pent.reference_date) as pdc_date, sum(ifnull(pref.allocated_amount,0)) as pdc_amount, + GROUP_CONCAT(pent.reference_no SEPARATOR ', ') as pdc_ref + from + `tabPayment Entry` as pent inner join `tabPayment Entry Reference` as pref + on + (pref.parent = pent.name) + where + pent.docstatus = 0 and pent.reference_date > pent.posting_date + and pent.party_type = %s + group by pref.reference_name""", party_type, as_dict=1): + pdc_details.setdefault(pdc.invoice_no, pdc) + + return pdc_details + +def get_dn_details(party_type): + dn_details = frappe._dict() + + if party_type == "Customer": + for si in frappe.db.sql("""select parent, GROUP_CONCAT(delivery_note SEPARATOR ', ') as dn + from `tabSales Invoice Item` + where docstatus=1 and delivery_note is not null and delivery_note != '' group by parent + Union + select against_sales_invoice as parent, GROUP_CONCAT(parent SEPARATOR ', ') as dn + from `tabDelivery Note Item` + where docstatus=1 and against_sales_invoice is not null + and against_sales_invoice != '' group by against_sales_invoice""", as_dict=1): + dn_details.setdefault(si.parent, si.dn) + + return dn_details diff --git a/erpnext/selling/doctype/sales_order/sales_order.json b/erpnext/selling/doctype/sales_order/sales_order.json index 7c23687eef..f302c1cd1c 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.json +++ b/erpnext/selling/doctype/sales_order/sales_order.json @@ -3529,8 +3529,8 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2017-12-19 14:51:52.710612", - "modified_by": "nabinhait@gmail.com", + "modified": "2018-01-12 15:56:12.483019", + "modified_by": "Administrator", "module": "Selling", "name": "Sales Order", "owner": "Administrator", diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index 42cde9f2fd..084a218005 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -476,13 +476,10 @@ def make_project(source_name, target_doc=None): @frappe.whitelist() def make_delivery_note(source_name, target_doc=None): def set_missing_values(source, target): - if source.po_no: - if target.po_no: - target_po_no = target.po_no.split(", ") - target_po_no.append(source.po_no) - target.po_no = ", ".join(list(set(target_po_no))) if len(target_po_no) > 1 else target_po_no[0] - else: - target.po_no = source.po_no + so = [d.against_sales_order for d in target.items] + if so: + po_no_list = frappe.get_all('Sales Order', 'po_no', filters = {'name': ('in', so)}) + target.po_no = ', '.join(d.po_no for d in po_no_list if d.po_no) target.ignore_pricing_rule = 1 target.run_method("set_missing_values") diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.json b/erpnext/stock/doctype/delivery_note/delivery_note.json index 1f944e46f4..f126b581d9 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.json +++ b/erpnext/stock/doctype/delivery_note/delivery_note.json @@ -398,73 +398,6 @@ "set_only_once": 0, "unique": 0 }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "po_no", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Customer's Purchase Order No", - "length": 0, - "no_copy": 0, - "oldfieldname": "po_no", - "oldfieldtype": "Data", - "permlevel": 0, - "print_hide": 1, - "print_hide_if_no_value": 0, - "print_width": "100px", - "read_only": 1, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0, - "width": "100px" - }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:doc.po_no", - "fieldname": "po_date", - "fieldtype": "Date", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Customer's Purchase Order Date", - "length": 0, - "no_copy": 0, - "oldfieldname": "po_date", - "oldfieldtype": "Data", - "permlevel": 0, - "print_hide": 1, - "print_hide_if_no_value": 0, - "print_width": "100px", - "read_only": 1, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0, - "width": "100px" - }, { "allow_bulk_edit": 0, "allow_on_submit": 0, @@ -527,6 +460,133 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 1, + "collapsible_depends_on": "po_no", + "columns": 0, + "fieldname": "customer_po_details", + "fieldtype": "Section Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Customer PO Details", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "po_no", + "fieldtype": "Data", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Customer's Purchase Order No", + "length": 0, + "no_copy": 0, + "oldfieldname": "po_no", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_hide_if_no_value": 0, + "print_width": "100px", + "read_only": 1, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0, + "width": "100px" + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "column_break_17", + "fieldtype": "Column Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "depends_on": "eval:doc.po_no", + "fieldname": "po_date", + "fieldtype": "Date", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Customer's Purchase Order Date", + "length": 0, + "no_copy": 0, + "oldfieldname": "po_date", + "oldfieldtype": "Data", + "permlevel": 0, + "print_hide": 1, + "print_hide_if_no_value": 0, + "print_width": "100px", + "read_only": 1, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0, + "width": "100px" + }, { "allow_bulk_edit": 0, "allow_on_submit": 0, @@ -3641,7 +3701,7 @@ "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2017-11-29 14:13:32.770027", + "modified": "2018-01-12 15:27:44.471335", "modified_by": "Administrator", "module": "Stock", "name": "Delivery Note",
{%= __("Date") %}{%= __("Ref") %}{%= (filters.customer || filters.supplier) ? __("Remarks"): __("Party") %}{%= __("Date") %}{%= __("Ref") %}{%= (filters.customer || filters.supplier) ? __("Remarks"): __("Party") %} {%= __("Invoiced Amount") %}{%= __("Paid Amount") %}{%= report.report_name === "Accounts Receivable" ? __('Credit Note') : __('Debit Note') %}{%= __("Outstanding Amount") %}{%= __("Paid Amount") %}{%= report.report_name === "Accounts Receivable" ? __('Credit Note') : __('Debit Note') %}{%= __("Outstanding Amount") %}{%= __("Customer LPO No.") %}{%= __("PDC/LC Date") %}{%= __("PDC/LC Ref") %}{%= __("PDC/LC Amount") %}{%= (filters.customer || filters.supplier) ? __("Remarks"): __("Party") %} {%= __("Total Invoiced Amount") %} {%= format_currency(data[i]["Invoiced Amount"], data[i]["currency"]) %} - {%= format_currency(data[i]["Paid Amount"], data[i]["currency"]) %} - {%= report.report_name === "Accounts Receivable" ? format_currency(data[i]["Credit Note"], data[i]["currency"]) : format_currency(data[i]["Debit Note"], data[i]["currency"]) %} + {%= format_currency(data[i]["Paid Amount"], data[i]["currency"]) %} + {%= report.report_name === "Accounts Receivable" ? format_currency(data[i]["Credit Note"], data[i]["currency"]) : format_currency(data[i]["Debit Note"], data[i]["currency"]) %} {%= format_currency(data[i]["Outstanding Amount"], data[i]["currency"]) %} + {%= data[i][__("Customer LPO")] %}{%= frappe.datetime.str_to_user(data[i][__("PDC/LC Date")]) %}{%= data[i][__("PDC/LC Ref")] %}{%= format_currency(data[i][__("PDC/LC Amount")], data[i]["currency"]) %} {%= __("Total") %} {%= format_currency(data[i]["Invoiced Amount"], data[i]["currency"] ) %} - {%= format_currency(data[i]["Paid Amount"], data[i]["currency"]) %}{%= report.report_name === "Accounts Receivable" ? format_currency(data[i]["Credit Note"], data[i]["currency"]) : format_currency(data[i]["Debit Note"], data[i]["currency"]) %} + {%= format_currency(data[i]["Paid Amount"], data[i]["currency"]) %}{%= report.report_name === "Accounts Receivable" ? format_currency(data[i]["Credit Note"], data[i]["currency"]) : format_currency(data[i]["Debit Note"], data[i]["currency"]) %} {%= format_currency(data[i]["Outstanding Amount"], data[i]["currency"]) %} + {%= data[i][__("Customer LPO")] %}{%= frappe.datetime.str_to_user(data[i][__("PDC/LC Date")]) %}{%= data[i][__("PDC/LC Ref")] %}{%= format_currency(data[i][__("PDC/LC Amount")], data[i]["currency"]) %}