diff --git a/erpnext/selling/doctype/pos_closing_voucher/pos_closing_voucher.js b/erpnext/selling/doctype/pos_closing_voucher/pos_closing_voucher.js index 13bd87867b..f24caf767f 100644 --- a/erpnext/selling/doctype/pos_closing_voucher/pos_closing_voucher.js +++ b/erpnext/selling/doctype/pos_closing_voucher/pos_closing_voucher.js @@ -76,6 +76,7 @@ var get_closing_voucher_details = function(frm) { refresh_field("grand_total"); refresh_field("net_total"); refresh_field("total_quantity"); + refresh_field("total_amount"); frm.get_field("payment_reconciliation_details").$wrapper.html(r.message); } diff --git a/erpnext/selling/doctype/pos_closing_voucher/pos_closing_voucher.json b/erpnext/selling/doctype/pos_closing_voucher/pos_closing_voucher.json index 0ebea83e60..2ac57794b4 100644 --- a/erpnext/selling/doctype/pos_closing_voucher/pos_closing_voucher.json +++ b/erpnext/selling/doctype/pos_closing_voucher/pos_closing_voucher.json @@ -39,7 +39,7 @@ "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, - "read_only": 0, + "read_only": 1, "remember_last_selected_value": 0, "report_hide": 0, "reqd": 1, @@ -72,7 +72,7 @@ "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, - "read_only": 0, + "read_only": 1, "remember_last_selected_value": 0, "report_hide": 0, "reqd": 1, @@ -958,7 +958,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2019-01-26 13:23:49.192650", + "modified": "2019-01-28 12:33:45.217813", "modified_by": "Administrator", "module": "Selling", "name": "POS Closing Voucher", diff --git a/erpnext/selling/doctype/pos_closing_voucher/pos_closing_voucher.py b/erpnext/selling/doctype/pos_closing_voucher/pos_closing_voucher.py index e7fc85e05a..c45571f57c 100644 --- a/erpnext/selling/doctype/pos_closing_voucher/pos_closing_voucher.py +++ b/erpnext/selling/doctype/pos_closing_voucher/pos_closing_voucher.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe +from frappe import _ from frappe.model.document import Document from collections import defaultdict from erpnext.controllers.taxes_and_totals import get_itemised_tax_breakup_data @@ -26,6 +27,7 @@ class POSClosingVoucher(Document): sales_summary = get_sales_summary(invoice_list) self.set_sales_summary_values(sales_summary) + self.total_amount = sales_summary['grand_total'] if not self.get('payment_reconciliation'): mop = get_mode_of_payment_details(invoice_list) @@ -36,6 +38,21 @@ class POSClosingVoucher(Document): return self.get_payment_reconciliation_details() + def validate(self): + user = frappe.get_all('POS Closing Voucher', + filters = { + 'user': self.user, + 'docstatus': 1 + }, + or_filters = { + 'period_start_date': ('between', [self.period_start_date, self.period_end_date]), + 'period_end_date': ('between', [self.period_start_date, self.period_end_date]) + }) + + if user: + frappe.throw(_("POS Closing Voucher alreday exists for {0} between date {1} and {2}" + .format(self.user, self.period_start_date, self.period_end_date))) + def set_invoice_list(self, invoice_list): self.sales_invoices_summary = [] for invoice in invoice_list: