fix: Made period fields read only and added validation for multiple entries by same user

This commit is contained in:
deepeshgarg007 2019-01-28 12:45:11 +05:30
parent 4e4b200972
commit 0bee62b460
3 changed files with 21 additions and 3 deletions

View File

@ -76,6 +76,7 @@ var get_closing_voucher_details = function(frm) {
refresh_field("grand_total"); refresh_field("grand_total");
refresh_field("net_total"); refresh_field("net_total");
refresh_field("total_quantity"); refresh_field("total_quantity");
refresh_field("total_amount");
frm.get_field("payment_reconciliation_details").$wrapper.html(r.message); frm.get_field("payment_reconciliation_details").$wrapper.html(r.message);
} }

View File

@ -39,7 +39,7 @@
"precision": "", "precision": "",
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 1,
"remember_last_selected_value": 0, "remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 1, "reqd": 1,
@ -72,7 +72,7 @@
"precision": "", "precision": "",
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 1,
"remember_last_selected_value": 0, "remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 1, "reqd": 1,
@ -958,7 +958,7 @@
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2019-01-26 13:23:49.192650", "modified": "2019-01-28 12:33:45.217813",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Selling", "module": "Selling",
"name": "POS Closing Voucher", "name": "POS Closing Voucher",

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe import _
from frappe.model.document import Document from frappe.model.document import Document
from collections import defaultdict from collections import defaultdict
from erpnext.controllers.taxes_and_totals import get_itemised_tax_breakup_data 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) sales_summary = get_sales_summary(invoice_list)
self.set_sales_summary_values(sales_summary) self.set_sales_summary_values(sales_summary)
self.total_amount = sales_summary['grand_total']
if not self.get('payment_reconciliation'): if not self.get('payment_reconciliation'):
mop = get_mode_of_payment_details(invoice_list) mop = get_mode_of_payment_details(invoice_list)
@ -36,6 +38,21 @@ class POSClosingVoucher(Document):
return self.get_payment_reconciliation_details() 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): def set_invoice_list(self, invoice_list):
self.sales_invoices_summary = [] self.sales_invoices_summary = []
for invoice in invoice_list: for invoice in invoice_list: