changed field name, validation for change amount account, validation for serial no qty

This commit is contained in:
Rohit Waghchaure 2016-08-17 16:20:13 +05:30
parent baef2624a2
commit e4e69ec027
7 changed files with 52 additions and 27 deletions

View File

@ -720,14 +720,14 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "change_amount_account", "fieldname": "account_for_change_amount",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Change Amount Account", "label": "Account for Change Amount",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"options": "Account", "options": "Account",
@ -885,7 +885,7 @@
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2016-08-09 02:36:07.316464", "modified": "2016-08-17 15:12:56.713748",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "POS Profile", "name": "POS Profile",

View File

@ -270,13 +270,13 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
}, },
change_amount: function(){ change_amount: function(){
if((this.frm.doc.paid_amount - this.frm.doc.grand_total) < this.frm.doc.change_amount){ if(this.frm.doc.paid_amount > this.frm.doc.grand_total){
this.frm.set_value("change_amount", 0.0)
frappe.msgprint(__("You can not return change amount, limit has been exceeded"))
}else{
this.calculate_write_off_amount() this.calculate_write_off_amount()
this.frm.refresh_fields(); }else {
this.frm.set_value("change_amount", 0.0)
} }
this.frm.refresh_fields();
} }
}); });

View File

@ -2356,14 +2356,14 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"fieldname": "change_amount_account", "fieldname": "account_for_change_amount",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 0, "in_list_view": 0,
"label": "Change Amount Account", "label": "Account for Change Amount",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"options": "Account", "options": "Account",
@ -3751,7 +3751,7 @@
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"menu_index": 0, "menu_index": 0,
"modified": "2016-08-04 05:08:15.008493", "modified": "2016-08-17 15:12:39.357372",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Sales Invoice", "name": "Sales Invoice",

View File

