Merge branch 'stable' of github.com:webnotes/erpnext
This commit is contained in:
commit
043b0f26bd
@ -1,4 +1,6 @@
|
|||||||
import webnotes
|
import webnotes
|
||||||
|
from webnotes.utils import flt
|
||||||
|
from webnotes.model.code import get_obj
|
||||||
|
|
||||||
def get_default_bank_account():
|
def get_default_bank_account():
|
||||||
"""
|
"""
|
||||||
@ -11,3 +13,208 @@ def get_default_bank_account():
|
|||||||
WHERE name=%s AND docstatus<2""", company)
|
WHERE name=%s AND docstatus<2""", company)
|
||||||
|
|
||||||
if res: return res[0][0]
|
if res: return res[0][0]
|
||||||
|
|
||||||
|
|
||||||
|
def get_new_jv_details():
|
||||||
|
"""
|
||||||
|
Get details which will help create new jv on sales/purchase return
|
||||||
|
"""
|
||||||
|
doclist = webnotes.form_dict.get('doclist')
|
||||||
|
fiscal_year = webnotes.form_dict.get('fiscal_year')
|
||||||
|
if not (isinstance(doclist, basestring) and isinstance(fiscal_year, basestring)): return
|
||||||
|
|
||||||
|
import json
|
||||||
|
doclist = json.loads(doclist)
|
||||||
|
doc, children = doclist[0], doclist[1:]
|
||||||
|
|
||||||
|
if doc.get('return_type')=='Sales Return':
|
||||||
|
if doc.get('sales_invoice_no'):
|
||||||
|
return get_invoice_details(doc, children, fiscal_year)
|
||||||
|
elif doc.get('delivery_note_no'):
|
||||||
|
return get_delivery_note_details(doc, children, fiscal_year)
|
||||||
|
|
||||||
|
elif doc.get('purchase_receipt_no'):
|
||||||
|
return get_purchase_receipt_details(doc, children, fiscal_year)
|
||||||
|
|
||||||
|
|
||||||
|
def get_invoice_details(doc, children, fiscal_year):
|
||||||
|
"""
|
||||||
|
Gets details from an invoice to make new jv
|
||||||
|
Returns [{
|
||||||
|
'account': ,
|
||||||
|
'balance': ,
|
||||||
|
'debit': ,
|
||||||
|
'credit': ,
|
||||||
|
'against_invoice': ,
|
||||||
|
'against_payable':
|
||||||
|
}, { ... }, ...]
|
||||||
|
"""
|
||||||
|
if doc.get('return_type')=='Sales Return':
|
||||||
|
obj = get_obj('Receivable Voucher', doc.get('sales_invoice_no'), with_children=1)
|
||||||
|
else:
|
||||||
|
obj = get_obj('Payable Voucher', doc.get('purchase_invoice_no'), with_children=1)
|
||||||
|
if not obj.doc.docstatus==1: return
|
||||||
|
|
||||||
|
# Build invoice account jv detail record
|
||||||
|
invoice_rec = get_invoice_account_jv_record(doc, children, fiscal_year, obj)
|
||||||
|
|
||||||
|
# Build item accountwise jv detail records
|
||||||
|
item_accountwise_list = get_item_accountwise_jv_record(doc, children, fiscal_year, obj)
|
||||||
|
|
||||||
|
return [invoice_rec] + item_accountwise_list
|
||||||
|
|
||||||
|
|
||||||
|
def get_invoice_account_jv_record(doc, children, fiscal_year, obj):
|
||||||
|
"""
|
||||||
|
Build customer/supplier account jv detail record
|
||||||
|
"""
|
||||||
|
# Calculate total return amount
|
||||||
|
total_amt = sum([(flt(ch.get('rate')) * flt(ch.get('returned_qty'))) for ch in children])
|
||||||
|
|
||||||
|
ret = {}
|
||||||
|
|
||||||
|
if doc.get('return_type')=='Sales Return':
|
||||||
|
account = obj.doc.debit_to
|
||||||
|
ret['against_invoice'] = doc.get('sales_invoice_no')
|
||||||
|
ret['credit'] = total_amt
|
||||||
|
else:
|
||||||
|
account = obj.doc.credit_to
|
||||||
|
ret['against_voucher'] = doc.get('purchase_invoice_no')
|
||||||
|
ret['debit'] = total_amt
|
||||||
|
|
||||||
|
ret.update({
|
||||||
|
'account': account,
|
||||||
|
'balance': get_obj('GL Control').get_bal(account + "~~~" + fiscal_year)
|
||||||
|
})
|
||||||
|
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
def get_item_accountwise_jv_record(doc, children, fiscal_year, obj):
|
||||||
|
"""
|
||||||
|
Build item accountwise jv detail records
|
||||||
|
"""
|
||||||
|
if doc.get('return_type')=='Sales Return':
|
||||||
|
amt_field = 'debit'
|
||||||
|
ac_field = 'income_account'
|
||||||
|
else:
|
||||||
|
amt_field = 'credit'
|
||||||
|
ac_field = 'expense_head'
|
||||||
|
|
||||||
|
inv_children = dict([[ic.fields.get('item_code'), ic] for ic in obj.doclist if ic.fields.get('item_code')])
|
||||||
|
|
||||||
|
accwise_list = []
|
||||||
|
|
||||||
|
for ch in children:
|
||||||
|
inv_ch = inv_children.get(ch.get('item_code'))
|
||||||
|
if not inv_ch: continue
|
||||||
|
|
||||||
|
amount = flt(ch.get('rate')) * flt(ch.get('returned_qty'))
|
||||||
|
|
||||||
|
accounts = [[jvd['account'], jvd['cost_center']] for jvd in accwise_list]
|
||||||
|
|
||||||
|
if [inv_ch.fields.get(ac_field), inv_ch.fields.get('cost_center')] not in accounts:
|
||||||
|
rec = {
|
||||||
|
'account': inv_ch.fields.get(ac_field),
|
||||||
|
'cost_center': inv_ch.fields.get('cost_center'),
|
||||||
|
'balance': get_obj('GL Control').get_bal(inv_ch.fields.get(ac_field) + "~~~" + fiscal_year)
|
||||||
|
}
|
||||||
|
rec[amt_field] = amount
|
||||||
|
accwise_list.append(rec)
|
||||||
|
else:
|
||||||
|
rec = accwise_list[accounts.index([inv_ch.fields.get(ac_field), inv_ch.fields.get('cost_center')])]
|
||||||
|
rec[amt_field] = rec[amt_field] + amount
|
||||||
|
|
||||||
|
return accwise_list
|
||||||
|
|
||||||
|
|
||||||
|
def get_jv_details_from_inv_list(doc, children, fiscal_year, inv_list, jv_details_list):
|
||||||
|
"""
|
||||||
|
Get invoice details and make jv detail records
|
||||||
|
"""
|
||||||
|
for inv in inv_list:
|
||||||
|
if not inv[0]: continue
|
||||||
|
|
||||||
|
if doc.get('return_type')=='Sales Return':
|
||||||
|
doc['sales_invoice_no'] = inv[0]
|
||||||
|
else:
|
||||||
|
doc['purchase_invoice_no'] = inv[0]
|
||||||
|
|
||||||
|
jv_details = get_invoice_details(doc, children, fiscal_year)
|
||||||
|
|
||||||
|
if jv_details and len(jv_details)>1: jv_details_list.extend(jv_details)
|
||||||
|
|
||||||
|
return jv_details_list
|
||||||
|
|
||||||
|
|
||||||
|
def get_prev_doc_list(obj, prev_doctype):
|
||||||
|
"""
|
||||||
|
Returns a list of previous doc's names
|
||||||
|
"""
|
||||||
|
prevdoc_list = []
|
||||||
|
for ch in obj.doclist:
|
||||||
|
if ch.fields.get('prevdoc_docname') and ch.fields.get('prevdoc_doctype')==prev_doctype:
|
||||||
|
prevdoc_list.append(ch.fields.get('prevdoc_docname'))
|
||||||
|
return prevdoc_list
|
||||||
|
|
||||||
|
|
||||||
|
def get_inv_list(table, field, value):
|
||||||
|
"""
|
||||||
|
Returns invoice list
|
||||||
|
"""
|
||||||
|
if isinstance(value, basestring):
|
||||||
|
return webnotes.conn.sql("""\
|
||||||
|
SELECT DISTINCT parent FROM `%s`
|
||||||
|
WHERE %s='%s' AND docstatus=1""" % (table, field, value))
|
||||||
|
elif isinstance(value, list):
|
||||||
|
return webnotes.conn.sql("""\
|
||||||
|
SELECT DISTINCT parent FROM `%s`
|
||||||
|
WHERE %s IN ("%s") AND docstatus=1""" % (table, field, '", "'.join(value)))
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
def get_delivery_note_details(doc, children, fiscal_year):
|
||||||
|
"""
|
||||||
|
Gets sales invoice numbers from delivery note details
|
||||||
|
and returns detail records for jv
|
||||||
|
"""
|
||||||
|
jv_details_list = []
|
||||||
|
|
||||||
|
dn_obj = get_obj('Delivery Note', doc['delivery_note_no'], with_children=1)
|
||||||
|
|
||||||
|
inv_list = get_inv_list('tabRV Detail', 'delivery_note', doc['delivery_note_no'])
|
||||||
|
|
||||||
|
if inv_list:
|
||||||
|
jv_details_list = get_jv_details_from_inv_list(doc, children, fiscal_year, inv_list, jv_details_list)
|
||||||
|
|
||||||
|
if not (inv_list and jv_details_list):
|
||||||
|
so_list = get_prev_doc_list(dn_obj, 'Sales Order')
|
||||||
|
inv_list = get_inv_list('tabRV Detail', 'sales_order', so_list)
|
||||||
|
if inv_list:
|
||||||
|
jv_details_list = get_jv_details_from_inv_list(doc, children, fiscal_year, inv_list, jv_details_list)
|
||||||
|
|
||||||
|
return jv_details_list
|
||||||
|
|
||||||
|
|
||||||
|
def get_purchase_receipt_details(doc, children, fiscal_year):
|
||||||
|
"""
|
||||||
|
Gets purchase invoice numbers from purchase receipt details
|
||||||
|
and returns detail records for jv
|
||||||
|
"""
|
||||||
|
jv_details_list = []
|
||||||
|
|
||||||
|
pr_obj = get_obj('Purchase Receipt', doc['purchase_receipt_no'], with_children=1)
|
||||||
|
|
||||||
|
inv_list = get_inv_list('tabPV Detail', 'purchase_receipt', doc['purchase_receipt_no'])
|
||||||
|
|
||||||
|
if inv_list:
|
||||||
|
jv_details_list = get_jv_details_from_inv_list(doc, children, fiscal_year, inv_list, jv_details_list)
|
||||||
|
|
||||||
|
if not (inv_list and jv_details_list):
|
||||||
|
po_list = get_prev_doc_list(pr_obj, 'Purchase Order')
|
||||||
|
inv_list = get_inv_list('tabPV Detail', 'purchase_order', po_list)
|
||||||
|
if inv_list:
|
||||||
|
jv_details_list = get_jv_details_from_inv_list(doc, children, fiscal_year, inv_list, jv_details_list)
|
||||||
|
|
||||||
|
return jv_details_list
|
||||||
|
@ -61,12 +61,16 @@ cur_frm.cscript.supplier = function(doc,dt,dn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var callback2 = function(r,rt){
|
var callback2 = function(r,rt){
|
||||||
var doc = locals[cur_frm.doctype][cur_frm.docname];
|
var doc = locals[cur_frm.doctype][cur_frm.docname];
|
||||||
var el = getchildren('PV Detail',doc.name,'entries');
|
var el = getchildren('PV Detail',doc.name,'entries');
|
||||||
for(var i in el){
|
for(var i in el){
|
||||||
if(el[i].item_code && (!el[i].expense_head || !el[i].cost_center)){
|
if(el[i].item_code && (!el[i].expense_head || !el[i].cost_center)){
|
||||||
args = "{'item_code':'" + el[i].item_code + "','expense_head':'" + el[i].expense_head + "','cost_center':'" + el[i].cost_center + "'}";
|
args = {
|
||||||
get_server_fields('get_default_values', args, 'entries', doc, el[i].doctype, el[i].name, 1);
|
item_code: el[i].item_code,
|
||||||
|
expense_head: el[i].expense_head,
|
||||||
|
cost_center: el[i].cost_center
|
||||||
|
};
|
||||||
|
get_server_fields('get_default_values', JSON.stringify(args), 'entries', doc, el[i].doctype, el[i].name, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cur_frm.cscript.calc_amount(doc, 1);
|
cur_frm.cscript.calc_amount(doc, 1);
|
||||||
|
@ -61,7 +61,8 @@ class DocType(TransactionBase):
|
|||||||
# Get Default Cost Center and Expense Head from Item Master
|
# Get Default Cost Center and Expense Head from Item Master
|
||||||
# ----------------------------------------------------------
|
# ----------------------------------------------------------
|
||||||
def get_default_values(self,args):
|
def get_default_values(self,args):
|
||||||
args = eval(args)
|
import json
|
||||||
|
args = json.loads(args)
|
||||||
ret = {}
|
ret = {}
|
||||||
if sql("select name from `tabItem` where name = '%s'" % args['item_code']):
|
if sql("select name from `tabItem` where name = '%s'" % args['item_code']):
|
||||||
if not args['expense_head'] or args['expense_head'] == 'undefined':
|
if not args['expense_head'] or args['expense_head'] == 'undefined':
|
||||||
@ -105,6 +106,7 @@ class DocType(TransactionBase):
|
|||||||
|
|
||||||
|
|
||||||
def get_pv_details(self, arg):
|
def get_pv_details(self, arg):
|
||||||
|
import json
|
||||||
item_det = sql("select item_name, brand, description, item_group,purchase_account,cost_center from tabItem where name=%s",arg,as_dict=1)
|
item_det = sql("select item_name, brand, description, item_group,purchase_account,cost_center from tabItem where name=%s",arg,as_dict=1)
|
||||||
tax = sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , arg)
|
tax = sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , arg)
|
||||||
t = {}
|
t = {}
|
||||||
@ -119,7 +121,7 @@ class DocType(TransactionBase):
|
|||||||
'amount' : 0.00,
|
'amount' : 0.00,
|
||||||
'expense_head' : item_det and item_det[0]['purchase_account'] or '',
|
'expense_head' : item_det and item_det[0]['purchase_account'] or '',
|
||||||
'cost_center' : item_det and item_det[0]['cost_center'] or '',
|
'cost_center' : item_det and item_det[0]['cost_center'] or '',
|
||||||
'item_tax_rate' : str(t)
|
'item_tax_rate' : json.dumps(t)
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ cur_frm.cscript.load_defaults = function(doc, dt, dn) {
|
|||||||
|
|
||||||
// Update existing item details
|
// Update existing item details
|
||||||
cur_frm.cscript.update_item_details = function(doc, dt, dn) {
|
cur_frm.cscript.update_item_details = function(doc, dt, dn) {
|
||||||
if(!cur_frm.doc.__islocal) return;
|
if(!cur_frm.doc.__islocal) { return; }
|
||||||
var children = getchildren(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname);
|
var children = getchildren(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname);
|
||||||
if(children) {
|
if(children) {
|
||||||
$c_obj(make_doclist(doc.doctype, doc.name), 'get_item_details', '',
|
$c_obj(make_doclist(doc.doctype, doc.name), 'get_item_details', '',
|
||||||
|
@ -585,6 +585,7 @@ HomeStatusBar = function() {
|
|||||||
this.wrapper.innerHTML = '';
|
this.wrapper.innerHTML = '';
|
||||||
this.profile_settings = $a($a(this.wrapper, 'p'), 'span', 'link_type', {fontWeight:'bold'});
|
this.profile_settings = $a($a(this.wrapper, 'p'), 'span', 'link_type', {fontWeight:'bold'});
|
||||||
this.profile_settings.innerHTML = user_fullname + ' (Profile Settings)';
|
this.profile_settings.innerHTML = user_fullname + ' (Profile Settings)';
|
||||||
|
this.profile_settings.id = "user_fullname";
|
||||||
this.profile_settings.onclick = function() { loadpage('profile-settings'); }
|
this.profile_settings.onclick = function() { loadpage('profile-settings'); }
|
||||||
|
|
||||||
this.span = $a($a(this.wrapper, 'p'), 'span', 'link_type', {fontWeight:'bold'});
|
this.span = $a($a(this.wrapper, 'p'), 'span', 'link_type', {fontWeight:'bold'});
|
||||||
@ -614,7 +615,7 @@ pscript.home_make_status = function() {
|
|||||||
|
|
||||||
// complete registration
|
// complete registration
|
||||||
if(in_list(user_roles,'System Manager')) {
|
if(in_list(user_roles,'System Manager')) {
|
||||||
pscript.complete_registration(r.message.registration_complete);
|
pscript.complete_registration(r.message.registration_complete, r.message.profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup wizard
|
// setup wizard
|
||||||
@ -627,15 +628,19 @@ pscript.home_make_status = function() {
|
|||||||
|
|
||||||
// complete my company registration
|
// complete my company registration
|
||||||
// --------------------------------
|
// --------------------------------
|
||||||
pscript.complete_registration = function(is_complete) {
|
pscript.complete_registration = function(is_complete, profile) {
|
||||||
if(is_complete == 'No'){
|
if(is_complete == 'No'){
|
||||||
var d = new Dialog(400, 200, "Please Complete Your Registration");
|
var d = new Dialog(400, 200, "Setup your Account");
|
||||||
if(user != 'Administrator'){
|
if(user != 'Administrator'){
|
||||||
d.no_cancel(); // Hide close image
|
d.no_cancel(); // Hide close image
|
||||||
$dh(page_body.wntoolbar.wrapper);
|
$dh(page_body.wntoolbar.wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
d.make_body([
|
d.make_body([
|
||||||
|
['HTML', 'Your Profile Details', '<h4>Your Profile Details</h4>'],
|
||||||
|
['Data', 'First Name'],
|
||||||
|
['Data', 'Last Name'],
|
||||||
|
['HTML', 'Company Details', '<h4>Create your first company</h4>'],
|
||||||
['Data','Company Name','Example: Your Company LLC'],
|
['Data','Company Name','Example: Your Company LLC'],
|
||||||
['Data','Company Abbreviation', 'Example: YC (all your acconts will have this as a suffix)'],
|
['Data','Company Abbreviation', 'Example: YC (all your acconts will have this as a suffix)'],
|
||||||
['Select','Fiscal Year Start Date'],
|
['Select','Fiscal Year Start Date'],
|
||||||
@ -649,7 +654,16 @@ pscript.complete_registration = function(is_complete) {
|
|||||||
d.widgets['Company Name'].value = locals['Control Panel']['Control Panel'].company_name;
|
d.widgets['Company Name'].value = locals['Control Panel']['Control Panel'].company_name;
|
||||||
d.widgets['Company Name'].disabled = 1;
|
d.widgets['Company Name'].disabled = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(profile && profile.length>0) {
|
||||||
|
if(profile[0].first_name && profile[0].first_name!='None') {
|
||||||
|
d.widgets['First Name'].value = profile[0].first_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(profile[0].last_name && profile[0].last_name!='None') {
|
||||||
|
d.widgets['Last Name'].value = profile[0].last_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//d.widgets['Save'].disabled = true; // disable Save button
|
//d.widgets['Save'].disabled = true; // disable Save button
|
||||||
pscript.make_dialog_field(d);
|
pscript.make_dialog_field(d);
|
||||||
@ -666,14 +680,20 @@ pscript.complete_registration = function(is_complete) {
|
|||||||
d.widgets['Company Name'].value,
|
d.widgets['Company Name'].value,
|
||||||
d.widgets['Company Abbreviation'].value,
|
d.widgets['Company Abbreviation'].value,
|
||||||
d.widgets['Fiscal Year Start Date'].value,
|
d.widgets['Fiscal Year Start Date'].value,
|
||||||
d.widgets['Default Currency'].value
|
d.widgets['Default Currency'].value,
|
||||||
|
d.widgets['First Name'].value,
|
||||||
|
d.widgets['Last Name'].value
|
||||||
];
|
];
|
||||||
|
|
||||||
$c_obj('Setup Control','setup_account',JSON.stringify(args),function(r, rt){
|
$c_obj('Setup Control','setup_account',JSON.stringify(args),function(r, rt){
|
||||||
sys_defaults = r.message;
|
sys_defaults = r.message.sys_defaults;
|
||||||
|
user_fullname = r.message.user_fullname;
|
||||||
d.hide();
|
d.hide();
|
||||||
$ds(page_body.wntoolbar.wrapper);
|
$ds(page_body.wntoolbar.wrapper);
|
||||||
|
$('#user_fullname').html(user_fullname + " (Profile Settings)");
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
d.widgets['Save'].done_working();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d.show();
|
d.show();
|
||||||
@ -699,12 +719,12 @@ pscript.make_dialog_field = function(d)
|
|||||||
// ---------------
|
// ---------------
|
||||||
pscript.validate_fields = function(d)
|
pscript.validate_fields = function(d)
|
||||||
{
|
{
|
||||||
var lst = ['Company Abbreviation', 'Fiscal Year Start Date', 'Default Currency'];
|
var lst = ['First Name', 'Company Name', 'Company Abbreviation', 'Fiscal Year Start Date', 'Default Currency'];
|
||||||
var msg = 'Please enter the following fields';
|
var msg = 'Please enter the following fields\n';
|
||||||
var flag = 1;
|
var flag = 1;
|
||||||
for(var i=0; i<lst.length; i++)
|
for(var i=0; i<lst.length; i++)
|
||||||
{
|
{
|
||||||
if(!d.widgets[lst[i]].value){
|
if(!d.widgets[lst[i]].value || d.widgets[lst[i]].value=='None'){
|
||||||
flag = 0;
|
flag = 0;
|
||||||
msg = msg + NEWLINE + lst[i];
|
msg = msg + NEWLINE + lst[i];
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,10 @@ def get_status_details(arg=None):
|
|||||||
'is_trial': webnotes.conn.get_global('is_trial'),
|
'is_trial': webnotes.conn.get_global('is_trial'),
|
||||||
'days_to_expiry': (webnotes.conn.get_global('days_to_expiry') or '0'),
|
'days_to_expiry': (webnotes.conn.get_global('days_to_expiry') or '0'),
|
||||||
'setup_status': get_setup_status(),
|
'setup_status': get_setup_status(),
|
||||||
'registration_complete': cint(get_defaults('registration_complete')) and 'Yes' or 'No'
|
'registration_complete': cint(get_defaults('registration_complete')) and 'Yes' or 'No',
|
||||||
|
'profile': webnotes.conn.sql("""\
|
||||||
|
SELECT first_name, last_name FROM `tabProfile`
|
||||||
|
WHERE name=%s AND docstatus<2""", webnotes.user.name, as_dict=1)
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@ -89,4 +92,4 @@ def get_setup_status():
|
|||||||
return ''
|
return ''
|
||||||
|
|
||||||
return {'ret': ret, 'percent': percent}
|
return {'ret': ret, 'percent': percent}
|
||||||
|
|
||||||
|
@ -197,17 +197,19 @@ class DocType(TransactionBase):
|
|||||||
|
|
||||||
#---------------------------------------- Get Tax Details -------------------------------#
|
#---------------------------------------- Get Tax Details -------------------------------#
|
||||||
def get_tax_details(self, item_code, obj):
|
def get_tax_details(self, item_code, obj):
|
||||||
|
import json
|
||||||
tax = webnotes.conn.sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , item_code)
|
tax = webnotes.conn.sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , item_code)
|
||||||
t = {}
|
t = {}
|
||||||
for x in tax: t[x[0]] = flt(x[1])
|
for x in tax: t[x[0]] = flt(x[1])
|
||||||
ret = {
|
ret = {
|
||||||
'item_tax_rate' : tax and str(t) or ''
|
'item_tax_rate' : tax and json.dumps(t) or ''
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
# Get Serial No Details
|
# Get Serial No Details
|
||||||
# ==========================================================================
|
# ==========================================================================
|
||||||
def get_serial_details(self, serial_no, obj):
|
def get_serial_details(self, serial_no, obj):
|
||||||
|
import json
|
||||||
item = webnotes.conn.sql("select item_code, make, label,brand, description from `tabSerial No` where name = '%s' and docstatus != 2" %(serial_no), as_dict=1)
|
item = webnotes.conn.sql("select item_code, make, label,brand, description from `tabSerial No` where name = '%s' and docstatus != 2" %(serial_no), as_dict=1)
|
||||||
tax = webnotes.conn.sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , item[0]['item_code'])
|
tax = webnotes.conn.sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , item[0]['item_code'])
|
||||||
t = {}
|
t = {}
|
||||||
@ -218,7 +220,7 @@ class DocType(TransactionBase):
|
|||||||
'label' : item and item[0]['label'] or '',
|
'label' : item and item[0]['label'] or '',
|
||||||
'brand' : item and item[0]['brand'] or '',
|
'brand' : item and item[0]['brand'] or '',
|
||||||
'description' : item and item[0]['description'] or '',
|
'description' : item and item[0]['description'] or '',
|
||||||
'item_tax_rate' : str(t)
|
'item_tax_rate' : json.dumps(t)
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
@ -47,9 +47,17 @@ class DocType:
|
|||||||
# Account Setup
|
# Account Setup
|
||||||
# ---------------
|
# ---------------
|
||||||
def setup_account(self, args):
|
def setup_account(self, args):
|
||||||
company_name, comp_abbr, fy_start, currency = eval(args)
|
import webnotes
|
||||||
|
company_name, comp_abbr, fy_start, currency, first_name, last_name = eval(args)
|
||||||
curr_fiscal_year,fy_start_date = self.get_fy_details(fy_start)
|
curr_fiscal_year,fy_start_date = self.get_fy_details(fy_start)
|
||||||
self.currency = currency
|
self.currency = currency
|
||||||
|
|
||||||
|
# Update Profile
|
||||||
|
if last_name=='None': last_name = None
|
||||||
|
webnotes.conn.sql("""\
|
||||||
|
UPDATE `tabProfile` SET first_name=%s, last_name=%s
|
||||||
|
WHERE name=%s AND docstatus<2""", (first_name, last_name, webnotes.user.name))
|
||||||
|
|
||||||
|
|
||||||
# Fiscal Year
|
# Fiscal Year
|
||||||
master_dict = {'Fiscal Year':{'year':curr_fiscal_year, 'year_start_date':fy_start_date}}
|
master_dict = {'Fiscal Year':{'year':curr_fiscal_year, 'year_start_date':fy_start_date}}
|
||||||
@ -66,6 +74,7 @@ class DocType:
|
|||||||
'default_currency': currency,
|
'default_currency': currency,
|
||||||
'default_company':company_name,
|
'default_company':company_name,
|
||||||
'default_valuation_method':'FIFO',
|
'default_valuation_method':'FIFO',
|
||||||
|
'default_stock_uom':'Nos',
|
||||||
'date_format':'dd-mm-yyyy',
|
'date_format':'dd-mm-yyyy',
|
||||||
'default_currency_format':'Lacs',
|
'default_currency_format':'Lacs',
|
||||||
'so_required':'No',
|
'so_required':'No',
|
||||||
@ -87,7 +96,8 @@ class DocType:
|
|||||||
msgprint("Great! Your company has now been created")
|
msgprint("Great! Your company has now been created")
|
||||||
|
|
||||||
import webnotes.utils
|
import webnotes.utils
|
||||||
return webnotes.utils.get_defaults()
|
user_fullname = (first_name or '') + (last_name and (" " + last_name) or '')
|
||||||
|
return {'sys_defaults': webnotes.utils.get_defaults(), 'user_fullname': user_fullname}
|
||||||
|
|
||||||
|
|
||||||
# Get Fiscal year Details
|
# Get Fiscal year Details
|
||||||
|
@ -112,6 +112,7 @@ class DocType:
|
|||||||
|
|
||||||
def cal_charges_and_item_tax_amt(self):
|
def cal_charges_and_item_tax_amt(self):
|
||||||
""" Re-calculates other charges values and itemwise tax amount for getting valuation rate"""
|
""" Re-calculates other charges values and itemwise tax amount for getting valuation rate"""
|
||||||
|
import json
|
||||||
for pr in self.selected_pr:
|
for pr in self.selected_pr:
|
||||||
obj = get_obj('Purchase Receipt', pr, with_children = 1)
|
obj = get_obj('Purchase Receipt', pr, with_children = 1)
|
||||||
total = 0
|
total = 0
|
||||||
@ -121,7 +122,11 @@ class DocType:
|
|||||||
prev_total, item_tax = flt(prd.amount), 0
|
prev_total, item_tax = flt(prd.amount), 0
|
||||||
total += flt(prd.qty) * flt(prd.purchase_rate)
|
total += flt(prd.qty) * flt(prd.purchase_rate)
|
||||||
|
|
||||||
item_tax_rate = prd.item_tax_rate and eval(prd.item_tax_rate) or {}
|
try:
|
||||||
|
item_tax_rate = prd.item_tax_rate and json.loads(prd.item_tax_rate) or {}
|
||||||
|
except ValueError:
|
||||||
|
item_tax_rate = prd.item_tax_rate and eval(prd.item_tax_rate) or {}
|
||||||
|
|
||||||
|
|
||||||
ocd = getlist(obj.doclist, 'purchase_tax_details')
|
ocd = getlist(obj.doclist, 'purchase_tax_details')
|
||||||
# calculate tax for other charges
|
# calculate tax for other charges
|
||||||
|
@ -241,7 +241,7 @@ cur_frm.cscript['Make Purchase Invoice'] = function() {
|
|||||||
'from_docname': cur_frm.doc.name,
|
'from_docname': cur_frm.doc.name,
|
||||||
'from_to_list':"[['Purchase Receipt','Payable Voucher'],['Purchase Receipt Detail','PV Detail'],['Purchase Tax Detail','Purchase Tax Detail']]"
|
'from_to_list':"[['Purchase Receipt','Payable Voucher'],['Purchase Receipt Detail','PV Detail'],['Purchase Tax Detail','Purchase Tax Detail']]"
|
||||||
}, function(r,rt) {
|
}, function(r,rt) {
|
||||||
loaddoc('Payable Voucher', n);
|
loaddoc('Payable Voucher', n);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,176 +1,213 @@
|
|||||||
// Onload
|
// Onload
|
||||||
//-------------------------------
|
//-------------------------------
|
||||||
cur_frm.cscript.onload = function(doc,dt,dn){
|
cur_frm.cscript.onload = function(doc,dt,dn){
|
||||||
if(!doc.return_date) set_multiple(dt,dn,{return_date:get_today()});
|
if(!doc.return_date) set_multiple(dt,dn,{return_date:get_today()});
|
||||||
doc.delivery_note_no = '';
|
doc.delivery_note_no = '';
|
||||||
doc.purchase_receipt_no = '';
|
doc.purchase_receipt_no = '';
|
||||||
doc.sales_invoice_no = '';
|
doc.sales_invoice_no = '';
|
||||||
doc.return_type ='';
|
doc.return_type ='';
|
||||||
refresh_many(['delivery_note_no', 'sales_invoice_no', 'purchase_receipt_no', 'return_type']);
|
refresh_many(['delivery_note_no', 'sales_invoice_no', 'purchase_receipt_no', 'return_type']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Link field query
|
// Link field query
|
||||||
//--------------------------------
|
//--------------------------------
|
||||||
cur_frm.fields_dict.delivery_note_no.get_query = function(doc) {
|
cur_frm.fields_dict.delivery_note_no.get_query = function(doc) {
|
||||||
return 'SELECT DISTINCT `tabDelivery Note`.name FROM `tabDelivery Note` WHERE `tabDelivery Note`.docstatus = 1 AND `tabDelivery Note`.%(key)s LIKE "%s" ORDER BY `tabDelivery Note`.name desc LIMIT 50';
|
return 'SELECT DISTINCT `tabDelivery Note`.name FROM `tabDelivery Note` WHERE `tabDelivery Note`.docstatus = 1 AND `tabDelivery Note`.%(key)s LIKE "%s" ORDER BY `tabDelivery Note`.name desc LIMIT 50';
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.fields_dict.sales_invoice_no.get_query = function(doc) {
|
cur_frm.fields_dict.sales_invoice_no.get_query = function(doc) {
|
||||||
return 'SELECT DISTINCT `tabReceivable Voucher`.name FROM `tabReceivable Voucher` WHERE `tabReceivable Voucher`.docstatus = 1 AND `tabReceivable Voucher`.%(key)s LIKE "%s" ORDER BY `tabReceivable Voucher`.name desc LIMIT 50';
|
return 'SELECT DISTINCT `tabReceivable Voucher`.name FROM `tabReceivable Voucher` WHERE `tabReceivable Voucher`.docstatus = 1 AND `tabReceivable Voucher`.%(key)s LIKE "%s" ORDER BY `tabReceivable Voucher`.name desc LIMIT 50';
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.fields_dict.purchase_receipt_no.get_query = function(doc) {
|
cur_frm.fields_dict.purchase_receipt_no.get_query = function(doc) {
|
||||||
return 'SELECT DISTINCT `tabPurchase Receipt`.name FROM `tabPurchase Receipt` WHERE `tabPurchase Receipt`.docstatus = 1 AND `tabPurchase Receipt`.%(key)s LIKE "%s" ORDER BY `tabPurchase Receipt`.name desc LIMIT 50';
|
return 'SELECT DISTINCT `tabPurchase Receipt`.name FROM `tabPurchase Receipt` WHERE `tabPurchase Receipt`.docstatus = 1 AND `tabPurchase Receipt`.%(key)s LIKE "%s" ORDER BY `tabPurchase Receipt`.name desc LIMIT 50';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide/unhide based on return type
|
// Hide/unhide based on return type
|
||||||
//----------------------------------
|
//----------------------------------
|
||||||
cur_frm.cscript.return_type = function(doc, cdt, cdn) {
|
cur_frm.cscript.return_type = function(doc, cdt, cdn) {
|
||||||
hide_field(['purchase_receipt_no', 'delivery_note_no', 'sales_invoice_no', 'return_details', 'Get Items', 'Make Excise Invoice', 'Make Stock Entry', 'Make Debit Note', 'Make Credit Note']);
|
var cp = locals['Control Panel']['Control Panel'];
|
||||||
if(doc.return_type == 'Sales Return')
|
hide_field(['purchase_receipt_no', 'delivery_note_no', 'sales_invoice_no',
|
||||||
unhide_field(['delivery_note_no', 'sales_invoice_no', 'Get Items', 'return_details', 'Make Credit Note', 'Make Stock Entry', 'Make Excise Invoice']);
|
'return_details', 'Get Items', 'Make Excise Invoice', 'Make Stock Entry',
|
||||||
else if(doc.return_type == 'Purchase Return')
|
'Make Debit Note', 'Make Credit Note']);
|
||||||
unhide_field(['purchase_receipt_no', 'Get Items', 'return_details', 'Make Debit Note', 'Make Stock Entry', 'Make Excise Invoice']);
|
|
||||||
|
|
||||||
cur_frm.cscript.clear_fields(doc);
|
if(doc.return_type == 'Sales Return') {
|
||||||
|
unhide_field(['delivery_note_no', 'sales_invoice_no', 'Get Items',
|
||||||
|
'return_details', 'Make Credit Note', 'Make Stock Entry']);
|
||||||
|
|
||||||
|
if(cp.country == 'India') { unhide_field(['Make Excise Invoice']); }
|
||||||
|
|
||||||
|
} else if(doc.return_type == 'Purchase Return') {
|
||||||
|
unhide_field(['purchase_receipt_no', 'Get Items', 'return_details',
|
||||||
|
'Make Debit Note', 'Make Stock Entry']);
|
||||||
|
|
||||||
|
if(cp.country == 'India') { unhide_field(['Make Excise Invoice']); }
|
||||||
|
}
|
||||||
|
|
||||||
|
cur_frm.cscript.clear_fields(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create item table
|
// Create item table
|
||||||
//-------------------------------
|
//-------------------------------
|
||||||
cur_frm.cscript['Get Items'] = function(doc, cdt, cdn) {
|
cur_frm.cscript['Get Items'] = function(doc, cdt, cdn) {
|
||||||
flag = 0
|
flag = 0
|
||||||
if(doc.return_type == 'Sales Return') {
|
if(doc.return_type == 'Sales Return') {
|
||||||
if (doc.delivery_note_no && doc.sales_invoice_no) {
|
if (doc.delivery_note_no && doc.sales_invoice_no) {
|
||||||
msgprint("You can not enter both Delivery Note No and Sales Invoice No. Please enter any one.");
|
msgprint("You can not enter both Delivery Note No and Sales Invoice No. Please enter any one.");
|
||||||
flag = 1;
|
flag = 1;
|
||||||
} else if (!doc.delivery_note_no && !doc.sales_invoice_no) {
|
} else if (!doc.delivery_note_no && !doc.sales_invoice_no) {
|
||||||
msgprint("Please enter Delivery Note No or Sales Invoice No to proceed");
|
msgprint("Please enter Delivery Note No or Sales Invoice No to proceed");
|
||||||
flag = 1;
|
flag = 1;
|
||||||
}
|
}
|
||||||
} else if (doc.return_type == 'Purchase Return' && !doc.purchase_receipt_no) {
|
} else if (doc.return_type == 'Purchase Return' && !doc.purchase_receipt_no) {
|
||||||
msgprint("Please enter Purchase Receipt No to proceed");
|
msgprint("Please enter Purchase Receipt No to proceed");
|
||||||
flag = 1;
|
flag = 1;
|
||||||
}
|
}
|
||||||
if (!flag)
|
if (!flag)
|
||||||
$c_obj(make_doclist(doc.doctype, doc.name),'pull_item_details','', function(r, rt) {
|
$c_obj(make_doclist(doc.doctype, doc.name),'pull_item_details','', function(r, rt) {
|
||||||
refresh_many(['return_details', 'cust_supp', 'cust_supp_name', 'cust_supp_address']);
|
refresh_many(['return_details', 'cust_supp', 'cust_supp_name', 'cust_supp_address']);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear fields
|
// Clear fields
|
||||||
//-------------------------------
|
//-------------------------------
|
||||||
cur_frm.cscript.clear_fields = function(doc) {
|
cur_frm.cscript.clear_fields = function(doc) {
|
||||||
doc.purchase_receipt_no, doc.delivery_note_no, doc.sales_invoice_no = '', '', '';
|
doc.purchase_receipt_no, doc.delivery_note_no, doc.sales_invoice_no = '', '', '';
|
||||||
var cl = getchildren('Return Detail', doc.name, 'return_details')
|
var cl = getchildren('Return Detail', doc.name, 'return_details')
|
||||||
if(cl.length) $c_obj(make_doclist(doc.doctype, doc.name),'clear_return_table','', function(r, rt) {refresh_field('return_details')});
|
if(cl.length) $c_obj(make_doclist(doc.doctype, doc.name),'clear_return_table','', function(r, rt) {refresh_field('return_details')});
|
||||||
refresh_many(['delivery_note_no', 'sales_invoice_no', 'purchase_receipt_no', 'return_details']);
|
refresh_many(['delivery_note_no', 'sales_invoice_no', 'purchase_receipt_no', 'return_details']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make Stock Entry
|
// Make Stock Entry
|
||||||
//-------------------------------
|
//-------------------------------
|
||||||
cur_frm.cscript['Make Stock Entry'] = function(doc, cdt, cdn) {
|
cur_frm.cscript['Make Stock Entry'] = function(doc, cdt, cdn) {
|
||||||
var cl = getchildren('Return Detail', doc.name, 'return_details');
|
var cl = getchildren('Return Detail', doc.name, 'return_details');
|
||||||
if (!cl.length)
|
if (!cl.length)
|
||||||
msgprint("Item table can not be blank. Please click on 'Get Items'.");
|
msgprint("Item table can not be blank. Please click on 'Get Items'.");
|
||||||
else if (!cur_frm.cscript.validate_returned_qty(cl)) {
|
else if (!cur_frm.cscript.validate_returned_qty(cl)) {
|
||||||
se = cur_frm.cscript.map_parent_fields(doc,cdt,cdn);
|
se = cur_frm.cscript.map_parent_fields(doc,cdt,cdn);
|
||||||
cur_frm.cscript.map_child_fields(cl, se);
|
cur_frm.cscript.map_child_fields(cl, se);
|
||||||
loaddoc('Stock Entry', se.name);
|
loaddoc('Stock Entry', se.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate returned qty
|
// Validate returned qty
|
||||||
//---------------------------
|
//---------------------------
|
||||||
cur_frm.cscript.validate_returned_qty = function(cl) {
|
cur_frm.cscript.validate_returned_qty = function(cl) {
|
||||||
flag = 0
|
flag = 0
|
||||||
for(var i = 0; i<cl.length; i++){
|
for(var i = 0; i<cl.length; i++){
|
||||||
if(cl[i].returned_qty > cl[i].qty) {
|
if(cl[i].returned_qty > cl[i].qty) {
|
||||||
msgprint("Returned Qty can not be greater than qty. Please check for item: " + cl[i].item_code);
|
msgprint("Returned Qty can not be greater than qty. Please check for item: " + cl[i].item_code);
|
||||||
flag = 1
|
flag = 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return flag
|
return flag
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// map parent fields of stock entry
|
// map parent fields of stock entry
|
||||||
//----------------------------------
|
//----------------------------------
|
||||||
cur_frm.cscript.map_parent_fields = function(doc, cdt, cdn) {
|
cur_frm.cscript.map_parent_fields = function(doc, cdt, cdn) {
|
||||||
var se = LocalDB.create('Stock Entry');
|
var se = LocalDB.create('Stock Entry');
|
||||||
se = locals['Stock Entry'][se];
|
se = locals['Stock Entry'][se];
|
||||||
se.posting_date = dateutil.obj_to_str(new Date());
|
se.posting_date = dateutil.obj_to_str(new Date());
|
||||||
se.transfer_date = dateutil.obj_to_str(new Date());
|
se.transfer_date = dateutil.obj_to_str(new Date());
|
||||||
se.fiscal_year = sys_defaults.fiscal_year;
|
se.fiscal_year = sys_defaults.fiscal_year;
|
||||||
se.purpose = doc.return_type;
|
se.purpose = doc.return_type;
|
||||||
se.remarks = doc.return_type + ' of ' + (doc.delivery_note_no || doc.sales_invoice_no || doc.purchase_receipt_no);
|
se.remarks = doc.return_type + ' of ' + (doc.delivery_note_no || doc.sales_invoice_no || doc.purchase_receipt_no);
|
||||||
if(doc.return_type == 'Sales Return'){
|
if(doc.return_type == 'Sales Return'){
|
||||||
se.delivery_note_no = doc.delivery_note_no;
|
se.delivery_note_no = doc.delivery_note_no;
|
||||||
se.sales_invoice_no = doc.sales_invoice_no;
|
se.sales_invoice_no = doc.sales_invoice_no;
|
||||||
se.customer = doc.cust_supp_name;
|
se.customer = doc.cust_supp_name;
|
||||||
se.customer_name = doc.cust_supp_name;
|
se.customer_name = doc.cust_supp_name;
|
||||||
se.customer_address = doc.cust_supp_address;
|
se.customer_address = doc.cust_supp_address;
|
||||||
}
|
}
|
||||||
else if(doc.return_type == 'Purchase Return'){
|
else if(doc.return_type == 'Purchase Return'){
|
||||||
se.purchase_receipt_no = doc.purchase_receipt_no;
|
se.purchase_receipt_no = doc.purchase_receipt_no;
|
||||||
se.supplier = doc.cust_supp_name;
|
se.supplier = doc.cust_supp_name;
|
||||||
se.supplier_name = doc.cust_supp_name;
|
se.supplier_name = doc.cust_supp_name;
|
||||||
se.supplier_address = doc.cust_supp_address;
|
se.supplier_address = doc.cust_supp_address;
|
||||||
}
|
}
|
||||||
return se
|
return se
|
||||||
}
|
}
|
||||||
|
|
||||||
// map child fields of stock entry
|
// map child fields of stock entry
|
||||||
//---------------------------------
|
//---------------------------------
|
||||||
cur_frm.cscript.map_child_fields = function(cl, se) {
|
cur_frm.cscript.map_child_fields = function(cl, se) {
|
||||||
for(var i = 0; i<cl.length; i++){
|
for(var i = 0; i<cl.length; i++){
|
||||||
if (cl[i].returned_qty) {
|
if (cl[i].returned_qty) {
|
||||||
var d1 = LocalDB.add_child(se, 'Stock Entry Detail', 'mtn_details');
|
var d1 = LocalDB.add_child(se, 'Stock Entry Detail', 'mtn_details');
|
||||||
d1.detail_name = cl[i].detail_name;
|
d1.detail_name = cl[i].detail_name;
|
||||||
d1.item_code = cl[i].item_code;
|
d1.item_code = cl[i].item_code;
|
||||||
d1.description = cl[i].description;
|
d1.description = cl[i].description;
|
||||||
d1.transfer_qty = cl[i].returned_qty;
|
d1.transfer_qty = cl[i].returned_qty;
|
||||||
d1.qty = cl[i].returned_qty;
|
d1.qty = cl[i].returned_qty;
|
||||||
d1.stock_uom = cl[i].uom;
|
d1.stock_uom = cl[i].uom;
|
||||||
d1.uom = cl[i].uom;
|
d1.uom = cl[i].uom;
|
||||||
d1.conversion_factor = 1;
|
d1.conversion_factor = 1;
|
||||||
d1.incoming_rate = cl[i].rate;
|
d1.incoming_rate = cl[i].rate;
|
||||||
d1.serial_no = cl[i].serial_no;
|
d1.serial_no = cl[i].serial_no;
|
||||||
d1.batch_no = cl[i].batch_no;
|
d1.batch_no = cl[i].batch_no;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make excise voucher
|
// Make excise voucher
|
||||||
//-------------------------------
|
//-------------------------------
|
||||||
cur_frm.cscript['Make Excise Invoice'] = function(doc) {
|
cur_frm.cscript['Make Excise Invoice'] = function(doc) {
|
||||||
var excise = LocalDB.create('Journal Voucher');
|
var excise = LocalDB.create('Journal Voucher');
|
||||||
excise = locals['Journal Voucher'][excise];
|
excise = locals['Journal Voucher'][excise];
|
||||||
excise.voucher_type = 'Excise Voucher';
|
excise.voucher_type = 'Excise Voucher';
|
||||||
loaddoc('Journal Voucher',excise.name);
|
loaddoc('Journal Voucher',excise.name);
|
||||||
}
|
}
|
||||||
// Make debit note
|
// Make debit note
|
||||||
//------------------------------
|
//------------------------------
|
||||||
cur_frm.cscript['Make Debit Note'] = function(doc) {
|
cur_frm.cscript['Make Debit Note'] = function(doc) {
|
||||||
cur_frm.cscript.make_jv(doc, 'Debit Note');
|
var doclist = make_doclist(doc.doctype, doc.name);
|
||||||
|
$c('accounts.get_new_jv_details', {
|
||||||
|
doclist: JSON.stringify(doclist),
|
||||||
|
fiscal_year: sys_defaults.fiscal_year
|
||||||
|
}, function(r, rt) {
|
||||||
|
if(!r.exc) {
|
||||||
|
cur_frm.cscript.make_jv(doc, 'Debit Note', r.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// Make credit note
|
// Make credit note
|
||||||
//------------------------------
|
//------------------------------
|
||||||
cur_frm.cscript['Make Credit Note'] = function(doc) {
|
cur_frm.cscript['Make Credit Note'] = function(doc) {
|
||||||
cur_frm.cscript.make_jv(doc, 'Credit Note');
|
var doclist = make_doclist(doc.doctype, doc.name);
|
||||||
|
$c('accounts.get_new_jv_details', {
|
||||||
|
doclist: JSON.stringify(doclist),
|
||||||
|
fiscal_year: sys_defaults.fiscal_year
|
||||||
|
}, function(r, rt) {
|
||||||
|
if(!r.exc) {
|
||||||
|
cur_frm.cscript.make_jv(doc, 'Credit Note', r.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Make JV
|
// Make JV
|
||||||
//--------------------------------
|
//--------------------------------
|
||||||
cur_frm.cscript.make_jv = function(doc, dr_or_cr) {
|
cur_frm.cscript.make_jv = function(doc, dr_or_cr, children) {
|
||||||
var jv = LocalDB.create('Journal Voucher');
|
var jv = LocalDB.create('Journal Voucher');
|
||||||
jv = locals['Journal Voucher'][jv];
|
jv = locals['Journal Voucher'][jv];
|
||||||
|
|
||||||
jv.voucher_type = dr_or_cr;
|
jv.voucher_type = dr_or_cr;
|
||||||
jv.company = sys_defaults.company;
|
jv.company = sys_defaults.company;
|
||||||
jv.fiscal_year = sys_defaults.fiscal_year;
|
jv.fiscal_year = sys_defaults.fiscal_year;
|
||||||
jv.is_opening = 'No';
|
jv.is_opening = 'No';
|
||||||
jv.posting_date = dateutil.obj_to_str(new Date());
|
jv.posting_date = dateutil.obj_to_str(new Date());
|
||||||
jv.voucher_date = dateutil.obj_to_str(new Date());
|
jv.voucher_date = dateutil.obj_to_str(new Date());
|
||||||
|
|
||||||
loaddoc('Journal Voucher',jv.name);
|
// Add children
|
||||||
|
if(children) {
|
||||||
|
for(var i=0; i<children.length; i++) {
|
||||||
|
var ch = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries');
|
||||||
|
$.extend(ch, children[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
loaddoc('Journal Voucher', jv.name);
|
||||||
}
|
}
|
||||||
|
@ -84,14 +84,18 @@ $.extend(cur_frm.cscript, {
|
|||||||
Send: function(doc, dt, dn) {
|
Send: function(doc, dt, dn) {
|
||||||
$c_obj([doc], 'send_response', '', function(r,rt) {
|
$c_obj([doc], 'send_response', '', function(r,rt) {
|
||||||
locals[dt][dn].new_response = '';
|
locals[dt][dn].new_response = '';
|
||||||
cur_frm.refresh();
|
if(!r.exc) {
|
||||||
|
cur_frm.refresh();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
customer: function(doc, dt, dn) {
|
customer: function(doc, dt, dn) {
|
||||||
var callback = function(r,rt) {
|
var callback = function(r,rt) {
|
||||||
var doc = locals[cur_frm.doctype][cur_frm.docname];
|
var doc = locals[cur_frm.doctype][cur_frm.docname];
|
||||||
cur_frm.refresh();
|
if(!r.exc) {
|
||||||
|
cur_frm.refresh();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', '', callback);
|
if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', '', callback);
|
||||||
if(doc.customer) unhide_field(['customer_name','address_display','contact_display','contact_mobile','contact_email']);
|
if(doc.customer) unhide_field(['customer_name','address_display','contact_display','contact_mobile','contact_email']);
|
||||||
@ -104,7 +108,9 @@ $.extend(cur_frm.cscript, {
|
|||||||
if(answer) {
|
if(answer) {
|
||||||
if(doc.name)
|
if(doc.name)
|
||||||
$c_obj([doc],'close_ticket','',function(r,rt) {
|
$c_obj([doc],'close_ticket','',function(r,rt) {
|
||||||
cur_frm.refresh();
|
if(!r.exc) {
|
||||||
|
cur_frm.refresh();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -116,7 +122,9 @@ $.extend(cur_frm.cscript, {
|
|||||||
if(answer) {
|
if(answer) {
|
||||||
if(doc.name)
|
if(doc.name)
|
||||||
$c_obj([doc],'reopen_ticket','',function(r,rt) {
|
$c_obj([doc],'reopen_ticket','',function(r,rt) {
|
||||||
cur_frm.refresh();
|
if(!r.exc) {
|
||||||
|
cur_frm.refresh();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user