mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 08:54:45 +00:00
Merge branch 'wsgi' of https://github.com/webnotes/erpnext into i18n
Conflicts: accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js public/js/complete_setup.js selling/doctype/opportunity/opportunity.js selling/doctype/quotation/quotation.js
This commit is contained in:
@@ -7,7 +7,6 @@ import webnotes
|
||||
from webnotes.utils import flt, fmt_money, cstr, cint
|
||||
from webnotes import msgprint, _
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
|
||||
class DocType:
|
||||
@@ -25,17 +24,6 @@ class DocType:
|
||||
self.doc.master_name, "address")
|
||||
}
|
||||
|
||||
def validate(self):
|
||||
self.validate_master_name()
|
||||
self.validate_parent()
|
||||
self.validate_duplicate_account()
|
||||
self.validate_root_details()
|
||||
self.validate_mandatory()
|
||||
self.validate_warehouse_account()
|
||||
|
||||
if not self.doc.parent_account:
|
||||
self.doc.parent_account = ''
|
||||
|
||||
def validate(self):
|
||||
self.validate_master_name()
|
||||
self.validate_parent()
|
||||
@@ -56,7 +44,7 @@ class DocType:
|
||||
def validate_parent(self):
|
||||
"""Fetch Parent Details and validation for account not to be created under ledger"""
|
||||
if self.doc.parent_account:
|
||||
par = sql("""select name, group_or_ledger, is_pl_account, debit_or_credit
|
||||
par = webnotes.conn.sql("""select name, group_or_ledger, is_pl_account, debit_or_credit
|
||||
from tabAccount where name =%s""", self.doc.parent_account)
|
||||
if not par:
|
||||
msgprint("Parent account does not exists", raise_exception=1)
|
||||
@@ -84,7 +72,7 @@ class DocType:
|
||||
def validate_duplicate_account(self):
|
||||
if self.doc.fields.get('__islocal') or not self.doc.name:
|
||||
company_abbr = webnotes.conn.get_value("Company", self.doc.company, "abbr")
|
||||
if sql("""select name from tabAccount where name=%s""",
|
||||
if webnotes.conn.sql("""select name from tabAccount where name=%s""",
|
||||
(self.doc.account_name + " - " + company_abbr)):
|
||||
msgprint("Account Name: %s already exists, please rename"
|
||||
% self.doc.account_name, raise_exception=1)
|
||||
@@ -133,7 +121,7 @@ class DocType:
|
||||
return webnotes.conn.get_value("GL Entry", {"account": self.doc.name})
|
||||
|
||||
def check_if_child_exists(self):
|
||||
return sql("""select name from `tabAccount` where parent_account = %s
|
||||
return webnotes.conn.sql("""select name from `tabAccount` where parent_account = %s
|
||||
and docstatus != 2""", self.doc.name)
|
||||
|
||||
def validate_mandatory(self):
|
||||
@@ -181,7 +169,7 @@ class DocType:
|
||||
# Get credit limit
|
||||
credit_limit_from = 'Customer'
|
||||
|
||||
cr_limit = sql("""select t1.credit_limit from tabCustomer t1, `tabAccount` t2
|
||||
cr_limit = webnotes.conn.sql("""select t1.credit_limit from tabCustomer t1, `tabAccount` t2
|
||||
where t2.name=%s and t1.name = t2.master_name""", account)
|
||||
credit_limit = cr_limit and flt(cr_limit[0][0]) or 0
|
||||
if not credit_limit:
|
||||
@@ -221,7 +209,7 @@ class DocType:
|
||||
|
||||
# rename account name
|
||||
new_account_name = " - ".join(parts[:-1])
|
||||
sql("update `tabAccount` set account_name = %s where name = %s", (new_account_name, old))
|
||||
webnotes.conn.sql("update `tabAccount` set account_name = %s where name = %s", (new_account_name, old))
|
||||
|
||||
if merge:
|
||||
new_name = " - ".join(parts)
|
||||
|
||||
@@ -10,7 +10,6 @@ from webnotes.model.doc import addchild
|
||||
from webnotes.model.bean import getlist, copy_doclist
|
||||
from webnotes import msgprint
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
|
||||
|
||||
@@ -23,7 +22,7 @@ class DocType:
|
||||
msgprint("Bank Account, From Date and To Date are Mandatory")
|
||||
return
|
||||
|
||||
dl = sql("select t1.name, t1.cheque_no, t1.cheque_date, t2.debit, t2.credit, t1.posting_date, t2.against_account from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t2.parent = t1.name and t2.account = %s and (clearance_date is null or clearance_date = '0000-00-00' or clearance_date = '') and t1.posting_date >= %s and t1.posting_date <= %s and t1.docstatus=1", (self.doc.bank_account, self.doc.from_date, self.doc.to_date))
|
||||
dl = webnotes.conn.sql("select t1.name, t1.cheque_no, t1.cheque_date, t2.debit, t2.credit, t1.posting_date, t2.against_account from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t2.parent = t1.name and t2.account = %s and (clearance_date is null or clearance_date = '0000-00-00' or clearance_date = '') and t1.posting_date >= %s and t1.posting_date <= %s and t1.docstatus=1", (self.doc.bank_account, self.doc.from_date, self.doc.to_date))
|
||||
|
||||
self.doclist = self.doc.clear_table(self.doclist, 'entries')
|
||||
self.doc.total_amount = 0.0
|
||||
@@ -47,7 +46,7 @@ class DocType:
|
||||
msgprint("Clearance Date can not be before Cheque Date (Row #%s)" %
|
||||
d.idx, raise_exception=1)
|
||||
|
||||
sql("""update `tabJournal Voucher`
|
||||
webnotes.conn.sql("""update `tabJournal Voucher`
|
||||
set clearance_date = %s, modified = %s where name=%s""",
|
||||
(d.clearance_date, nowdate(), d.voucher_id))
|
||||
vouchers.append(d.voucher_id)
|
||||
|
||||
@@ -107,7 +107,7 @@ class DocType:
|
||||
_(" does not belong to the company") + ": " + self.doc.company)
|
||||
|
||||
def check_negative_balance(account, adv_adj=False):
|
||||
if not adv_adj:
|
||||
if not adv_adj and account:
|
||||
account_details = webnotes.conn.get_value("Account", account,
|
||||
["allow_negative_balance", "debit_or_credit"], as_dict=True)
|
||||
if not account_details["allow_negative_balance"]:
|
||||
@@ -161,16 +161,6 @@ def update_outstanding_amt(account, against_voucher_type, against_voucher, on_ca
|
||||
webnotes.conn.sql("update `tab%s` set outstanding_amount=%s where name='%s'" %
|
||||
(against_voucher_type, bal, against_voucher))
|
||||
|
||||
def validate_freezed_account(account, adv_adj=False):
|
||||
"""Account has been freezed for other users except account manager"""
|
||||
|
||||
freezed_account = webnotes.conn.get_value("Account", account, "freeze_account")
|
||||
|
||||
if freezed_account == 'Yes' and not adv_adj \
|
||||
and 'Accounts Manager' not in webnotes.user.get_roles():
|
||||
webnotes.throw(_("Account") + ": " + account + _(" has been freezed. \
|
||||
Only Accounts Manager can do transaction against this account"))
|
||||
|
||||
def validate_frozen_account(account, adv_adj):
|
||||
frozen_account = webnotes.conn.get_value("Account", account, "freeze_account")
|
||||
if frozen_account == 'Yes' and not adv_adj:
|
||||
@@ -183,4 +173,4 @@ def validate_frozen_account(account, adv_adj):
|
||||
elif frozen_accounts_modifier not in webnotes.user.get_roles():
|
||||
webnotes.throw(account + _(" is a frozen account. ") +
|
||||
_("To create / edit transactions against this account, you need role") + ": " +
|
||||
frozen_accounts_modifier)
|
||||
frozen_accounts_modifier)
|
||||
|
||||
@@ -59,6 +59,50 @@ erpnext.accounts.JournalVoucher = wn.ui.form.Controller.extend({
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
against_voucher: function(doc, cdt, cdn) {
|
||||
var d = wn.model.get_doc(cdt, cdn);
|
||||
if (d.against_voucher && !flt(d.debit)) {
|
||||
this.get_outstanding({
|
||||
'doctype': 'Purchase Invoice',
|
||||
'docname': d.against_voucher
|
||||
}, d)
|
||||
}
|
||||
},
|
||||
|
||||
against_invoice: function(doc, cdt, cdn) {
|
||||
var d = wn.model.get_doc(cdt, cdn);
|
||||
if (d.against_invoice && !flt(d.credit)) {
|
||||
this.get_outstanding({
|
||||
'doctype': 'Sales Invoice',
|
||||
'docname': d.against_invoice
|
||||
}, d)
|
||||
}
|
||||
},
|
||||
|
||||
against_jv: function(doc, cdt, cdn) {
|
||||
var d = wn.model.get_doc(cdt, cdn);
|
||||
if (d.against_jv && !flt(d.credit) && !flt(d.debit)) {
|
||||
this.get_outstanding({
|
||||
'doctype': 'Journal Voucher',
|
||||
'docname': d.against_jv,
|
||||
'account': d.account
|
||||
}, d)
|
||||
}
|
||||
},
|
||||
|
||||
get_outstanding: function(args, child) {
|
||||
var me = this;
|
||||
return this.frm.call({
|
||||
child: child,
|
||||
method: "get_outstanding",
|
||||
args: { args: args},
|
||||
callback: function(r) {
|
||||
cur_frm.cscript.update_totals(me.frm.doc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
cur_frm.script_manager.make(erpnext.accounts.JournalVoucher);
|
||||
@@ -88,24 +132,6 @@ cur_frm.cscript.is_opening = function(doc, cdt, cdn) {
|
||||
if (doc.is_opening == 'Yes') unhide_field('aging_date');
|
||||
}
|
||||
|
||||
cur_frm.cscript.against_voucher = function(doc,cdt,cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
if (d.against_voucher && !flt(d.debit)) {
|
||||
args = {'doctype': 'Purchase Invoice', 'docname': d.against_voucher }
|
||||
return get_server_fields('get_outstanding',docstring(args),'entries',doc,cdt,cdn,1,function(r,rt) { cur_frm.cscript.update_totals(doc); });
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.against_invoice = function(doc,cdt,cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
if (d.against_invoice && !flt(d.credit)) {
|
||||
args = {'doctype': 'Sales Invoice', 'docname': d.against_invoice }
|
||||
return get_server_fields('get_outstanding',docstring(args),'entries',doc,cdt,cdn,1,function(r,rt) { cur_frm.cscript.update_totals(doc); });
|
||||
}
|
||||
}
|
||||
|
||||
// Update Totals
|
||||
|
||||
cur_frm.cscript.update_totals = function(doc) {
|
||||
var td=0.0; var tc =0.0;
|
||||
var el = getchildren('Journal Voucher Detail', doc.name, 'entries');
|
||||
|
||||
@@ -260,15 +260,6 @@ class DocType(AccountsController):
|
||||
if gl_map:
|
||||
make_gl_entries(gl_map, cancel=cancel, adv_adj=adv_adj)
|
||||
|
||||
def get_outstanding(self, args):
|
||||
args = eval(args)
|
||||
o_s = webnotes.conn.sql("""select outstanding_amount from `tab%s` where name = %s""" %
|
||||
(args['doctype'], '%s'), args['docname'])
|
||||
if args['doctype'] == 'Purchase Invoice':
|
||||
return {'debit': o_s and flt(o_s[0][0]) or 0}
|
||||
if args['doctype'] == 'Sales Invoice':
|
||||
return {'credit': o_s and flt(o_s[0][0]) or 0}
|
||||
|
||||
def get_balance(self):
|
||||
if not getlist(self.doclist,'entries'):
|
||||
msgprint("Please enter atleast 1 entry in 'GL Entries' table")
|
||||
@@ -434,4 +425,31 @@ def get_against_jv(doctype, txt, searchfield, start, page_len, filters):
|
||||
where jv_detail.parent = jv.name and jv_detail.account = %s and jv.docstatus = 1
|
||||
and jv.%s like %s order by jv.name desc limit %s, %s""" %
|
||||
("%s", searchfield, "%s", "%s", "%s"),
|
||||
(filters["account"], "%%%s%%" % txt, start, page_len))
|
||||
(filters["account"], "%%%s%%" % txt, start, page_len))
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_outstanding(args):
|
||||
args = eval(args)
|
||||
if args.get("doctype") == "Journal Voucher" and args.get("account"):
|
||||
against_jv_amount = webnotes.conn.sql("""
|
||||
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
|
||||
from `tabJournal Voucher Detail` where parent=%s and account=%s
|
||||
and ifnull(against_invoice, '')='' and ifnull(against_voucher, '')=''
|
||||
and ifnull(against_jv, '')=''""", (args['docname'], args['account']))
|
||||
|
||||
against_jv_amount = flt(against_jv_amount[0][0]) if against_jv_amount else 0
|
||||
if against_jv_amount > 0:
|
||||
return {"credit": against_jv_amount}
|
||||
else:
|
||||
return {"debit": -1* against_jv_amount}
|
||||
|
||||
elif args.get("doctype") == "Sales Invoice":
|
||||
return {
|
||||
"credit": flt(webnotes.conn.get_value("Sales Invoice", args["docname"],
|
||||
"outstanding_amount"))
|
||||
}
|
||||
elif args.get("doctype") == "Purchase Invoice":
|
||||
return {
|
||||
"debit": flt(webnotes.conn.get_value("Purchase Invoice", args["docname"],
|
||||
"outstanding_amount"))
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ from webnotes import session, msgprint
|
||||
|
||||
import webnotes.defaults
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
from accounts.utils import get_balance_on, get_fiscal_year
|
||||
|
||||
@@ -44,7 +43,7 @@ class DocType:
|
||||
ret['company'] = get_companies()
|
||||
|
||||
#--- to get fiscal year and start_date of that fiscal year -----
|
||||
res = sql("select name, year_start_date from `tabFiscal Year`")
|
||||
res = webnotes.conn.sql("select name, year_start_date from `tabFiscal Year`")
|
||||
ret['fiscal_year'] = [r[0] for r in res]
|
||||
ret['start_dates'] = {}
|
||||
for r in res:
|
||||
@@ -52,7 +51,7 @@ class DocType:
|
||||
|
||||
#--- from month and to month (for MIS - Comparison Report) -------
|
||||
month_list = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
|
||||
fiscal_start_month = sql("select MONTH(year_start_date) from `tabFiscal Year` where name = %s",(webnotes.defaults.get_global_default("fiscal_year")))
|
||||
fiscal_start_month = webnotes.conn.sql("select MONTH(year_start_date) from `tabFiscal Year` where name = %s",(webnotes.defaults.get_global_default("fiscal_year")))
|
||||
fiscal_start_month = fiscal_start_month and fiscal_start_month[0][0] or 1
|
||||
mon = ['']
|
||||
for i in range(fiscal_start_month,13): mon.append(month_list[i-1])
|
||||
@@ -107,7 +106,7 @@ class DocType:
|
||||
def dates(self,fiscal_year,from_date,to_date):
|
||||
import datetime
|
||||
ret = ''
|
||||
start_date = cstr(sql("select year_start_date from `tabFiscal Year` where name = %s",fiscal_year)[0][0])
|
||||
start_date = cstr(webnotes.conn.sql("select year_start_date from `tabFiscal Year` where name = %s",fiscal_year)[0][0])
|
||||
st_mon = cint(from_date.split('-')[1])
|
||||
ed_mon = cint(to_date.split('-')[1])
|
||||
st_day = cint(from_date.split('-')[2])
|
||||
@@ -152,7 +151,7 @@ class DocType:
|
||||
def get_totals(self, args):
|
||||
args = eval(args)
|
||||
#msgprint(args)
|
||||
totals = sql("SELECT %s FROM %s WHERE %s %s %s %s" %(cstr(args['query_val']), cstr(args['tables']), cstr(args['company']), cstr(args['cond']), cstr(args['add_cond']), cstr(args['fil_cond'])), as_dict = 1)[0]
|
||||
totals = webnotes.conn.sql("SELECT %s FROM %s WHERE %s %s %s %s" %(cstr(args['query_val']), cstr(args['tables']), cstr(args['company']), cstr(args['cond']), cstr(args['add_cond']), cstr(args['fil_cond'])), as_dict = 1)[0]
|
||||
#msgprint(totals)
|
||||
tot_keys = totals.keys()
|
||||
# return in flt because JSON doesn't accept Decimal
|
||||
@@ -185,7 +184,7 @@ class DocType:
|
||||
# Get Children
|
||||
# ------------
|
||||
def get_children(self, parent_account, level, pl, company, fy):
|
||||
cl = sql("select distinct account_name, name, debit_or_credit, lft, rgt from `tabAccount` where ifnull(parent_account, '') = %s and ifnull(is_pl_account, 'No')=%s and company=%s and docstatus != 2 order by name asc", (parent_account, pl, company))
|
||||
cl = webnotes.conn.sql("select distinct account_name, name, debit_or_credit, lft, rgt from `tabAccount` where ifnull(parent_account, '') = %s and ifnull(is_pl_account, 'No')=%s and company=%s and docstatus != 2 order by name asc", (parent_account, pl, company))
|
||||
level0_diff = [0 for p in self.period_list]
|
||||
if pl=='Yes' and level==0: # switch for income & expenses
|
||||
cl = [c for c in cl]
|
||||
@@ -238,7 +237,7 @@ class DocType:
|
||||
def define_periods(self, year, period):
|
||||
|
||||
# get year start date
|
||||
ysd = sql("select year_start_date from `tabFiscal Year` where name=%s", year)
|
||||
ysd = webnotes.conn.sql("select year_start_date from `tabFiscal Year` where name=%s", year)
|
||||
ysd = ysd and ysd[0][0] or ''
|
||||
|
||||
self.ysd = ysd
|
||||
|
||||
@@ -69,7 +69,6 @@ class DocType(AccountsController):
|
||||
|
||||
def get_pl_balances(self):
|
||||
"""Get balance for pl accounts"""
|
||||
|
||||
return webnotes.conn.sql("""
|
||||
select t1.account, sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0)) as balance
|
||||
from `tabGL Entry` t1, `tabAccount` t2
|
||||
@@ -101,4 +100,4 @@ class DocType(AccountsController):
|
||||
}))
|
||||
|
||||
from accounts.general_ledger import make_gl_entries
|
||||
make_gl_entries(gl_entries)
|
||||
make_gl_entries(gl_entries)
|
||||
|
||||
@@ -8,6 +8,9 @@ import webnotes
|
||||
|
||||
class TestPeriodClosingVoucher(unittest.TestCase):
|
||||
def test_closing_entry(self):
|
||||
# clear GL Entries
|
||||
webnotes.conn.sql("""delete from `tabGL Entry`""")
|
||||
|
||||
from accounts.doctype.journal_voucher.test_journal_voucher import test_records as jv_records
|
||||
jv = webnotes.bean(copy=jv_records[2])
|
||||
jv.insert()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-24 12:15:51",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-08-28 19:13:42",
|
||||
"modified": "2013-10-15 11:12:02",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -80,16 +80,6 @@
|
||||
"read_only": 0,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "conversion_rate",
|
||||
"fieldtype": "Float",
|
||||
"label": "Conversion Rate",
|
||||
"oldfieldname": "conversion_rate",
|
||||
"oldfieldtype": "Currency",
|
||||
"read_only": 0,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "selling_price_list",
|
||||
|
||||
@@ -8,6 +8,7 @@ cur_frm.cscript.other_fname = "purchase_tax_details";
|
||||
wn.provide("erpnext.accounts");
|
||||
wn.require('app/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js');
|
||||
wn.require('app/buying/doctype/purchase_common/purchase_common.js');
|
||||
wn.require('app/accounts/doctype/sales_invoice/pos.js');
|
||||
|
||||
erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
|
||||
onload: function() {
|
||||
|
||||
@@ -12,7 +12,6 @@ from setup.utils import get_company_currency
|
||||
|
||||
import webnotes.defaults
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
from controllers.buying_controller import BuyingController
|
||||
class DocType(BuyingController):
|
||||
@@ -62,19 +61,23 @@ class DocType(BuyingController):
|
||||
"purchase_receipt_details")
|
||||
|
||||
def get_credit_to(self):
|
||||
acc_head = sql("""select name, credit_days from `tabAccount`
|
||||
where (name = %s or (master_name = %s and master_type = 'supplier'))
|
||||
and docstatus != 2 and company = %s""",
|
||||
(cstr(self.doc.supplier) + " - " + self.company_abbr,
|
||||
self.doc.supplier, self.doc.company))
|
||||
|
||||
ret = {}
|
||||
if acc_head and acc_head[0][0]:
|
||||
ret['credit_to'] = acc_head[0][0]
|
||||
if not self.doc.due_date:
|
||||
ret['due_date'] = add_days(cstr(self.doc.posting_date), acc_head and cint(acc_head[0][1]) or 0)
|
||||
elif not acc_head:
|
||||
msgprint("%s does not have an Account Head in %s. You must first create it from the Supplier Master" % (self.doc.supplier, self.doc.company))
|
||||
if self.doc.supplier:
|
||||
acc_head = webnotes.conn.sql("""select name, credit_days from `tabAccount`
|
||||
where (name = %s or (master_name = %s and master_type = 'supplier'))
|
||||
and docstatus != 2 and company = %s""",
|
||||
(cstr(self.doc.supplier) + " - " + self.company_abbr,
|
||||
self.doc.supplier, self.doc.company))
|
||||
|
||||
if acc_head and acc_head[0][0]:
|
||||
ret['credit_to'] = acc_head[0][0]
|
||||
if not self.doc.due_date:
|
||||
ret['due_date'] = add_days(cstr(self.doc.posting_date),
|
||||
acc_head and cint(acc_head[0][1]) or 0)
|
||||
elif not acc_head:
|
||||
msgprint("%s does not have an Account Head in %s. \
|
||||
You must first create it from the Supplier Master" % \
|
||||
(self.doc.supplier, self.doc.company))
|
||||
return ret
|
||||
|
||||
def set_supplier_defaults(self):
|
||||
@@ -85,18 +88,10 @@ class DocType(BuyingController):
|
||||
super(DocType, self).get_advances(self.doc.credit_to,
|
||||
"Purchase Invoice Advance", "advance_allocation_details", "debit")
|
||||
|
||||
def get_rate(self,arg):
|
||||
return get_obj('Purchase Common').get_rate(arg,self)
|
||||
|
||||
def get_rate1(self,acc):
|
||||
rate = sql("select tax_rate from `tabAccount` where name='%s'"%(acc))
|
||||
ret={'add_tax_rate' :rate and flt(rate[0][0]) or 0 }
|
||||
return ret
|
||||
|
||||
def check_active_purchase_items(self):
|
||||
for d in getlist(self.doclist, 'entries'):
|
||||
if d.item_code: # extra condn coz item_code is not mandatory in PV
|
||||
valid_item = sql("select docstatus,is_purchase_item from tabItem where name = %s",d.item_code)
|
||||
valid_item = webnotes.conn.sql("select docstatus,is_purchase_item from tabItem where name = %s",d.item_code)
|
||||
if valid_item[0][0] == 2:
|
||||
msgprint("Item : '%s' is Inactive, you can restore it from Trash" %(d.item_code))
|
||||
raise Exception
|
||||
@@ -116,7 +111,7 @@ class DocType(BuyingController):
|
||||
def validate_bill_no(self):
|
||||
if self.doc.bill_no and self.doc.bill_no.lower().strip() \
|
||||
not in ['na', 'not applicable', 'none']:
|
||||
b_no = sql("""select bill_no, name, ifnull(is_opening,'') from `tabPurchase Invoice`
|
||||
b_no = webnotes.conn.sql("""select bill_no, name, ifnull(is_opening,'') from `tabPurchase Invoice`
|
||||
where bill_no = %s and credit_to = %s and docstatus = 1 and name != %s""",
|
||||
(self.doc.bill_no, self.doc.credit_to, self.doc.name))
|
||||
if b_no and cstr(b_no[0][2]) == cstr(self.doc.is_opening):
|
||||
@@ -132,7 +127,7 @@ class DocType(BuyingController):
|
||||
self.doc.remarks = "No Remarks"
|
||||
|
||||
def validate_credit_acc(self):
|
||||
acc = sql("select debit_or_credit, is_pl_account from tabAccount where name = %s",
|
||||
acc = webnotes.conn.sql("select debit_or_credit, is_pl_account from tabAccount where name = %s",
|
||||
self.doc.credit_to)
|
||||
if not acc:
|
||||
msgprint("Account: "+ self.doc.credit_to + "does not exist")
|
||||
@@ -148,7 +143,7 @@ class DocType(BuyingController):
|
||||
# ------------------------------------------------------------
|
||||
def check_for_acc_head_of_supplier(self):
|
||||
if self.doc.supplier and self.doc.credit_to:
|
||||
acc_head = sql("select master_name from `tabAccount` where name = %s", self.doc.credit_to)
|
||||
acc_head = webnotes.conn.sql("select master_name from `tabAccount` where name = %s", self.doc.credit_to)
|
||||
|
||||
if (acc_head and cstr(acc_head[0][0]) != cstr(self.doc.supplier)) or (not acc_head and (self.doc.credit_to != cstr(self.doc.supplier) + " - " + self.company_abbr)):
|
||||
msgprint("Credit To: %s do not match with Supplier: %s for Company: %s.\n If both correctly entered, please select Master Type and Master Name in account master." %(self.doc.credit_to,self.doc.supplier,self.doc.company), raise_exception=1)
|
||||
@@ -160,7 +155,7 @@ class DocType(BuyingController):
|
||||
for d in getlist(self.doclist,'entries'):
|
||||
if d.purchase_order and not d.purchase_order in check_list and not d.purchase_receipt:
|
||||
check_list.append(d.purhcase_order)
|
||||
stopped = sql("select name from `tabPurchase Order` where status = 'Stopped' and name = '%s'" % d.purchase_order)
|
||||
stopped = webnotes.conn.sql("select name from `tabPurchase Order` where status = 'Stopped' and name = '%s'" % d.purchase_order)
|
||||
if stopped:
|
||||
msgprint("One cannot do any transaction against 'Purchase Order' : %s, it's status is 'Stopped'" % (d.purhcase_order))
|
||||
raise Exception
|
||||
@@ -260,11 +255,11 @@ class DocType(BuyingController):
|
||||
def check_prev_docstatus(self):
|
||||
for d in getlist(self.doclist,'entries'):
|
||||
if d.purchase_order:
|
||||
submitted = sql("select name from `tabPurchase Order` where docstatus = 1 and name = '%s'" % d.purchase_order)
|
||||
submitted = webnotes.conn.sql("select name from `tabPurchase Order` where docstatus = 1 and name = '%s'" % d.purchase_order)
|
||||
if not submitted:
|
||||
webnotes.throw("Purchase Order : "+ cstr(d.purchase_order) +" is not submitted")
|
||||
if d.purchase_receipt:
|
||||
submitted = sql("select name from `tabPurchase Receipt` where docstatus = 1 and name = '%s'" % d.purchase_receipt)
|
||||
submitted = webnotes.conn.sql("select name from `tabPurchase Receipt` where docstatus = 1 and name = '%s'" % d.purchase_receipt)
|
||||
if not submitted:
|
||||
webnotes.throw("Purchase Receipt : "+ cstr(d.purchase_receipt) +" is not submitted")
|
||||
|
||||
@@ -334,7 +329,7 @@ class DocType(BuyingController):
|
||||
)
|
||||
|
||||
# tax table gl entries
|
||||
valuation_tax = 0
|
||||
valuation_tax = {}
|
||||
for tax in self.doclist.get({"parentfield": "purchase_tax_details"}):
|
||||
if tax.category in ("Total", "Valuation and Total") and flt(tax.tax_amount):
|
||||
gl_entries.append(
|
||||
@@ -349,8 +344,11 @@ class DocType(BuyingController):
|
||||
)
|
||||
|
||||
# accumulate valuation tax
|
||||
if tax.category in ("Valuation", "Valuation and Total") and flt(tax.tax_amount):
|
||||
valuation_tax += (tax.add_deduct_tax == "Add" and 1 or -1) * flt(tax.tax_amount)
|
||||
if tax.category in ("Valuation", "Valuation and Total") and flt(tax.tax_amount) \
|
||||
and tax.cost_center:
|
||||
valuation_tax.setdefault(tax.cost_center, 0)
|
||||
valuation_tax[tax.cost_center] += \
|
||||
(tax.add_deduct_tax == "Add" and 1 or -1) * flt(tax.tax_amount)
|
||||
|
||||
# item gl entries
|
||||
stock_item_and_auto_accounting_for_stock = False
|
||||
@@ -391,15 +389,19 @@ class DocType(BuyingController):
|
||||
if stock_item_and_auto_accounting_for_stock and valuation_tax:
|
||||
# credit valuation tax amount in "Expenses Included In Valuation"
|
||||
# this will balance out valuation amount included in cost of goods sold
|
||||
gl_entries.append(
|
||||
self.get_gl_dict({
|
||||
"account": self.get_company_default("expenses_included_in_valuation"),
|
||||
"cost_center": self.get_company_default("cost_center"),
|
||||
"against": self.doc.credit_to,
|
||||
"credit": valuation_tax,
|
||||
"remarks": self.doc.remarks or "Accounting Entry for Stock"
|
||||
})
|
||||
)
|
||||
expenses_included_in_valuation = \
|
||||
self.get_company_default("expenses_included_in_valuation")
|
||||
|
||||
for cost_center, amount in valuation_tax.items():
|
||||
gl_entries.append(
|
||||
self.get_gl_dict({
|
||||
"account": expenses_included_in_valuation,
|
||||
"cost_center": cost_center,
|
||||
"against": self.doc.credit_to,
|
||||
"credit": amount,
|
||||
"remarks": self.doc.remarks or "Accounting Entry for Stock"
|
||||
})
|
||||
)
|
||||
|
||||
# writeoff account includes petty difference in the invoice amount
|
||||
# and the amount that is paid
|
||||
@@ -432,7 +434,7 @@ class DocType(BuyingController):
|
||||
def update_raw_material_cost(self):
|
||||
if self.sub_contracted_items:
|
||||
for d in self.doclist.get({"parentfield": "entries"}):
|
||||
rm_cost = webnotes.conn.sql(""" select raw_material_cost / quantity
|
||||
rm_cost = webnotes.conn.sql("""select raw_material_cost / quantity
|
||||
from `tabBOM` where item = %s and is_default = 1 and docstatus = 1
|
||||
and is_active = 1 """, (d.item_code,))
|
||||
rm_cost = rm_cost and flt(rm_cost[0][0]) or 0
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
{
|
||||
"creation": "2013-05-21 16:16:39",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-08-09 14:45:35",
|
||||
"modified": "2013-10-02 14:24:55",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"allow_attach": 1,
|
||||
"allow_import": 1,
|
||||
"autoname": "naming_series:",
|
||||
"doctype": "DocType",
|
||||
"icon": "icon-file-text",
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
//
|
||||
|
||||
//--------- ONLOAD -------------
|
||||
wn.require("app/js/controllers/accounts.js");
|
||||
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
|
||||
}
|
||||
@@ -134,6 +136,7 @@ cur_frm.fields_dict['purchase_tax_details'].grid.get_field("cost_center").get_qu
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
cur_frm.cscript.account_head = function(doc, cdt, cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
if(!d.charge_type && d.account_head){
|
||||
@@ -148,6 +151,8 @@ cur_frm.cscript.account_head = function(doc, cdt, cdn) {
|
||||
refresh_field('account_head',d.name,'purchase_tax_details');
|
||||
}
|
||||
|
||||
=======
|
||||
>>>>>>> f146e8b7f52a3e46e335c0fefd92c347717b370b
|
||||
cur_frm.cscript.rate = function(doc, cdt, cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
if(!d.charge_type && d.rate) {
|
||||
|
||||
@@ -8,16 +8,10 @@ from webnotes.model import db_exists
|
||||
from webnotes.model.bean import copy_doclist
|
||||
from webnotes.model.code import get_obj
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
# Get Tax Rate if account type is Tax
|
||||
# ===================================================================
|
||||
def get_rate(self, arg):
|
||||
return get_obj('Purchase Common').get_rate(arg, self)
|
||||
self.doclist = doclist
|
||||
@@ -7,7 +7,7 @@ erpnext.POS = Class.extend({
|
||||
this.frm = frm;
|
||||
this.wrapper.html('<div class="container">\
|
||||
<div class="row">\
|
||||
<div class="customer-area col-sm-3 col-xs-6"></div>\
|
||||
<div class="party-area col-sm-3 col-xs-6"></div>\
|
||||
<div class="barcode-area col-sm-3 col-xs-6"></div>\
|
||||
<div class="search-area col-sm-3 col-xs-6"></div>\
|
||||
<div class="item-group-area col-sm-3 col-xs-6"></div>\
|
||||
@@ -71,7 +71,18 @@ erpnext.POS = Class.extend({
|
||||
</div>\
|
||||
</div>\
|
||||
</div></div>');
|
||||
|
||||
|
||||
if (wn.meta.has_field(cur_frm.doc.doctype, "customer")) {
|
||||
this.party = "Customer";
|
||||
this.price_list = this.frm.doc.selling_price_list;
|
||||
this.sales_or_purchase = "Sales";
|
||||
}
|
||||
else if (wn.meta.has_field(cur_frm.doc.doctype, "supplier")) {
|
||||
this.party = "Supplier";
|
||||
this.price_list = this.frm.doc.buying_price_list;
|
||||
this.sales_or_purchase = "Purchase";
|
||||
}
|
||||
|
||||
this.make();
|
||||
|
||||
var me = this;
|
||||
@@ -88,28 +99,29 @@ erpnext.POS = Class.extend({
|
||||
});
|
||||
},
|
||||
make: function() {
|
||||
this.make_customer();
|
||||
this.make_party();
|
||||
this.make_item_group();
|
||||
this.make_search();
|
||||
this.make_barcode();
|
||||
this.make_item_list();
|
||||
},
|
||||
make_customer: function() {
|
||||
make_party: function() {
|
||||
var me = this;
|
||||
this.customer = wn.ui.form.make_control({
|
||||
this.party_field = wn.ui.form.make_control({
|
||||
df: {
|
||||
"fieldtype": "Link",
|
||||
"options": "Customer",
|
||||
"label": "Customer",
|
||||
"fieldname": "pos_customer",
|
||||
"placeholder": "Customer"
|
||||
"options": this.party,
|
||||
"label": this.party,
|
||||
"fieldname": "pos_party",
|
||||
"placeholder": this.party
|
||||
},
|
||||
parent: this.wrapper.find(".customer-area")
|
||||
parent: this.wrapper.find(".party-area")
|
||||
});
|
||||
this.customer.make_input();
|
||||
this.customer.$input.on("change", function() {
|
||||
if(!me.customer.autocomplete_open)
|
||||
wn.model.set_value("Sales Invoice", me.frm.docname, "customer", this.value);
|
||||
this.party_field.make_input();
|
||||
this.party_field.$input.on("change", function() {
|
||||
if(!me.party_field.autocomplete_open)
|
||||
wn.model.set_value(me.frm.doctype, me.frm.docname,
|
||||
me.party.toLowerCase(), this.value);
|
||||
});
|
||||
},
|
||||
make_item_group: function() {
|
||||
@@ -120,7 +132,7 @@ erpnext.POS = Class.extend({
|
||||
"options": "Item Group",
|
||||
"label": "Item Group",
|
||||
"fieldname": "pos_item_group",
|
||||
"placeholder": "Filter by Item Group"
|
||||
"placeholder": "Item Group"
|
||||
},
|
||||
parent: this.wrapper.find(".item-group-area")
|
||||
});
|
||||
@@ -138,7 +150,7 @@ erpnext.POS = Class.extend({
|
||||
"options": "Item",
|
||||
"label": "Item",
|
||||
"fieldname": "pos_item",
|
||||
"placeholder": "Select Item"
|
||||
"placeholder": "Item"
|
||||
},
|
||||
parent: this.wrapper.find(".search-area")
|
||||
});
|
||||
@@ -155,7 +167,7 @@ erpnext.POS = Class.extend({
|
||||
"fieldtype": "Data",
|
||||
"label": "Barcode",
|
||||
"fieldname": "pos_barcode",
|
||||
"placeholder": "Select Barcode"
|
||||
"placeholder": "Barcode"
|
||||
},
|
||||
parent: this.wrapper.find(".barcode-area")
|
||||
});
|
||||
@@ -171,7 +183,8 @@ erpnext.POS = Class.extend({
|
||||
wn.call({
|
||||
method: 'accounts.doctype.sales_invoice.pos.get_items',
|
||||
args: {
|
||||
price_list: cur_frm.doc.selling_price_list,
|
||||
sales_or_purchase: this.sales_or_purchase,
|
||||
price_list: this.price_list,
|
||||
item_group: this.item_group.$input.val(),
|
||||
item: this.search.$input.val()
|
||||
},
|
||||
@@ -200,15 +213,18 @@ erpnext.POS = Class.extend({
|
||||
});
|
||||
|
||||
// if form is local then allow this function
|
||||
if (cur_frm.doc.docstatus===0) {
|
||||
$("div.pos-item").on("click", function() {
|
||||
if(!cur_frm.doc.customer) {
|
||||
msgprint("Please select customer first.");
|
||||
$(me.wrapper).find("div.pos-item").on("click", function() {
|
||||
if(me.frm.doc.docstatus==0) {
|
||||
if(!me.frm.doc[me.party.toLowerCase()] && ((me.frm.doctype == "Quotation" &&
|
||||
me.frm.doc.quotation_to == "Customer")
|
||||
|| me.frm.doctype != "Quotation")) {
|
||||
msgprint("Please select " + me.party + " first.");
|
||||
return;
|
||||
}
|
||||
me.add_to_cart($(this).attr("data-item_code"));
|
||||
});
|
||||
}
|
||||
else
|
||||
me.add_to_cart($(this).attr("data-item_code"));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -217,12 +233,12 @@ erpnext.POS = Class.extend({
|
||||
var caught = false;
|
||||
|
||||
// get no_of_items
|
||||
no_of_items = me.wrapper.find("#cart tbody").length;
|
||||
|
||||
var no_of_items = me.wrapper.find("#cart tbody tr").length;
|
||||
|
||||
// check whether the item is already added
|
||||
if (no_of_items != 0) {
|
||||
$.each(wn.model.get_children("Sales Invoice Item", this.frm.doc.name, "entries",
|
||||
"Sales Invoice"), function(i, d) {
|
||||
$.each(wn.model.get_children(this.frm.doctype + " Item", this.frm.doc.name,
|
||||
this.frm.cscript.fname, this.frm.doctype), function(i, d) {
|
||||
if (d.item_code == item_code)
|
||||
caught = true;
|
||||
});
|
||||
@@ -233,15 +249,16 @@ erpnext.POS = Class.extend({
|
||||
me.update_qty(item_code, 1);
|
||||
}
|
||||
else {
|
||||
var child = wn.model.add_child(me.frm.doc, "Sales Invoice Item", "entries");
|
||||
var child = wn.model.add_child(me.frm.doc, this.frm.doctype + " Item",
|
||||
this.frm.cscript.fname);
|
||||
child.item_code = item_code;
|
||||
me.frm.cscript.item_code(me.frm.doc, child.doctype, child.name);
|
||||
}
|
||||
},
|
||||
update_qty: function(item_code, qty, textbox_qty) {
|
||||
var me = this;
|
||||
$.each(wn.model.get_children("Sales Invoice Item", this.frm.doc.name, "entries",
|
||||
"Sales Invoice"), function(i, d) {
|
||||
$.each(wn.model.get_children(this.frm.doctype + " Item", this.frm.doc.name,
|
||||
this.frm.cscript.fname, this.frm.doctype), function(i, d) {
|
||||
if (d.item_code == item_code) {
|
||||
if (textbox_qty) {
|
||||
if (qty == 0 && d.item_code == item_code)
|
||||
@@ -259,14 +276,24 @@ erpnext.POS = Class.extend({
|
||||
},
|
||||
refresh: function() {
|
||||
var me = this;
|
||||
this.customer.set_input(this.frm.doc.customer);
|
||||
this.party_field.set_input(this.frm.doc[this.party.toLowerCase()]);
|
||||
this.barcode.set_input("");
|
||||
|
||||
// add items
|
||||
var $items = me.wrapper.find("#cart tbody").empty();
|
||||
|
||||
$.each(wn.model.get_children("Sales Invoice Item", this.frm.doc.name, "entries",
|
||||
"Sales Invoice"), function(i, d) {
|
||||
$.each(wn.model.get_children(this.frm.doctype + " Item", this.frm.doc.name,
|
||||
this.frm.cscript.fname, this.frm.doctype), function(i, d) {
|
||||
|
||||
if (me.sales_or_purchase == "Sales") {
|
||||
item_amount = d.export_amount;
|
||||
rate = d.export_rate;
|
||||
}
|
||||
else {
|
||||
item_amount = d.import_amount;
|
||||
rate = d.import_rate;
|
||||
}
|
||||
|
||||
$(repl('<tr id="%(item_code)s" data-selected="false">\
|
||||
<td>%(item_code)s%(item_name)s</td>\
|
||||
<td><input type="text" value="%(qty)s" \
|
||||
@@ -277,16 +304,16 @@ erpnext.POS = Class.extend({
|
||||
item_code: d.item_code,
|
||||
item_name: d.item_name===d.item_code ? "" : ("<br>" + d.item_name),
|
||||
qty: d.qty,
|
||||
rate: format_currency(d.ref_rate, cur_frm.doc.price_list_currency),
|
||||
amount: format_currency(d.export_amount, cur_frm.doc.price_list_currency)
|
||||
rate: format_currency(rate, me.frm.doc.currency),
|
||||
amount: format_currency(item_amount, me.frm.doc.currency)
|
||||
}
|
||||
)).appendTo($items);
|
||||
});
|
||||
|
||||
// taxes
|
||||
var taxes = wn.model.get_children("Sales Taxes and Charges", this.frm.doc.name, "other_charges",
|
||||
"Sales Invoice");
|
||||
$(".tax-table")
|
||||
var taxes = wn.model.get_children(this.sales_or_purchase + " Taxes and Charges",
|
||||
this.frm.doc.name, this.frm.cscript.other_fname, this.frm.doctype);
|
||||
$(this.wrapper).find(".tax-table")
|
||||
.toggle((taxes && taxes.length) ? true : false)
|
||||
.find("tbody").empty();
|
||||
|
||||
@@ -297,30 +324,39 @@ erpnext.POS = Class.extend({
|
||||
<tr>', {
|
||||
description: d.description,
|
||||
rate: d.rate,
|
||||
tax_amount: format_currency(d.tax_amount, me.frm.doc.price_list_currency)
|
||||
tax_amount: format_currency(flt(d.tax_amount)/flt(me.frm.doc.conversion_rate),
|
||||
me.frm.doc.currency)
|
||||
})).appendTo(".tax-table tbody");
|
||||
});
|
||||
|
||||
// set totals
|
||||
this.wrapper.find(".net-total").text(format_currency(this.frm.doc.net_total_export,
|
||||
cur_frm.doc.price_list_currency));
|
||||
this.wrapper.find(".grand-total").text(format_currency(this.frm.doc.grand_total_export,
|
||||
cur_frm.doc.price_list_currency));
|
||||
if (this.sales_or_purchase == "Sales") {
|
||||
this.wrapper.find(".net-total").text(format_currency(this.frm.doc.net_total_export,
|
||||
me.frm.doc.currency));
|
||||
this.wrapper.find(".grand-total").text(format_currency(this.frm.doc.grand_total_export,
|
||||
me.frm.doc.currency));
|
||||
}
|
||||
else {
|
||||
this.wrapper.find(".net-total").text(format_currency(this.frm.doc.net_total_import,
|
||||
me.frm.doc.currency));
|
||||
this.wrapper.find(".grand-total").text(format_currency(this.frm.doc.grand_total_import,
|
||||
me.frm.doc.currency));
|
||||
}
|
||||
|
||||
// if form is local then only run all these functions
|
||||
if (cur_frm.doc.docstatus===0) {
|
||||
$("input.qty").on("focus", function() {
|
||||
if (this.frm.doc.docstatus===0) {
|
||||
$(this.wrapper).find("input.qty").on("focus", function() {
|
||||
$(this).select();
|
||||
});
|
||||
|
||||
// append quantity to the respective item after change from input box
|
||||
$("input.qty").on("change", function() {
|
||||
$(this.wrapper).find("input.qty").on("change", function() {
|
||||
var item_code = $(this).closest("tr")[0].id;
|
||||
me.update_qty(item_code, $(this).val(), true);
|
||||
});
|
||||
|
||||
// on td click toggle the highlighting of row
|
||||
$("#cart tbody tr td").on("click", function() {
|
||||
$(this.wrapper).find("#cart tbody tr td").on("click", function() {
|
||||
var row = $(this).closest("tr");
|
||||
if (row.attr("data-selected") == "false") {
|
||||
row.attr("class", "warning");
|
||||
@@ -335,20 +371,37 @@ erpnext.POS = Class.extend({
|
||||
});
|
||||
|
||||
me.refresh_delete_btn();
|
||||
cur_frm.pos.barcode.$input.focus();
|
||||
this.barcode.$input.focus();
|
||||
}
|
||||
|
||||
// if form is submitted & cancelled then disable all input box & buttons
|
||||
if (cur_frm.doc.docstatus>=1 && cint(cur_frm.doc.is_pos)) {
|
||||
me.wrapper.find('input, button').each(function () {
|
||||
if (this.frm.doc.docstatus>=1) {
|
||||
$(this.wrapper).find('input, button').each(function () {
|
||||
$(this).prop('disabled', true);
|
||||
});
|
||||
$(".delete-items").hide();
|
||||
$(".make-payment").hide();
|
||||
$(this.wrapper).find(".delete-items").hide();
|
||||
$(this.wrapper).find(".make-payment").hide();
|
||||
}
|
||||
else {
|
||||
$(this.wrapper).find('input, button').each(function () {
|
||||
$(this).prop('disabled', false);
|
||||
});
|
||||
$(this.wrapper).find(".make-payment").show();
|
||||
}
|
||||
|
||||
// Show Make Payment button only in Sales Invoice
|
||||
if (this.frm.doctype != "Sales Invoice")
|
||||
$(this.wrapper).find(".make-payment").hide();
|
||||
|
||||
// If quotation to is not Customer then remove party
|
||||
if (this.frm.doctype == "Quotation") {
|
||||
this.party_field.$wrapper.remove();
|
||||
if (this.frm.doc.quotation_to == "Customer")
|
||||
this.make_party();
|
||||
}
|
||||
},
|
||||
refresh_delete_btn: function() {
|
||||
$(".delete-items").toggle($(".item-cart .warning").length ? true : false);
|
||||
$(this.wrapper).find(".delete-items").toggle($(".item-cart .warning").length ? true : false);
|
||||
},
|
||||
add_item_thru_barcode: function() {
|
||||
var me = this;
|
||||
@@ -370,32 +423,32 @@ erpnext.POS = Class.extend({
|
||||
remove_selected_item: function() {
|
||||
var me = this;
|
||||
var selected_items = [];
|
||||
var no_of_items = $("#cart tbody tr").length;
|
||||
var no_of_items = $(this.wrapper).find("#cart tbody tr").length;
|
||||
for(var x=0; x<=no_of_items - 1; x++) {
|
||||
var row = $("#cart tbody tr:eq(" + x + ")");
|
||||
var row = $(this.wrapper).find("#cart tbody tr:eq(" + x + ")");
|
||||
if(row.attr("data-selected") == "true") {
|
||||
selected_items.push(row.attr("id"));
|
||||
}
|
||||
}
|
||||
|
||||
var child = wn.model.get_children("Sales Invoice Item", this.frm.doc.name, "entries",
|
||||
"Sales Invoice");
|
||||
|
||||
var child = wn.model.get_children(this.frm.doctype + " Item", this.frm.doc.name,
|
||||
this.frm.cscript.fname, this.frm.doctype);
|
||||
|
||||
$.each(child, function(i, d) {
|
||||
for (var i in selected_items) {
|
||||
if (d.item_code == selected_items[i]) {
|
||||
// cur_frm.fields_dict["entries"].grid.grid_rows[d.idx].remove();
|
||||
wn.model.clear_doc(d.doctype, d.name);
|
||||
}
|
||||
}
|
||||
});
|
||||
cur_frm.fields_dict["entries"].grid.refresh();
|
||||
cur_frm.script_manager.trigger("calculate_taxes_and_totals");
|
||||
this.frm.fields_dict[this.frm.cscript.fname].grid.refresh();
|
||||
this.frm.script_manager.trigger("calculate_taxes_and_totals");
|
||||
me.frm.dirty();
|
||||
me.refresh();
|
||||
},
|
||||
make_payment: function() {
|
||||
var me = this;
|
||||
var no_of_items = $("#cart tbody tr").length;
|
||||
var no_of_items = $(this.wrapper).find("#cart tbody tr").length;
|
||||
var mode_of_payment = [];
|
||||
|
||||
if (no_of_items == 0)
|
||||
@@ -423,15 +476,15 @@ erpnext.POS = Class.extend({
|
||||
"total_amount": $(".grand-total").text()
|
||||
});
|
||||
dialog.show();
|
||||
cur_frm.pos.barcode.$input.focus();
|
||||
me.barcode.$input.focus();
|
||||
|
||||
dialog.get_input("total_amount").prop("disabled", true);
|
||||
|
||||
dialog.fields_dict.pay.input.onclick = function() {
|
||||
cur_frm.set_value("mode_of_payment", dialog.get_values().mode_of_payment);
|
||||
cur_frm.set_value("paid_amount", dialog.get_values().total_amount);
|
||||
cur_frm.cscript.mode_of_payment(cur_frm.doc);
|
||||
cur_frm.save();
|
||||
me.frm.set_value("mode_of_payment", dialog.get_values().mode_of_payment);
|
||||
me.frm.set_value("paid_amount", dialog.get_values().total_amount);
|
||||
me.frm.cscript.mode_of_payment(me.frm.doc);
|
||||
me.frm.save();
|
||||
dialog.hide();
|
||||
me.refresh();
|
||||
};
|
||||
|
||||
@@ -3,17 +3,21 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import msgprint
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_items(price_list, item=None, item_group=None):
|
||||
def get_items(price_list, sales_or_purchase, item=None, item_group=None):
|
||||
condition = ""
|
||||
|
||||
if sales_or_purchase == "Sales":
|
||||
condition = "i.is_sales_item='Yes'"
|
||||
else:
|
||||
condition = "i.is_purchase_item='Yes'"
|
||||
|
||||
if item_group and item_group != "All Item Groups":
|
||||
condition = "and i.item_group='%s'" % item_group
|
||||
condition += " and i.item_group='%s'" % item_group
|
||||
|
||||
if item:
|
||||
condition = "and i.name='%s'" % item
|
||||
condition += " and i.name='%s'" % item
|
||||
|
||||
return webnotes.conn.sql("""select i.name, i.item_name, i.image,
|
||||
pl_items.ref_rate, pl_items.currency
|
||||
@@ -24,13 +28,18 @@ def get_items(price_list, item=None, item_group=None):
|
||||
ON
|
||||
pl_items.item_code=i.name
|
||||
where
|
||||
i.is_sales_item='Yes'%s""" % ('%s', condition), (price_list), as_dict=1)
|
||||
%s""" % ('%s', condition), (price_list), as_dict=1)
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_item_from_barcode(barcode):
|
||||
return webnotes.conn.sql("""select name from `tabItem` where barcode=%s""",
|
||||
(barcode), as_dict=1)
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_item_from_serial_no(serial_no):
|
||||
return webnotes.conn.sql("""select name, item_code from `tabSerial No` where
|
||||
name=%s""", (serial_no), as_dict=1)
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_mode_of_payment():
|
||||
return webnotes.conn.sql("""select name from `tabMode of Payment`""", as_dict=1)
|
||||
@@ -1,15 +0,0 @@
|
||||
.pos-item {
|
||||
height: 200px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
padding-left: 5px !important;
|
||||
padding-right: 5px !important;
|
||||
}
|
||||
|
||||
.pos-bill {
|
||||
padding: 20px 5px;
|
||||
font-family: Monospace;
|
||||
border: 1px solid #eee;
|
||||
-webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
|
||||
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
|
||||
}
|
||||
@@ -29,9 +29,10 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
||||
// toggle to pos view if is_pos is 1 in user_defaults
|
||||
if ((cint(wn.defaults.get_user_defaults("is_pos"))===1 || cur_frm.doc.is_pos) &&
|
||||
cint(wn.defaults.get_user_defaults("fs_pos_view"))===1) {
|
||||
this.frm.set_value("is_pos", 1);
|
||||
this.is_pos();
|
||||
cur_frm.cscript.toggle_pos(true);
|
||||
if(this.frm.doc.__islocal && !this.frm.doc.amended_from) {
|
||||
this.frm.set_value("is_pos", 1);
|
||||
this.is_pos(function() {cur_frm.cscript.toggle_pos(true);});
|
||||
}
|
||||
}
|
||||
|
||||
// if document is POS then change default print format to "POS Invoice"
|
||||
@@ -78,14 +79,11 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
||||
cur_frm.add_custom_button(wn._('Make Payment Entry'), cur_frm.cscript.make_bank_voucher);
|
||||
}
|
||||
|
||||
if (doc.docstatus===0) {
|
||||
// Show buttons only when pos view is active
|
||||
if (doc.docstatus===0 && !this.pos_active) {
|
||||
cur_frm.cscript.sales_order_btn();
|
||||
cur_frm.cscript.delivery_note_btn();
|
||||
}
|
||||
|
||||
// Show POS button only if it enabled from features setup
|
||||
if(cint(sys_defaults.fs_pos_view)===1)
|
||||
cur_frm.cscript.pos_btn();
|
||||
},
|
||||
|
||||
sales_order_btn: function() {
|
||||
@@ -124,62 +122,13 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
pos_btn: function() {
|
||||
if(cur_frm.$pos_btn)
|
||||
cur_frm.$pos_btn.remove();
|
||||
|
||||
if(!cur_frm.pos_active) {
|
||||
var btn_label = wn._("POS View"),
|
||||
icon = "icon-desktop";
|
||||
|
||||
cur_frm.cscript.sales_order_btn();
|
||||
cur_frm.cscript.delivery_note_btn();
|
||||
} else {
|
||||
var btn_label = wn._("Invoice View"),
|
||||
icon = "icon-file-text";
|
||||
|
||||
if (cur_frm.doc.docstatus===0) {
|
||||
this.$delivery_note_btn.remove();
|
||||
this.$sales_order_btn.remove();
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.$pos_btn = cur_frm.add_custom_button(btn_label, function() {
|
||||
cur_frm.cscript.toggle_pos();
|
||||
cur_frm.cscript.pos_btn();
|
||||
}, icon);
|
||||
},
|
||||
|
||||
toggle_pos: function(show) {
|
||||
if (!this.frm.doc.selling_price_list)
|
||||
msgprint(wn._("Please select Price List"))
|
||||
else {
|
||||
if((show===true && cur_frm.pos_active) || (show===false && !cur_frm.pos_active)) return;
|
||||
|
||||
// make pos
|
||||
if(!cur_frm.pos) {
|
||||
cur_frm.layout.add_view("pos");
|
||||
cur_frm.pos = new erpnext.POS(cur_frm.layout.views.pos, cur_frm);
|
||||
}
|
||||
|
||||
// toggle view
|
||||
cur_frm.layout.set_view(cur_frm.pos_active ? "" : "pos");
|
||||
cur_frm.pos_active = !cur_frm.pos_active;
|
||||
|
||||
// refresh
|
||||
if(cur_frm.pos_active)
|
||||
cur_frm.pos.refresh();
|
||||
}
|
||||
},
|
||||
|
||||
tc_name: function() {
|
||||
this.get_terms();
|
||||
},
|
||||
|
||||
is_pos: function() {
|
||||
is_pos: function(callback_fn) {
|
||||
cur_frm.cscript.hide_fields(this.frm.doc);
|
||||
|
||||
if(cint(this.frm.doc.is_pos)) {
|
||||
if(!this.frm.doc.company) {
|
||||
this.frm.set_value("is_pos", 0);
|
||||
@@ -192,6 +141,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
||||
callback: function(r) {
|
||||
if(!r.exc) {
|
||||
me.frm.script_manager.trigger("update_stock");
|
||||
if(callback_fn) callback_fn()
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -256,7 +206,6 @@ cur_frm.cscript.hide_fields = function(doc) {
|
||||
'total_commission', 'advances'];
|
||||
|
||||
item_flds_normal = ['sales_order', 'delivery_note']
|
||||
item_flds_pos = ['serial_no', 'batch_no', 'actual_qty', 'expense_account']
|
||||
|
||||
if(cint(doc.is_pos) == 1) {
|
||||
hide_field(par_flds);
|
||||
@@ -271,7 +220,9 @@ cur_frm.cscript.hide_fields = function(doc) {
|
||||
cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_normal, true);
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_pos, (cint(doc.update_stock)==1?true:false));
|
||||
item_flds_stock = ['serial_no', 'batch_no', 'actual_qty', 'expense_account', 'warehouse']
|
||||
cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_stock,
|
||||
(cint(doc.update_stock)==1 ? true : false));
|
||||
|
||||
// India related fields
|
||||
var cp = wn.control_panel;
|
||||
|
||||
@@ -83,7 +83,6 @@ class DocType(SellingController):
|
||||
def on_submit(self):
|
||||
if cint(self.doc.update_stock) == 1:
|
||||
self.update_stock_ledger()
|
||||
self.update_serial_nos()
|
||||
else:
|
||||
# Check for Approving Authority
|
||||
if not self.doc.recurring_id:
|
||||
@@ -111,7 +110,6 @@ class DocType(SellingController):
|
||||
def on_cancel(self):
|
||||
if cint(self.doc.update_stock) == 1:
|
||||
self.update_stock_ledger()
|
||||
self.update_serial_nos(cancel = True)
|
||||
|
||||
sales_com_obj = get_obj(dt = 'Sales Common')
|
||||
sales_com_obj.check_stop_sales_order(self)
|
||||
@@ -195,7 +193,7 @@ class DocType(SellingController):
|
||||
pos = get_pos_settings(self.doc.company)
|
||||
|
||||
if pos:
|
||||
if not for_validate:
|
||||
if not for_validate and not self.doc.customer:
|
||||
self.doc.customer = pos.customer
|
||||
self.set_customer_defaults()
|
||||
|
||||
@@ -266,13 +264,7 @@ class DocType(SellingController):
|
||||
|
||||
def get_adj_percent(self, arg=''):
|
||||
"""Fetch ref rate from item master as per selected price list"""
|
||||
get_obj('Sales Common').get_adj_percent(self)
|
||||
|
||||
|
||||
def get_rate(self,arg):
|
||||
"""Get tax rate if account type is tax"""
|
||||
get_obj('Sales Common').get_rate(arg)
|
||||
|
||||
get_obj('Sales Common').get_adj_percent(self)
|
||||
|
||||
def get_comm_rate(self, sales_partner):
|
||||
"""Get Commission rate of Sales Partner"""
|
||||
@@ -965,8 +957,7 @@ def make_delivery_note(source_name, target_doclist=None):
|
||||
"doctype": "Delivery Note Item",
|
||||
"field_map": {
|
||||
"name": "prevdoc_detail_docname",
|
||||
"parent": "prevdoc_docname",
|
||||
"parenttype": "prevdoc_doctype",
|
||||
"parent": "against_sales_invoice",
|
||||
"serial_no": "serial_no"
|
||||
},
|
||||
"postprocess": update_item
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
{
|
||||
"creation": "2013-05-24 19:29:05",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-09-01 05:26:13",
|
||||
"modified": "2013-10-11 13:12:38",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"allow_attach": 1,
|
||||
"allow_import": 1,
|
||||
"autoname": "naming_series:",
|
||||
"default_print_format": "Standard",
|
||||
"doctype": "DocType",
|
||||
@@ -225,7 +226,6 @@
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"default": "1.00",
|
||||
"description": "Rate at which Customer Currency is converted to customer's base currency",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "conversion_rate",
|
||||
@@ -411,7 +411,7 @@
|
||||
"doctype": "DocField",
|
||||
"fieldname": "other_charges",
|
||||
"fieldtype": "Table",
|
||||
"label": "Taxes and Charges1",
|
||||
"label": "Sales Taxes and Charges",
|
||||
"oldfieldname": "other_charges",
|
||||
"oldfieldtype": "Table",
|
||||
"options": "Sales Taxes and Charges",
|
||||
|
||||
@@ -641,8 +641,8 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
|
||||
return new_si
|
||||
|
||||
# if yearly, test 3 repetitions, else test 13 repetitions
|
||||
count = 3 if no_of_months == 12 else 13
|
||||
# if yearly, test 1 repetition, else test 5 repetitions
|
||||
count = 1 if (no_of_months == 12) else 5
|
||||
for i in xrange(count):
|
||||
base_si = _test(i)
|
||||
|
||||
@@ -653,7 +653,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
|
||||
def test_serialized(self):
|
||||
from stock.doctype.stock_entry.test_stock_entry import make_serialized_item
|
||||
from stock.doctype.stock_ledger_entry.stock_ledger_entry import get_serial_nos
|
||||
from stock.doctype.serial_no.serial_no import get_serial_nos
|
||||
|
||||
se = make_serialized_item()
|
||||
serial_nos = get_serial_nos(se.doclist[1].serial_no)
|
||||
@@ -674,7 +674,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
return si
|
||||
|
||||
def test_serialized_cancel(self):
|
||||
from stock.doctype.stock_ledger_entry.stock_ledger_entry import get_serial_nos
|
||||
from stock.doctype.serial_no.serial_no import get_serial_nos
|
||||
si = self.test_serialized()
|
||||
si.cancel()
|
||||
|
||||
@@ -686,7 +686,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
"delivery_document_no"))
|
||||
|
||||
def test_serialize_status(self):
|
||||
from stock.doctype.stock_ledger_entry.stock_ledger_entry import SerialNoStatusError, get_serial_nos
|
||||
from stock.doctype.serial_no.serial_no import SerialNoStatusError, get_serial_nos
|
||||
from stock.doctype.stock_entry.test_stock_entry import make_serialized_item
|
||||
|
||||
se = make_serialized_item()
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
//--------- ONLOAD -------------
|
||||
|
||||
wn.require("app/js/controllers/accounts.js");
|
||||
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
if(doc.doctype === "Sales Taxes and Charges Master")
|
||||
erpnext.add_for_territory();
|
||||
@@ -142,6 +145,7 @@ cur_frm.fields_dict['other_charges'].grid.get_field("cost_center").get_query = f
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
|
||||
cur_frm.cscript.account_head = function(doc, cdt, cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
@@ -157,6 +161,8 @@ cur_frm.cscript.account_head = function(doc, cdt, cdn) {
|
||||
refresh_field('account_head',d.name,'other_charges');
|
||||
}
|
||||
|
||||
=======
|
||||
>>>>>>> f146e8b7f52a3e46e335c0fefd92c347717b370b
|
||||
cur_frm.cscript.rate = function(doc, cdt, cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
if(!d.charge_type && d.rate) {
|
||||
|
||||
@@ -6,11 +6,7 @@ import webnotes
|
||||
from webnotes.utils import cint
|
||||
from webnotes.model.controller import DocListController
|
||||
|
||||
class DocType(DocListController):
|
||||
def get_rate(self, arg):
|
||||
from webnotes.model.code import get_obj
|
||||
return get_obj('Sales Common').get_rate(arg)
|
||||
|
||||
class DocType(DocListController):
|
||||
def validate(self):
|
||||
if self.doc.is_default == 1:
|
||||
webnotes.conn.sql("""update `tabSales Taxes and Charges Master` set is_default = 0
|
||||
|
||||
@@ -15,7 +15,7 @@ def get_companies():
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_children():
|
||||
args = webnotes.form_dict
|
||||
args = webnotes.local.form_dict
|
||||
ctype, company = args['ctype'], args['comp']
|
||||
|
||||
# root
|
||||
|
||||
@@ -64,10 +64,10 @@ def upload():
|
||||
|
||||
data, start_idx = get_data(rows, company_abbr, rows[0][0])
|
||||
except Exception, e:
|
||||
err_msg = webnotes.message_log and "<br>".join(webnotes.message_log) or cstr(e)
|
||||
err_msg = webnotes.local.message_log and "<br>".join(webnotes.local.message_log) or cstr(e)
|
||||
messages.append("""<p style='color: red'>%s</p>""" % (err_msg or "No message"))
|
||||
webnotes.errprint(webnotes.getTraceback())
|
||||
webnotes.message_log = []
|
||||
webnotes.local.message_log = []
|
||||
return messages
|
||||
|
||||
return import_vouchers(common_values, data, start_idx, rows[0][0])
|
||||
@@ -117,11 +117,11 @@ def import_vouchers(common_values, data, start_idx, import_type):
|
||||
|
||||
d = data[i][0]
|
||||
if import_type == "Voucher Import: Two Accounts" and flt(d.get("amount")) == 0:
|
||||
webnotes.message_log = ["Amount not specified"]
|
||||
webnotes.local.message_log = ["Amount not specified"]
|
||||
raise Exception
|
||||
elif import_type == "Voucher Import: Multiple Accounts" and \
|
||||
(flt(d.get("total_debit")) == 0 or flt(d.get("total_credit")) == 0):
|
||||
webnotes.message_log = ["Total Debit and Total Credit amount can not be zero"]
|
||||
webnotes.local.message_log = ["Total Debit and Total Credit amount can not be zero"]
|
||||
raise Exception
|
||||
else:
|
||||
d.posting_date = parse_date(d.posting_date)
|
||||
@@ -174,7 +174,7 @@ def import_vouchers(common_values, data, start_idx, import_type):
|
||||
details.append(detail)
|
||||
|
||||
if not details:
|
||||
webnotes.message_log = ["""No accounts found.
|
||||
webnotes.local.message_log = ["""No accounts found.
|
||||
If you entered accounts correctly, please check template once"""]
|
||||
raise Exception
|
||||
|
||||
@@ -193,12 +193,12 @@ def import_vouchers(common_values, data, start_idx, import_type):
|
||||
webnotes.conn.commit()
|
||||
except Exception, e:
|
||||
webnotes.conn.rollback()
|
||||
err_msg = webnotes.message_log and "<br>".join(webnotes.message_log) or cstr(e)
|
||||
err_msg = webnotes.local.message_log and "<br>".join(webnotes.local.message_log) or cstr(e)
|
||||
messages.append("""<p style='color: red'>[row #%s] %s failed: %s</p>"""
|
||||
% ((start_idx + 1) + i, jv.name or "", err_msg or "No message"))
|
||||
messages.append("<p style='color: red'>All transactions rolled back</p>")
|
||||
webnotes.errprint(webnotes.getTraceback())
|
||||
webnotes.message_log = []
|
||||
webnotes.local.message_log = []
|
||||
|
||||
return messages
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ def get_stock_ledger_entries(filters):
|
||||
from `tabStock Ledger Entry`"""
|
||||
|
||||
if filters.get("company"):
|
||||
query += """ and company=%(company)s"""
|
||||
query += """ where company=%(company)s"""
|
||||
|
||||
query += " order by item_code desc, warehouse desc, posting_date desc, posting_time desc, name desc"
|
||||
|
||||
|
||||
@@ -81,12 +81,12 @@ def get_tax_accounts(item_list, columns):
|
||||
if account_head not in tax_accounts:
|
||||
tax_accounts.append(account_head)
|
||||
|
||||
invoice = item_tax.setdefault(parent, {})
|
||||
if item_wise_tax_detail:
|
||||
try:
|
||||
item_wise_tax_detail = json.loads(item_wise_tax_detail)
|
||||
for item, tax_amount in item_wise_tax_detail.items():
|
||||
invoice.setdefault(item, {})[account_head] = flt(tax_amount)
|
||||
item_tax.setdefault(parent, {}).setdefault(item, {})[account_head] = \
|
||||
flt(tax_amount[1])
|
||||
|
||||
except ValueError:
|
||||
continue
|
||||
|
||||
@@ -9,7 +9,7 @@ def execute(filters=None):
|
||||
if not filters: filters = {}
|
||||
columns = get_columns()
|
||||
last_col = len(columns)
|
||||
|
||||
|
||||
item_list = get_items(filters)
|
||||
item_tax, tax_accounts = get_tax_accounts(item_list, columns)
|
||||
|
||||
@@ -21,7 +21,7 @@ def execute(filters=None):
|
||||
|
||||
for tax in tax_accounts:
|
||||
row.append(item_tax.get(d.parent, {}).get(d.item_code, {}).get(tax, 0))
|
||||
|
||||
|
||||
total_tax = sum(row[last_col:])
|
||||
row += [total_tax, d.amount + total_tax]
|
||||
|
||||
@@ -71,19 +71,19 @@ def get_tax_accounts(item_list, columns):
|
||||
tax_details = webnotes.conn.sql("""select parent, account_head, item_wise_tax_detail
|
||||
from `tabSales Taxes and Charges` where parenttype = 'Sales Invoice'
|
||||
and docstatus = 1 and ifnull(account_head, '') != ''
|
||||
and parent in (%s)""" % ', '.join(['%s']*len(item_list)), tuple([item.parent for item in item_list]))
|
||||
and parent in (%s)""" % ', '.join(['%s']*len(item_list)),
|
||||
tuple([item.parent for item in item_list]))
|
||||
|
||||
for parent, account_head, item_wise_tax_detail in tax_details:
|
||||
if account_head not in tax_accounts:
|
||||
tax_accounts.append(account_head)
|
||||
|
||||
invoice = item_tax.setdefault(parent, {})
|
||||
|
||||
if item_wise_tax_detail:
|
||||
try:
|
||||
item_wise_tax_detail = json.loads(item_wise_tax_detail)
|
||||
for item, tax_amount in item_wise_tax_detail.items():
|
||||
invoice.setdefault(item, {})[account_head] = flt(tax_amount)
|
||||
|
||||
item_tax.setdefault(parent, {}).setdefault(item, {})[account_head] = \
|
||||
flt(tax_amount[1])
|
||||
except ValueError:
|
||||
continue
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ def get_balance_on(account=None, date=None):
|
||||
@webnotes.whitelist()
|
||||
def add_ac(args=None):
|
||||
if not args:
|
||||
args = webnotes.form_dict
|
||||
args = webnotes.local.form_dict
|
||||
args.pop("cmd")
|
||||
|
||||
ac = webnotes.bean(args)
|
||||
@@ -121,7 +121,7 @@ def add_ac(args=None):
|
||||
@webnotes.whitelist()
|
||||
def add_cc(args=None):
|
||||
if not args:
|
||||
args = webnotes.form_dict
|
||||
args = webnotes.local.form_dict
|
||||
args.pop("cmd")
|
||||
|
||||
cc = webnotes.bean(args)
|
||||
|
||||
Reference in New Issue
Block a user