@ -61,6 +61,7 @@ class SalesInvoice(SellingController):
self.clear_unallocated_advances("Sales Invoice Advance", "advances") self.clear_unallocated_advances("Sales Invoice Advance", "advances")
self.add_remarks() self.add_remarks()
self.validate_write_off_account() self.validate_write_off_account()
self.validate_account_for_change_amount()
self.validate_fixed_asset() self.validate_fixed_asset()
self.set_income_account_for_fixed_assets() self.set_income_account_for_fixed_assets()
@ -237,8 +238,8 @@ class SalesInvoice(SellingController):
pos_profile = frappe.get_doc('POS Profile', pos.name) if pos else None pos_profile = frappe.get_doc('POS Profile', pos.name) if pos else None
update_multi_mode_option(self, pos_profile) update_multi_mode_option(self, pos_profile)
if not self.change_amount_account: if not self.account_for_change_amount:
self.change_amount_account = frappe.db.get_value('Company', self.company, 'default_cash_account') self.account_for_change_amount = frappe.db.get_value('Company', self.company, 'default_cash_account')
if pos: if pos:
if not for_validate and not self.customer: if not for_validate and not self.customer:
@ -246,8 +247,8 @@ class SalesInvoice(SellingController):
self.mode_of_payment = pos.mode_of_payment self.mode_of_payment = pos.mode_of_payment
# self.set_customer_defaults() # self.set_customer_defaults()
if not self.change_amount_account: if pos.get('account_for_change_amount'):
self.change_amount_account = pos.get('change_amount_account') self.account_for_change_amount = pos.get('account_for_change_amount')
for fieldname in ('territory', 'naming_series', 'currency', 'taxes_and_charges', 'letter_head', 'tc_name', for fieldname in ('territory', 'naming_series', 'currency', 'taxes_and_charges', 'letter_head', 'tc_name',
'selling_price_list', 'company', 'select_print_heading', 'cash_bank_account', 'selling_price_list', 'company', 'select_print_heading', 'cash_bank_account',
@ -385,6 +386,9 @@ class SalesInvoice(SellingController):
if flt(self.write_off_amount) and not self.write_off_account: if flt(self.write_off_amount) and not self.write_off_account:
msgprint(_("Please enter Write Off Account"), raise_exception=1) msgprint(_("Please enter Write Off Account"), raise_exception=1)
def validate_account_for_change_amount(self):
if flt(self.change_amount) and not self.account_for_change_amount:
msgprint(_("Please enter Account for Change Amount"), raise_exception=1)
def validate_c_form(self): def validate_c_form(self):
""" Blank C-form no if C-form applicable marked as 'No'""" """ Blank C-form no if C-form applicable marked as 'No'"""
@ -614,13 +618,13 @@ class SalesInvoice(SellingController):
def make_gle_for_change_amount(self, gl_entries): def make_gle_for_change_amount(self, gl_entries):
if cint(self.is_pos) and self.change_amount: if cint(self.is_pos) and self.change_amount:
if self.change_amount_account: if self.account_for_change_amount:
gl_entries.append( gl_entries.append(
self.get_gl_dict({ self.get_gl_dict({
"account": self.debit_to, "account": self.debit_to,
"party_type": "Customer", "party_type": "Customer",
"party": self.customer, "party": self.customer,
"against": self.change_amount_account, "against": self.account_for_change_amount,
"debit": flt(self.base_change_amount), "debit": flt(self.base_change_amount),
"debit_in_account_currency": flt(self.base_change_amount) \ "debit_in_account_currency": flt(self.base_change_amount) \
if self.party_account_currency==self.company_currency else flt(self.change_amount), if self.party_account_currency==self.company_currency else flt(self.change_amount),
@ -631,7 +635,7 @@ class SalesInvoice(SellingController):
gl_entries.append( gl_entries.append(
self.get_gl_dict({ self.get_gl_dict({
"account": self.change_amount_account, "account": self.account_for_change_amount,
"against": self.customer, "against": self.customer,
"credit": self.base_change_amount "credit": self.base_change_amount
}) })

View File

@ -455,7 +455,7 @@ class TestSalesInvoice(unittest.TestCase):
self.pos_gl_entry(si, pos, 300) self.pos_gl_entry(si, pos, 300)
def test_pos_chnage_amount(self): def test_pos_change_amount(self):
set_perpetual_inventory() set_perpetual_inventory()
self.make_pos_profile() self.make_pos_profile()

View File

@ -188,8 +188,8 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
this.frm.doc.write_off_account = doc.write_off_account this.frm.doc.write_off_account = doc.write_off_account
} }
if(!this.frm.doc.change_amount_account){ if(!this.frm.doc.account_for_change_amount){
this.frm.doc.change_amount_account = doc.change_amount_account this.frm.doc.account_for_change_amount = doc.account_for_change_amount
} }
}, },
@ -486,11 +486,8 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
this.remove_item = [] this.remove_item = []
$.each(this.frm.doc["items"] || [], function(i, d) { $.each(this.frm.doc["items"] || [], function(i, d) {
if (d.item_code == item_code && d.serial_no if(d.serial_no){
&& field == 'qty' && cint(value) != value) { me.validate_serial_no_qty(d, item_code, field, value)
d.qty = 0.0;
me.refresh();
frappe.throw(__("Serial no item cannot be a fraction"))
} }
if (d.item_code == item_code) { if (d.item_code == item_code) {
@ -907,6 +904,23 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
} }
}, },
validate_serial_no_qty: function(args, item_code, field, value){
var me = this;
if (args.item_code == item_code && args.serial_no
&& field == 'qty' && cint(value) != value) {
args.qty = 0.0;
this.refresh();
frappe.throw(__("Serial no item cannot be a fraction"))
}
if(args.serial_no && args.serial_no.split('\n').length != cint(value)){
args.qty = 0.0;
args.serial_no = ''
this.refresh();
frappe.throw(__("Total nos of serial no is not equal to quantity."))
}
},
mandatory_batch_no: function(){ mandatory_batch_no: function(){
var me = this; var me = this;
if(this.items[0].has_batch_no && !this.item_batch_no[this.items[0].item_code]){ if(this.items[0].has_batch_no && !this.item_batch_no[this.items[0].item_code]){

View File

@ -137,12 +137,14 @@
font-size: 15px; font-size: 15px;
} }
.pos-payment-row .col-xs-6 { .pos-payment-row .col-xs-6 {
padding: 10px; padding: 15px;
} }
.pos-payment-row { .pos-payment-row {
border-bottom: 1px solid #d1d8dd; border-bottom: 1px solid #d1d8dd;
margin: 2px 0px 5px 0px; margin: 2px 0px 5px 0px;
height: 60px; height: 60px;
margin-top: 0px;
margin-bottom: 0px;
} }
.pos-payment-row:hover, .pos-payment-row:hover,
.pos-keyboard-key:hover { .pos-keyboard-key:hover {
@ -202,3 +204,8 @@ body[data-route="pos"] .modal-dialog {
.pos-invoice-list { .pos-invoice-list {
padding: 15px 10px; padding: 15px 10px;
} }
.write_off_amount,
.change_amount {
margin: 15px;
width: 130px;
}