diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index c433ddb33c..cde4c0e70f 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -2,7 +2,7 @@
from __future__ import unicode_literals
import frappe
-__version__ = '7.0.28'
+__version__ = '7.0.29'
def get_default_company(user=None):
'''Get default company for user'''
diff --git a/erpnext/accounts/doctype/pos_profile/pos_profile.json b/erpnext/accounts/doctype/pos_profile/pos_profile.json
index cb637d254a..01a87c42e7 100644
--- a/erpnext/accounts/doctype/pos_profile/pos_profile.json
+++ b/erpnext/accounts/doctype/pos_profile/pos_profile.json
@@ -118,6 +118,32 @@
"set_only_once": 0,
"unique": 0
},
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "fieldname": "campaign",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "Campaign",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Campaign",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
{
"allow_on_submit": 0,
"bold": 0,
@@ -690,6 +716,32 @@
"set_only_once": 0,
"unique": 0
},
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "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": "Account for Change Amount",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Account",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
{
"allow_on_submit": 0,
"bold": 0,
@@ -833,7 +885,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2016-08-06 17:05:59.990031",
+ "modified": "2016-08-17 15:12:56.713748",
"modified_by": "Administrator",
"module": "Accounts",
"name": "POS Profile",
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
index c655626b86..c51231e881 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
@@ -232,7 +232,8 @@ cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
cur_frm.fields_dict['items'].grid.get_field("item_code").get_query = function(doc, cdt, cdn) {
return {
- query: "erpnext.controllers.queries.item_query"
+ query: "erpnext.controllers.queries.item_query",
+ filters: {'is_purchase_item': 1}
}
}
diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges_template/purchase_taxes_and_charges_template.js b/erpnext/accounts/doctype/purchase_taxes_and_charges_template/purchase_taxes_and_charges_template.js
index 433cda7372..a1d8bf85d2 100644
--- a/erpnext/accounts/doctype/purchase_taxes_and_charges_template/purchase_taxes_and_charges_template.js
+++ b/erpnext/accounts/doctype/purchase_taxes_and_charges_template/purchase_taxes_and_charges_template.js
@@ -18,3 +18,13 @@ frappe.ui.form.on("Purchase Taxes and Charges", "add_deduct_tax", function(doc,
}
refresh_field('add_deduct_tax', d.name, 'taxes');
});
+
+frappe.ui.form.on("Purchase Taxes and Charges", "category", function(doc, cdt, cdn) {
+ var d = locals[cdt][cdn];
+
+ if (d.category != 'Total' && d.add_deduct_tax == 'Deduct') {
+ msgprint(__("Cannot deduct when category is for 'Valuation' or 'Vaulation and Total'"));
+ d.add_deduct_tax = '';
+ }
+ refresh_field('add_deduct_tax', d.name, 'taxes');
+});
diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py
index 33032bf1e9..df0874bce4 100644
--- a/erpnext/accounts/doctype/sales_invoice/pos.py
+++ b/erpnext/accounts/doctype/sales_invoice/pos.py
@@ -35,7 +35,6 @@ def get_pos_data():
'customers': get_customers(pos_profile, doc),
'pricing_rules': get_pricing_rules(doc),
'print_template': print_template,
- 'write_off_account': pos_profile.get('write_off_account'),
'meta': {
'invoice': frappe.get_meta('Sales Invoice'),
'items': frappe.get_meta('Sales Invoice Item'),
@@ -45,7 +44,12 @@ def get_pos_data():
def update_pos_profile_data(doc, pos_profile):
company_data = frappe.db.get_value('Company', doc.company, '*', as_dict=1)
+ doc.campaign = pos_profile.get('campaign')
+ doc.write_off_account = pos_profile.get('write_off_account') or \
+ company_data.write_off_account
+ doc.change_amount_account = pos_profile.get('change_amount_account') or \
+ company_data.default_cash_account
doc.taxes_and_charges = pos_profile.get('taxes_and_charges')
if doc.taxes_and_charges:
update_tax_table(doc)
@@ -54,7 +58,8 @@ def update_pos_profile_data(doc, pos_profile):
doc.conversion_rate = 1.0
if doc.currency != company_data.default_currency:
doc.conversion_rate = get_exchange_rate(doc.currency, company_data.default_currency)
- doc.selling_price_list = pos_profile.get('selling_price_list') or frappe.db.get_value('Selling Settings', None, 'selling_price_list')
+ doc.selling_price_list = pos_profile.get('selling_price_list') or \
+ frappe.db.get_value('Selling Settings', None, 'selling_price_list')
doc.naming_series = pos_profile.get('naming_series') or 'SINV-'
doc.letter_head = pos_profile.get('letter_head') or company_data.default_letter_head
doc.ignore_pricing_rule = pos_profile.get('ignore_pricing_rule') or 0
@@ -157,10 +162,11 @@ def get_customers(pos_profile, doc):
def get_pricing_rules(doc):
pricing_rules = ""
if doc.ignore_pricing_rule == 0:
- pricing_rules = frappe.db.sql(""" Select * from `tabPricing Rule` where docstatus < 2 and disable = 0
- and selling = 1 and ifnull(company, '') in (%(company)s, '') and
- ifnull(for_price_list, '') in (%(price_list)s, '') and %(date)s between
- ifnull(valid_from, '2000-01-01') and ifnull(valid_upto, '2500-12-31') order by priority desc, name desc""",
+ pricing_rules = frappe.db.sql(""" Select * from `tabPricing Rule` where docstatus < 2
+ and ifnull(for_price_list, '') in (%(price_list)s, '') and selling = 1
+ and ifnull(company, '') in (%(company)s, '') and disable = 0 and %(date)s
+ between ifnull(valid_from, '2000-01-01') and ifnull(valid_upto, '2500-12-31')
+ order by priority desc, name desc""",
{'company': doc.company, 'price_list': doc.selling_price_list, 'date': nowdate()}, as_dict=1)
return pricing_rules
@@ -173,9 +179,9 @@ def make_invoice(doc_list):
for docs in doc_list:
for name, doc in docs.items():
- if not frappe.db.exists('Sales Invoice', {'offline_pos_name': name}):
- validate_customer(doc)
- validate_item(doc)
+ if not frappe.db.exists('Sales Invoice',
+ {'offline_pos_name': name, 'docstatus': ("<", "2")}):
+ validate_records(doc)
si_doc = frappe.new_doc('Sales Invoice')
si_doc.offline_pos_name = name
si_doc.update(doc)
@@ -186,6 +192,10 @@ def make_invoice(doc_list):
return name_list
+def validate_records(doc):
+ validate_customer(doc)
+ validate_item(doc)
+
def validate_customer(doc):
if not frappe.db.exists('Customer', doc.get('customer')):
customer_doc = frappe.new_doc('Customer')
@@ -197,8 +207,6 @@ def validate_customer(doc):
frappe.db.commit()
doc['customer'] = customer_doc.name
- return doc
-
def validate_item(doc):
for item in doc.get('items'):
if not frappe.db.exists('Item', item.get('item_code')):
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
index b73673fe94..3245e78e13 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
@@ -267,6 +267,16 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
amount: function(){
this.write_off_outstanding_amount_automatically()
+ },
+
+ change_amount: function(){
+ if(this.frm.doc.paid_amount > this.frm.doc.grand_total){
+ this.calculate_write_off_amount()
+ }else {
+ this.frm.set_value("change_amount", 0.0)
+ }
+
+ this.frm.refresh_fields();
}
});
@@ -458,7 +468,7 @@ frappe.ui.form.on('Sales Invoice', {
]
}
}
- },
+ }
})
frappe.ui.form.on('Sales Invoice Timesheet', {
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
index 06bc6359b9..a2e930c820 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
@@ -2200,32 +2200,6 @@
"set_only_once": 0,
"unique": 0
},
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "fieldname": "base_change_amount",
- "fieldtype": "Currency",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Base Change Amount (Company Currency)",
- "length": 0,
- "no_copy": 1,
- "options": "Company:company:default_currency",
- "permlevel": 0,
- "precision": "",
- "print_hide": 1,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
{
"allow_on_submit": 0,
"bold": 0,
@@ -2278,6 +2252,80 @@
"set_only_once": 0,
"unique": 0
},
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "fieldname": "section_break_88",
+ "fieldtype": "Section Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "fieldname": "base_change_amount",
+ "fieldtype": "Currency",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "Base Change Amount (Company Currency)",
+ "length": 0,
+ "no_copy": 1,
+ "options": "Company:company:default_currency",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "print_hide_if_no_value": 0,
+ "read_only": 1,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "fieldname": "column_break_90",
+ "fieldtype": "Column Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
{
"allow_on_submit": 0,
"bold": 0,
@@ -2297,7 +2345,33 @@
"precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
- "read_only": 1,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "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": "Account for Change Amount",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Account",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -3677,7 +3751,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
- "modified": "2016-08-03 11:50:49.680278",
+ "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 f055140348..871a1512e0 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -61,6 +61,7 @@ class SalesInvoice(SellingController):
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()
@@ -233,12 +234,22 @@ class SalesInvoice(SellingController):
from erpnext.stock.get_item_details import get_pos_profile_item_details, get_pos_profile
pos = get_pos_profile(self.company)
+ if not self.get('payments'):
+ pos_profile = frappe.get_doc('POS Profile', pos.name) if pos else None
+ update_multi_mode_option(self, pos_profile)
+
+ 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:
self.customer = pos.customer
self.mode_of_payment = pos.mode_of_payment
# self.set_customer_defaults()
+ 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',
'write_off_account', 'write_off_cost_center'):
@@ -265,10 +276,6 @@ class SalesInvoice(SellingController):
if self.taxes_and_charges and not len(self.get("taxes")):
self.set_taxes()
- if not self.get('payments'):
- pos_profile = frappe.get_doc('POS Profile', pos.name)
- update_multi_mode_option(self, pos_profile)
-
return pos
def get_company_abbr(self):
@@ -379,6 +386,9 @@ class SalesInvoice(SellingController):
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'"""
@@ -502,7 +512,7 @@ class SalesInvoice(SellingController):
gl_entries = merge_similar_entries(gl_entries)
self.make_pos_gl_entries(gl_entries)
- self.make_gle_for_change(gl_entries)
+ self.make_gle_for_change_amount(gl_entries)
self.make_write_off_gl_entry(gl_entries)
@@ -606,16 +616,15 @@ class SalesInvoice(SellingController):
}, payment_mode_account_currency)
)
- def make_gle_for_change(self, gl_entries):
+ def make_gle_for_change_amount(self, gl_entries):
if cint(self.is_pos) and self.change_amount:
- cash_account = self.get_cash_account()
- if cash_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": cash_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),
@@ -626,22 +635,13 @@ class SalesInvoice(SellingController):
gl_entries.append(
self.get_gl_dict({
- "account": cash_account,
+ "account": self.account_for_change_amount,
"against": self.customer,
"credit": self.base_change_amount
})
)
-
-
- def get_cash_account(self):
- cash_account = [d.account for d in self.payments if d.type=="Cash"]
- if cash_account:
- cash_account = cash_account[0]
- else:
- cash_account = frappe.db.get_value("Account",
- filters={"company": self.company, "account_type": "Cash", "is_group": 0})
-
- return cash_account
+ else:
+ frappe.throw(_("Select change amount account"), title="Mandatory Field")
def make_write_off_gl_entry(self, gl_entries):
# write off entries, applicable if only pos
diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
index dd28059c43..1bb7b1c2ac 100644
--- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
@@ -455,6 +455,25 @@ class TestSalesInvoice(unittest.TestCase):
self.pos_gl_entry(si, pos, 300)
+ def test_pos_change_amount(self):
+ set_perpetual_inventory()
+ self.make_pos_profile()
+
+ self._insert_purchase_receipt()
+ pos = copy.deepcopy(test_records[1])
+ pos["is_pos"] = 1
+ pos["update_stock"] = 1
+ pos["payments"] = [{'mode_of_payment': 'Bank Draft', 'account': '_Test Bank - _TC', 'amount': 300},
+ {'mode_of_payment': 'Cash', 'account': 'Cash - _TC', 'amount': 340}]
+
+ si = frappe.copy_doc(pos)
+ si.change_amount = 5.0
+ si.insert()
+ si.submit()
+
+ self.assertEquals(si.grand_total, 630.0)
+ self.assertEquals(si.write_off_amount, -5)
+
def test_make_pos_invoice(self):
from erpnext.accounts.doctype.sales_invoice.pos import make_invoice
diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js
index 0d3e0193d5..06606a97fe 100644
--- a/erpnext/accounts/page/pos/pos.js
+++ b/erpnext/accounts/page/pos/pos.js
@@ -183,6 +183,14 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
if(this.frm.doc.customer){
this.party_field.$input.val(this.frm.doc.customer);
}
+
+ if(!this.frm.doc.write_off_account){
+ this.frm.doc.write_off_account = doc.write_off_account
+ }
+
+ if(!this.frm.doc.account_for_change_amount){
+ this.frm.doc.account_for_change_amount = doc.account_for_change_amount
+ }
},
get_invoice_doc: function(si_docs){
@@ -209,7 +217,6 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
window.meta = r.message.meta;
window.print_template = r.message.print_template;
me.default_customer = r.message.default_customer || null;
- me.write_off_account = r.message.write_off_account;
localStorage.setItem('doc', JSON.stringify(r.message.doc));
if(callback){
callback();
@@ -485,11 +492,8 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
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) {
@@ -723,49 +727,6 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
}, 1000)
},
- write_off_amount: function(){
- var me = this;
- var value = 0.0;
-
- if(this.frm.doc.outstanding_amount > 0){
- dialog = new frappe.ui.Dialog({
- title: 'Write Off Amount',
- fields: [
- {fieldtype: "Check", fieldname: "write_off_amount", label: __("Write off Outstanding Amount")},
- {fieldtype: "Link", options:"Account", default:this.write_off_account, fieldname: "write_off_account",
- label: __("Write off Account"), get_query: function() {
- return {
- filters: {'is_group': 0, 'report_type': 'Profit and Loss'}
- }
- }}
- ]
- });
-
- dialog.show();
-
- dialog.fields_dict.write_off_amount.$input.change(function(){
- write_off_amount = dialog.get_values().write_off_amount;
- me.frm.doc.write_off_outstanding_amount_automatically = write_off_amount;
- me.frm.doc.base_write_off_amount = (write_off_amount==1) ? flt(me.frm.doc.grand_total - me.frm.doc.paid_amount, precision("outstanding_amount")) : 0;
- me.frm.doc.write_off_account = (write_off_amount==1) ? dialog.get_values().write_off_account : '';
- me.frm.doc.write_off_amount = flt(me.frm.doc.base_write_off_amount * me.frm.doc.conversion_rate, precision("write_off_amount"))
- me.calculate_outstanding_amount();
- me.set_primary_action();
- })
-
- dialog.fields_dict.write_off_account.$input.change(function(){
- me.frm.doc.write_off_account = dialog.get_values().write_off_account;
- })
-
- dialog.set_primary_action(__("Submit"), function(){
- dialog.hide()
- me.submit_invoice()
- })
- }else{
- this.submit_invoice()
- }
- },
-
submit_invoice: function(){
var me = this;
frappe.confirm(__("Do you really want to submit the invoice?"), function () {
@@ -951,6 +912,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(){
var me = this;
if(this.items[0].has_batch_no && !this.item_batch_no[this.items[0].item_code]){
@@ -978,11 +956,13 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
get_pricing_rule: function(item){
var me = this;
return $.grep(this.pricing_rules, function(data){
- if(data.item_code == item.item_code || in_list(['All Item Groups', item.item_group], data.item_group)) {
- if(in_list(['Customer', 'Customer Group', 'Territory'], data.applicable_for)){
- return me.validate_condition(data)
- }else{
- return true
+ if(item.qty >= data.min_qty && (item.qty <= (data.max_qty ? data.max_qty : item.qty)) ){
+ if(data.item_code == item.item_code || in_list(['All Item Groups', item.item_group], data.item_group)) {
+ if(in_list(['Customer', 'Customer Group', 'Territory', 'Campaign'], data.applicable_for)){
+ return me.validate_condition(data)
+ }else{
+ return true
+ }
}
}
})
@@ -1001,6 +981,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
'Customer': [data.customer, [this.frm.doc.customer]],
'Customer Group': [data.customer_group, [this.frm.doc.customer_group, 'All Customer Groups']],
'Territory': [data.territory, [this.frm.doc.territory, 'All Territories']],
+ 'Campaign': [data.campaign, [this.frm.doc.campaign]],
}
},
diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js
index 2e7651699b..6e27546cce 100644
--- a/erpnext/buying/doctype/purchase_common/purchase_common.js
+++ b/erpnext/buying/doctype/purchase_common/purchase_common.js
@@ -79,7 +79,8 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
}
} else {
return{
- query: "erpnext.controllers.queries.item_query"
+ query: "erpnext.controllers.queries.item_query",
+ filters: {'is_purchase_item': 1}
}
}
});
diff --git a/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.js b/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.js
index 45bc7381fb..0f44baacaf 100644
--- a/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.js
+++ b/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.js
@@ -11,5 +11,72 @@ frappe.query_reports["Quoted Item Comparison"] = {
"default": ""
}
- ]
+ ],
+ onload: function(report) {
+ //Create a button for setting the default supplier
+ report.page.add_inner_button(__("Select Default Supplier"), function() {
+
+ var reporter = frappe.query_reports["Quoted Item Comparison"];
+
+ //Always make a new one so that the latest values get updated
+ reporter.make_default_supplier_dialog(report);
+ report.dialog.show();
+ setTimeout(function() { report.dialog.input.focus(); }, 1000);
+
+ }, 'Tools');
+
+ },
+ "make_default_supplier_dialog": function (report) {
+ //Get the name of the item to change
+ var filters = report.get_values();
+ var item_code = filters.item;
+
+ //Get a list of the suppliers (with a blank as well) for the user to select
+ var select_options = "";
+ for (let supplier of report.data)
+ {
+ select_options += supplier.supplier_name+ '\n'
+ }
+
+ //Create a dialog window for the user to pick their supplier
+ var d = new frappe.ui.Dialog({
+ title: __('Select Default Supplier'),
+ fields: [
+ {fieldname: 'supplier', fieldtype:'Select', label:'Supplier', reqd:1,options:select_options},
+ {fieldname: 'ok_button', fieldtype:'Button', label:'Set Default Supplier'},
+ ]
+ });
+
+ //On the user clicking the ok button
+ d.fields_dict.ok_button.input.onclick = function() {
+ var btn = d.fields_dict.ok_button.input;
+ var v = report.dialog.get_values();
+ if(v) {
+ $(btn).set_working();
+
+ //Set the default_supplier field of the appropriate Item to the selected supplier
+ frappe.call({
+ method: "frappe.client.set_value",
+ args: {
+ doctype: "Item",
+ name: item_code,
+ fieldname: "default_supplier",
+ value: v.supplier,
+ },
+ callback: function (r){
+ $(btn).done_working();
+ msgprint("Successfully Set Supplier");
+ report.dialog.hide();
+
+ }
+ });
+ }
+ }
+ report.dialog = d;
+
+
+ }
+
}
+
+
diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py
index 28b2f7c756..125f4fedb6 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -440,6 +440,7 @@ class calculate_taxes_and_totals(object):
paid_amount = self.doc.paid_amount \
if self.doc.party_account_currency == self.doc.currency else self.doc.base_paid_amount
+ self.calculate_write_off_amount()
self.calculate_change_amount()
self.doc.outstanding_amount = flt(total_amount_to_pay - flt(paid_amount) +
@@ -468,6 +469,12 @@ class calculate_taxes_and_totals(object):
self.doc.base_change_amount = flt(self.doc.change_amount * self.doc.conversion_rate,
self.doc.precision("base_change_amount"))
+ def calculate_write_off_amount(self):
+ if flt(self.doc.change_amount) > 0:
+ self.doc.write_off_amount = self.doc.grand_total - self.doc.paid_amount + self.doc.change_amount
+ self.doc.base_write_off_amount = flt(self.doc.write_off_amount * self.doc.conversion_rate,
+ self.doc.precision("base_write_off_amount"))
+
def calculate_margin(self, item):
total_margin = 0.0
if item.price_list_rate:
diff --git a/erpnext/crm/doctype/opportunity/opportunity.js b/erpnext/crm/doctype/opportunity/opportunity.js
index 21a7429be2..c9f1ffb1a5 100644
--- a/erpnext/crm/doctype/opportunity/opportunity.js
+++ b/erpnext/crm/doctype/opportunity/opportunity.js
@@ -51,7 +51,8 @@ erpnext.crm.Opportunity = frappe.ui.form.Controller.extend({
this.frm.set_query("item_code", "items", function() {
return {
- query: "erpnext.controllers.queries.item_query"
+ query: "erpnext.controllers.queries.item_query",
+ filters: {'is_sales_item': 1}
};
});
diff --git a/erpnext/docs/assets/img/accounts/perpetual-2.png b/erpnext/docs/assets/img/accounts/perpetual-2.png
new file mode 100644
index 0000000000..5a2b20b21d
Binary files /dev/null and b/erpnext/docs/assets/img/accounts/perpetual-2.png differ
diff --git a/erpnext/docs/assets/img/accounts/perpetual-3.png b/erpnext/docs/assets/img/accounts/perpetual-3.png
new file mode 100644
index 0000000000..faa77245c5
Binary files /dev/null and b/erpnext/docs/assets/img/accounts/perpetual-3.png differ
diff --git a/erpnext/docs/assets/img/articles/fixed-asset-dep-1.gif b/erpnext/docs/assets/img/articles/fixed-asset-dep-1.gif
deleted file mode 100644
index e6330adb87..0000000000
Binary files a/erpnext/docs/assets/img/articles/fixed-asset-dep-1.gif and /dev/null differ
diff --git a/erpnext/docs/assets/img/articles/fixed-asset-dep-2.png b/erpnext/docs/assets/img/articles/fixed-asset-dep-2.png
deleted file mode 100644
index 0679403e14..0000000000
Binary files a/erpnext/docs/assets/img/articles/fixed-asset-dep-2.png and /dev/null differ
diff --git a/erpnext/docs/assets/img/articles/fixed-asset-dep-2.textClipping b/erpnext/docs/assets/img/articles/fixed-asset-dep-2.textClipping
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/erpnext/docs/assets/img/articles/freeze-account-1.png b/erpnext/docs/assets/img/articles/freeze-account-1.png
new file mode 100644
index 0000000000..c2f4257b86
Binary files /dev/null and b/erpnext/docs/assets/img/articles/freeze-account-1.png differ
diff --git a/erpnext/docs/assets/img/articles/freeze-account-2.png b/erpnext/docs/assets/img/articles/freeze-account-2.png
new file mode 100644
index 0000000000..4562a26a82
Binary files /dev/null and b/erpnext/docs/assets/img/articles/freeze-account-2.png differ
diff --git a/erpnext/docs/assets/img/articles/post-dated-1.gif b/erpnext/docs/assets/img/articles/post-dated-1.gif
deleted file mode 100644
index 3bb03b5984..0000000000
Binary files a/erpnext/docs/assets/img/articles/post-dated-1.gif and /dev/null differ
diff --git a/erpnext/docs/assets/img/articles/post-dated-1.png b/erpnext/docs/assets/img/articles/post-dated-1.png
new file mode 100644
index 0000000000..50696b7fbb
Binary files /dev/null and b/erpnext/docs/assets/img/articles/post-dated-1.png differ
diff --git a/erpnext/docs/assets/img/setup-wizard/step-1.png b/erpnext/docs/assets/img/setup-wizard/step-1.png
new file mode 100644
index 0000000000..0a3c230ae8
Binary files /dev/null and b/erpnext/docs/assets/img/setup-wizard/step-1.png differ
diff --git a/erpnext/docs/assets/img/setup/dropbox-1.png b/erpnext/docs/assets/img/setup/dropbox-1.png
new file mode 100644
index 0000000000..f839d25720
Binary files /dev/null and b/erpnext/docs/assets/img/setup/dropbox-1.png differ
diff --git a/erpnext/docs/assets/img/setup/dropbox-2.png b/erpnext/docs/assets/img/setup/dropbox-2.png
new file mode 100644
index 0000000000..d0a65588d1
Binary files /dev/null and b/erpnext/docs/assets/img/setup/dropbox-2.png differ
diff --git a/erpnext/docs/assets/img/setup/dropbox-3.png b/erpnext/docs/assets/img/setup/dropbox-3.png
new file mode 100644
index 0000000000..0275597769
Binary files /dev/null and b/erpnext/docs/assets/img/setup/dropbox-3.png differ
diff --git a/erpnext/docs/assets/img/setup/dropbox-open-1.png b/erpnext/docs/assets/img/setup/dropbox-open-1.png
new file mode 100644
index 0000000000..cc1d57ce8b
Binary files /dev/null and b/erpnext/docs/assets/img/setup/dropbox-open-1.png differ
diff --git a/erpnext/docs/assets/img/setup/dropbox-open-2.png b/erpnext/docs/assets/img/setup/dropbox-open-2.png
new file mode 100644
index 0000000000..969d7a7166
Binary files /dev/null and b/erpnext/docs/assets/img/setup/dropbox-open-2.png differ
diff --git a/erpnext/docs/assets/img/setup/dropbox-open-3.png b/erpnext/docs/assets/img/setup/dropbox-open-3.png
new file mode 100644
index 0000000000..150a95a4ec
Binary files /dev/null and b/erpnext/docs/assets/img/setup/dropbox-open-3.png differ
diff --git a/erpnext/docs/assets/img/users-and-permissions/permissions-lead-list.png b/erpnext/docs/assets/img/users-and-permissions/permissions-lead-list.png
new file mode 100644
index 0000000000..c2fdc7cd04
Binary files /dev/null and b/erpnext/docs/assets/img/users-and-permissions/permissions-lead-list.png differ
diff --git a/erpnext/docs/assets/img/users-and-permissions/user-permission-company.png b/erpnext/docs/assets/img/users-and-permissions/user-permission-company.png
new file mode 100644
index 0000000000..eb529f1792
Binary files /dev/null and b/erpnext/docs/assets/img/users-and-permissions/user-permission-company.png differ
diff --git a/erpnext/docs/assets/img/users-and-permissions/user-permission-quotation.png b/erpnext/docs/assets/img/users-and-permissions/user-permission-quotation.png
new file mode 100644
index 0000000000..ee7a19b51a
Binary files /dev/null and b/erpnext/docs/assets/img/users-and-permissions/user-permission-quotation.png differ
diff --git a/erpnext/docs/assets/img/users-and-permissions/user-permission-user-limited-by-company.png b/erpnext/docs/assets/img/users-and-permissions/user-permission-user-limited-by-company.png
deleted file mode 100644
index e23f1229b0..0000000000
Binary files a/erpnext/docs/assets/img/users-and-permissions/user-permission-user-limited-by-company.png and /dev/null differ
diff --git a/erpnext/docs/assets/img/users-and-permissions/user-permissions-company-wind-power-llc.png b/erpnext/docs/assets/img/users-and-permissions/user-permissions-company-wind-power-llc.png
deleted file mode 100644
index 6d78e5dc1e..0000000000
Binary files a/erpnext/docs/assets/img/users-and-permissions/user-permissions-company-wind-power-llc.png and /dev/null differ
diff --git a/erpnext/docs/assets/img/users-and-permissions/user-permissions-company.png b/erpnext/docs/assets/img/users-and-permissions/user-permissions-company.png
deleted file mode 100644
index e091a61b76..0000000000
Binary files a/erpnext/docs/assets/img/users-and-permissions/user-permissions-company.png and /dev/null differ
diff --git a/erpnext/docs/assets/img/users-and-permissions/user-permissions-new.gif b/erpnext/docs/assets/img/users-and-permissions/user-permissions-new.gif
new file mode 100644
index 0000000000..609bf257e2
Binary files /dev/null and b/erpnext/docs/assets/img/users-and-permissions/user-permissions-new.gif differ
diff --git a/erpnext/docs/assets/old_images/erpnext/accounting-for-stock-2.png b/erpnext/docs/assets/old_images/erpnext/accounting-for-stock-2.png
deleted file mode 100644
index f194360b8f..0000000000
Binary files a/erpnext/docs/assets/old_images/erpnext/accounting-for-stock-2.png and /dev/null differ
diff --git a/erpnext/docs/assets/old_images/erpnext/accounting-for-stock-3.png b/erpnext/docs/assets/old_images/erpnext/accounting-for-stock-3.png
deleted file mode 100644
index c6e336f8a8..0000000000
Binary files a/erpnext/docs/assets/old_images/erpnext/accounting-for-stock-3.png and /dev/null differ
diff --git a/erpnext/docs/assets/old_images/erpnext/user-permissions-lead-based-on-territory.png b/erpnext/docs/assets/old_images/erpnext/user-permissions-lead-based-on-territory.png
deleted file mode 100644
index e0b237329b..0000000000
Binary files a/erpnext/docs/assets/old_images/erpnext/user-permissions-lead-based-on-territory.png and /dev/null differ
diff --git a/erpnext/docs/assets/old_images/erpnext/user-permissions-quotation-list.png b/erpnext/docs/assets/old_images/erpnext/user-permissions-quotation-list.png
deleted file mode 100644
index 8a7e9c64ae..0000000000
Binary files a/erpnext/docs/assets/old_images/erpnext/user-permissions-quotation-list.png and /dev/null differ
diff --git a/erpnext/docs/user/manual/en/accounts/articles/cheque-print.md b/erpnext/docs/user/manual/en/accounts/articles/cheque-print.md
deleted file mode 100644
index 811e948fd5..0000000000
--- a/erpnext/docs/user/manual/en/accounts/articles/cheque-print.md
+++ /dev/null
@@ -1,36 +0,0 @@
-#Cheque Print
-
-** Whats is Cheque Print? **
-
-You can choose to print Cheques at the time of making payments to Creditors/ parties during Voucher Entry i.e., directly from the Payment Vouchers and Inter-bank payment or transfers through Contra Vouchers.
-
-###Setup Cheque Print
-
-To enable cheque printing,
-
-1. Create cheque settings under `Accounts > Cheque Print Template`.
-
-
-
-You can see a preview of cheque print by attaching scanned copy of cheque to avoid miss printing.
-
-
-
-
-
-2. After saving cheque print settings, you can Create / Update print format for settings.
-
-To create print format, click on `Create Print Format`.
-
-
-
-If you have already created a Print Format, you can update it by clicking on `Update Print Format`.
-
-3. You will see newly created / updated print format under Journal Entry.
-
-
-
-
-###Cheque Print
-
-
diff --git a/erpnext/docs/user/manual/en/accounts/articles/depreciation-for-fixed-asset-items.md b/erpnext/docs/user/manual/en/accounts/articles/depreciation-for-fixed-asset-items.md
deleted file mode 100644
index f7d1c5bef5..0000000000
--- a/erpnext/docs/user/manual/en/accounts/articles/depreciation-for-fixed-asset-items.md
+++ /dev/null
@@ -1,41 +0,0 @@
-#Depreciation for Fixed Asset Items
-
-Depreciation is when you write off certain value of your assets as an expense. For example, office computer will be used for five years. Hence total value of computer should be booked as expense over the period of five years.
-
-As per perpetual inventory valuation system (set by default), you should create Stock Reconciliation for depreciating value of fixed asset items. Check below steps to learn more.
-
-#### Step 1: Depreciation Account
-
-Depreciation account is auto-created, under Indirect Expenses account.
-
-
-
-#### Step 2: Stock Reconciliation
-
-To create new Stock Reconciliation, go to:
-
-`Stock > Setup > Stock Reconciliation > New`
-
-Set Posting Date and Time of Stock Reconciliation will when you wish depreciation entry to be posted in your accounts.
-
-#### Step 3: Item
-
-Select Fixed Asset Items in the item table. Update Warehouse of an item. For item valuation, update post-depreciation value. For example, item value was 100. Depreciation amount is 20. As per this post-depreciation valuation of an item will be 80. Hence 80 should be posted as valuation in the Stock Reconciliation.
-
-
-
-#### Step 4: Depreciation Account
-
-Select Depereciation Account in which depereciation amount will be booked.
-
-
-
-#### Step 5: Submit
-
-On submission of Stock Reconciliation, depreciation will booked for items asset items.
-
-
-
-Click [here]({{docs_base_url}}/user/manual/en/setting-up/stock-reconciliation-for-non-serialized-item.html) for steps to be followed when making Stock Reconciliation entry.
-
-
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/accounts/articles/how-to-freeze-accounting-ledger.md b/erpnext/docs/user/manual/en/accounts/articles/how-to-freeze-accounting-ledger.md
index f21bf2d99e..80aed6d40e 100644
--- a/erpnext/docs/user/manual/en/accounts/articles/how-to-freeze-accounting-ledger.md
+++ b/erpnext/docs/user/manual/en/accounts/articles/how-to-freeze-accounting-ledger.md
@@ -1,28 +1,36 @@
#How To Freeze Accounting Ledger?
-You can freeze any accounting ledger in ERPNext. So that frozen accounting ledger became unsearchable in accounting transaction. Follow below step to understand the process.
+If you want to discontinue using specific Account, you can freeze it.
-#### 1. Set Frozen Accounts Modifier
+>Account can be Frozen by the User having specific Role. This Role for set in the Account Settings, in the field "Role Allowed to Set Frozen Accounts & Edit Frozen Entries".
-To set frozen accounts modifier go to `Accounts > Setup > Accounts Setting`
+Please check following steps to freeze an Account from the Chart of Accounts master.
-Search and select Role under Frozen Accounts Modifier field and save the Account Settings form.
-
-
+####Step 1: Chart of Accounts
-#### 2. Edit Accounting Ledger.
+To edit an Account, go to Chart of Accounts:
-To edit accounting ledger go to `Accounts > Setup > Chart of Accounts`
+`Explore > Accounts > Chart of Accounts`
-
+
-#### 3. Set Frozen Status of Ledger.
+Click on Account in which Frozen Date is to be updated.
-
+####Step 2: Set Account as Frozen
+
+In the Account form, you will find a field called **Frozen**. Set value in this field as 'Yes'
+
+
+
+####Step 3: Save
+
+After update Save an Account.
+
+On saving, this Account will be frozen and will not be selectable in any accounting transaction.
+
+
If you wish to store your backups on a periodic basis,on Dropbox, you can do it directly through ERPNext.
---Setup > Manage 3rd Party Backups
-
Step 1: Click on Integrations > Backup Manager
-
-
In the Backup Manager page, enter the email addresses of those people whom you wish to notify about the upload status. Under the topic 'Sync with Dropbox', select whether you wish to upload Daily, Weekly or Never.
-Step 2 Click on Allow Dropbox Access.
---Tip: In future, if you wish to discontinue uploading backups to dropbox, then select the Never option.
-
You need to login to your dropbox account, with your user id and password.
-{
- "db_name": "demo",
- "db_password": "DZ1Idd55xJ9qvkHvUH",
- "dropbox_access_key": "ACCESSKEY",
- "dropbox_secret_key": "SECRECTKEY"
-}
-
+ {
+ "db_name": "demo",
+ "db_password": "DZ1Idd55xJ9qvkHvUH",
+ "dropbox_access_key": "ACCESSKEY",
+ "dropbox_secret_key": "SECRECTKEY"
+}
+
+
+Stock Ledger -
-Total
Paid
Outstanding
Change
Change +
+Write off