changed field name, validation for change amount account, validation for serial no qty
diff --git a/erpnext/accounts/doctype/pos_profile/pos_profile.json b/erpnext/accounts/doctype/pos_profile/pos_profile.json
index 0ab48e2..01a87c4 100644
--- a/erpnext/accounts/doctype/pos_profile/pos_profile.json
+++ b/erpnext/accounts/doctype/pos_profile/pos_profile.json
@@ -720,14 +720,14 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
- "fieldname": "change_amount_account",
+ "fieldname": "account_for_change_amount",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
- "label": "Change Amount Account",
+ "label": "Account for Change Amount",
"length": 0,
"no_copy": 0,
"options": "Account",
@@ -885,7 +885,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2016-08-09 02:36:07.316464",
+ "modified": "2016-08-17 15:12:56.713748",
"modified_by": "Administrator",
"module": "Accounts",
"name": "POS Profile",
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
index 1191871..3245e78 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
@@ -270,13 +270,13 @@
},
change_amount: function(){
- if((this.frm.doc.paid_amount - this.frm.doc.grand_total) < this.frm.doc.change_amount){
- this.frm.set_value("change_amount", 0.0)
- frappe.msgprint(__("You can not return change amount, limit has been exceeded"))
- }else{
+ if(this.frm.doc.paid_amount > this.frm.doc.grand_total){
this.calculate_write_off_amount()
- this.frm.refresh_fields();
+ }else {
+ this.frm.set_value("change_amount", 0.0)
}
+
+ this.frm.refresh_fields();
}
});
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
index df7f89e..a2e930c 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
@@ -2356,14 +2356,14 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
- "fieldname": "change_amount_account",
+ "fieldname": "account_for_change_amount",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
- "label": "Change Amount Account",
+ "label": "Account for Change Amount",
"length": 0,
"no_copy": 0,
"options": "Account",
@@ -3751,7 +3751,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
- "modified": "2016-08-04 05:08:15.008493",
+ "modified": "2016-08-17 15:12:39.357372",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice",
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index cdf9bd8..871a151 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -61,6 +61,7 @@
self.clear_unallocated_advances("Sales Invoice Advance", "advances")
self.add_remarks()
self.validate_write_off_account()
+ self.validate_account_for_change_amount()
self.validate_fixed_asset()
self.set_income_account_for_fixed_assets()
@@ -237,8 +238,8 @@
pos_profile = frappe.get_doc('POS Profile', pos.name) if pos else None
update_multi_mode_option(self, pos_profile)
- if not self.change_amount_account:
- self.change_amount_account = frappe.db.get_value('Company', self.company, 'default_cash_account')
+ if not self.account_for_change_amount:
+ self.account_for_change_amount = frappe.db.get_value('Company', self.company, 'default_cash_account')
if pos:
if not for_validate and not self.customer:
@@ -246,8 +247,8 @@
self.mode_of_payment = pos.mode_of_payment
# self.set_customer_defaults()
- if not self.change_amount_account:
- self.change_amount_account = pos.get('change_amount_account')
+ if pos.get('account_for_change_amount'):
+ 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',
'selling_price_list', 'company', 'select_print_heading', 'cash_bank_account',
@@ -385,6 +386,9 @@
if flt(self.write_off_amount) and not self.write_off_account:
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):
""" Blank C-form no if C-form applicable marked as 'No'"""
@@ -614,13 +618,13 @@
def make_gle_for_change_amount(self, gl_entries):
if cint(self.is_pos) and self.change_amount:
- if self.change_amount_account:
+ if self.account_for_change_amount:
gl_entries.append(
self.get_gl_dict({
"account": self.debit_to,
"party_type": "Customer",
"party": self.customer,
- "against": self.change_amount_account,
+ "against": self.account_for_change_amount,
"debit": 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),
@@ -631,7 +635,7 @@
gl_entries.append(
self.get_gl_dict({
- "account": self.change_amount_account,
+ "account": self.account_for_change_amount,
"against": self.customer,
"credit": self.base_change_amount
})
diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
index db129de..1bb7b1c 100644
--- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
@@ -455,7 +455,7 @@
self.pos_gl_entry(si, pos, 300)
- def test_pos_chnage_amount(self):
+ def test_pos_change_amount(self):
set_perpetual_inventory()
self.make_pos_profile()
diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js
index fd76d51..850564c 100644
--- a/erpnext/accounts/page/pos/pos.js
+++ b/erpnext/accounts/page/pos/pos.js
@@ -188,8 +188,8 @@
this.frm.doc.write_off_account = doc.write_off_account
}
- if(!this.frm.doc.change_amount_account){
- this.frm.doc.change_amount_account = doc.change_amount_account
+ if(!this.frm.doc.account_for_change_amount){
+ this.frm.doc.account_for_change_amount = doc.account_for_change_amount
}
},
@@ -486,11 +486,8 @@
this.remove_item = []
$.each(this.frm.doc["items"] || [], function(i, d) {
- if (d.item_code == item_code && d.serial_no
- && field == 'qty' && cint(value) != value) {
- d.qty = 0.0;
- me.refresh();
- frappe.throw(__("Serial no item cannot be a fraction"))
+ if(d.serial_no){
+ me.validate_serial_no_qty(d, item_code, field, value)
}
if (d.item_code == item_code) {
@@ -907,6 +904,23 @@
}
},
+ 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(){
var me = this;
if(this.items[0].has_batch_no && !this.item_batch_no[this.items[0].item_code]){
diff --git a/erpnext/public/css/erpnext.css b/erpnext/public/css/erpnext.css
index b8d51c0..475b44b 100644
--- a/erpnext/public/css/erpnext.css
+++ b/erpnext/public/css/erpnext.css
@@ -137,12 +137,14 @@
font-size: 15px;
}
.pos-payment-row .col-xs-6 {
- padding: 10px;
+ padding: 15px;
}
.pos-payment-row {
border-bottom: 1px solid #d1d8dd;
margin: 2px 0px 5px 0px;
height: 60px;
+ margin-top: 0px;
+ margin-bottom: 0px;
}
.pos-payment-row:hover,
.pos-keyboard-key:hover {
@@ -202,3 +204,8 @@
.pos-invoice-list {
padding: 15px 10px;
}
+.write_off_amount,
+.change_amount {
+ margin: 15px;
+ width: 130px;
+}