fix in field names

This commit is contained in:
Anand Doshi 2012-04-12 14:08:43 +05:30
parent db695ecbf4
commit 25bc68c7b2
26 changed files with 280 additions and 390 deletions

View File

@ -44,9 +44,9 @@ $.extend(cur_frm.cscript, {
}, },
hide_show_buttons: function(doc) { hide_show_buttons: function(doc) {
if(doc.docstatus==0) { if(doc.docstatus==0) {
hide_field('Installment Reciept'); show_field('Generate'); hide_field('installment_reciept'); show_field('generate');
} else if (doc.docstatus==1) { } else if (doc.docstatus==1) {
show_field('Installment Reciept');hide_field('Generate'); show_field('installment_reciept');hide_field('generate');
} }
}, },
clear_installments: function(doc) { clear_installments: function(doc) {

View File

@ -21,14 +21,14 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
} }
cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.cscript.refresh = function(doc, cdt, cdn) {
hide_field('Repost Account Balances'); hide_field('repost_account_balances');
hide_field('next_fiscal_year'); hide_field('next_fiscal_year');
hide_field('Repost'); hide_field('repost');
if (doc.docstatus == 1) { if (doc.docstatus == 1) {
unhide_field('Repost Account Balances'); unhide_field('repost_account_balances');
unhide_field('next_fiscal_year'); unhide_field('next_fiscal_year');
unhide_field('Repost'); unhide_field('repost');
} }
} }

View File

@ -29,10 +29,10 @@ cur_frm.cscript.onload = function(doc,dt,dn) {
if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()}); if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()});
if(cp.country == 'India') { if(cp.country == 'India') {
unhide_field(['TDS','tds_applicable','tds_category','Get TDS','tax_code','rate','ded_amount','total_tds_on_voucher','tds_amount_on_advance']); unhide_field(['tds','tds_applicable','tds_category','get_tds','tax_code','rate','ded_amount','total_tds_on_voucher','tds_amount_on_advance']);
} }
else { else {
hide_field(['TDS','tds_applicable','tds_category','Get TDS','tax_code','rate','ded_amount','total_tds_on_voucher','tds_amount_on_advance']); hide_field(['tds','tds_applicable','tds_category','get_tds','tax_code','rate','ded_amount','total_tds_on_voucher','tds_amount_on_advance']);
} }
if(doc.__islocal){ if(doc.__islocal){
@ -69,9 +69,9 @@ cur_frm.cscript.refresh = function(doc, dt, dn) {
cur_frm.add_custom_button('Make Payment Entry', cur_frm.cscript.make_bank_voucher); cur_frm.add_custom_button('Make Payment Entry', cur_frm.cscript.make_bank_voucher);
if(doc.docstatus==1) { if(doc.docstatus==1) {
unhide_field(['Repair Outstanding Amt']); unhide_field(['repair_outstanding_amt']);
cur_frm.add_custom_button('View Ledger', cur_frm.cscript.view_ledger_entry); cur_frm.add_custom_button('View Ledger', cur_frm.cscript.view_ledger_entry);
} else hide_field(['Repair Outstanding Amt']); } else hide_field(['repair_outstanding_amt']);
cur_frm.cscript.is_opening(doc, dt, dn); cur_frm.cscript.is_opening(doc, dt, dn);
} }

View File

@ -1,110 +0,0 @@
// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
class DocType:
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
# ============TDS==================
# Stop payable voucher on which tds is applicable is made before posting date of the
# voucher in which tds was applicable for 1st time
def validate_first_entry(self,obj):
if obj.doc.doctype == 'Purchase Invoice':
supp_acc = obj.doc.credit_to
elif obj.doc.doctype == 'Journal Voucher':
supp_acc = obj.doc.supplier_account
if obj.doc.ded_amount:
# first pv
first_pv = sql("select posting_date from `tabPurchase Invoice` where credit_to = '%s' and docstatus = 1 and tds_category = '%s' and fiscal_year = '%s' and tds_applicable = 'Yes' and (ded_amount != 0 or ded_amount is not null) order by posting_date asc limit 1"%(supp_acc, obj.doc.tds_category, obj.doc.fiscal_year))
first_pv_date = first_pv and first_pv[0][0] or ''
# first jv
first_jv = sql("select posting_date from `tabJournal Voucher` where supplier_account = '%s'and docstatus = 1 and tds_category = '%s' and fiscal_year = '%s' and tds_applicable = 'Yes' and (ded_amount != 0 or ded_amount is not null) order by posting_date asc limit 1"%(supp_acc, obj.doc.tds_category, obj.doc.fiscal_year))
first_jv_date = first_jv and first_jv[0][0] or ''
#first tds voucher date
first_tds_date = ''
if first_pv_date and first_jv_date:
first_tds_date = first_pv_date < first_jv_date and first_pv_date or first_jv_date
elif first_pv_date:
first_tds_date = first_pv_date
elif first_jv_date:
first_tds_date = first_jv_date
if first_tds_date and getdate(obj.doc.posting_date) < first_tds_date:
msgprint("First tds voucher for this category has been made already. Hence payable voucher cannot be made before posting date of first tds voucher ")
raise Exception
# TDS function definition
#---------------------------
def get_tds_amount(self, obj):
# Validate if posting date b4 first tds entry for this category
self.validate_first_entry(obj)
# get current amount and supplier head
if obj.doc.doctype == 'Purchase Invoice':
supplier_account = obj.doc.credit_to
total_amount=flt(obj.doc.grand_total)
for d in getlist(obj.doclist,'advance_allocation_details'):
if flt(d.tds_amount)!=0:
total_amount -= flt(d.allocated_amount)
elif obj.doc.doctype == 'Journal Voucher':
supplier_account = obj.doc.supplier_account
total_amount = obj.doc.total_debit
if obj.doc.tds_category:
# get total billed
total_billed = 0
pv = sql("select sum(ifnull(grand_total,0)), sum(ifnull(ded_amount,0)) from `tabPurchase Invoice` where tds_category = %s and credit_to = %s and fiscal_year = %s and docstatus = 1 and name != %s and is_opening != 'Yes'", (obj.doc.tds_category, supplier_account, obj.doc.fiscal_year, obj.doc.name))
jv = sql("select sum(ifnull(total_debit,0)), sum(ifnull(ded_amount,0)) from `tabJournal Voucher` where tds_category = %s and supplier_account = %s and fiscal_year = %s and docstatus = 1 and name != %s and is_opening != 'Yes'", (obj.doc.tds_category, supplier_account, obj.doc.fiscal_year, obj.doc.name))
tds_in_pv = pv and pv[0][1] or 0
tds_in_jv = jv and jv[0][1] or 0
total_billed += flt(pv and pv[0][0] or 0)+flt(jv and jv[0][0] or 0)+flt(total_amount)
# get slab
slab = sql("SELECT * FROM `tabTDS Rate Detail` t1, `tabTDS Rate Chart` t2 WHERE '%s' >= t1.slab_from AND t1.category = '%s' AND t1.parent=t2.name and t2.applicable_from <= '%s' ORDER BY t2.applicable_from DESC LIMIT 1" % (total_billed, obj.doc.tds_category, obj.doc.posting_date), as_dict = 1)
if slab:
if flt(tds_in_pv) <= 0 and flt(tds_in_jv) <= 0:
total_amount = total_billed
slab = slab[0]
# special tds rate
special_tds = sql("select special_tds_rate, special_tds_limit, special_tds_rate_applicable from `tabTDS Detail` where parent = '%s' and tds_category = '%s'"% (supplier_account,obj.doc.tds_category))
# get_pan_number
pan_no = sql("select pan_number from `tabAccount` where name = '%s'" % supplier_account)
pan_no = pan_no and cstr(pan_no[0][0]) or ''
if not pan_no and flt(slab.get('rate_without_pan')):
msgprint("As there is no PAN number mentioned in the account head: %s, TDS amount will be calculated at rate %s%%" % (supplier_account, cstr(slab['rate_without_pan'])))
tds_rate = flt(slab.get('rate_without_pan'))
elif special_tds and special_tds[0][2]=='Yes' and (flt(special_tds[0][1])==0 or flt(special_tds[0][1]) >= flt(total_amount)):
tds_rate = flt(special_tds[0][0])
else:
tds_rate=flt(slab['rate'])
# calculate tds amount
if flt(slab['rate']):
ac = sql("SELECT account_head FROM `tabTDS Category Account` where parent=%s and company=%s", (obj.doc.tds_category,obj.doc.company))
if ac:
obj.doc.tax_code = ac[0][0]
obj.doc.rate = tds_rate
obj.doc.ded_amount = round(flt(tds_rate) * flt(total_amount) / 100)
else:
msgprint("TDS Account not selected in TDS Category %s" % (obj.doc.tds_category))
raise Exception

View File

@ -81,11 +81,11 @@ cur_frm.cscript.make_jv = function(doc, dt, dn, det) {
// Show / Hide button // Show / Hide button
cur_frm.cscript.refresh = function(doc, dt, dn) { cur_frm.cscript.refresh = function(doc, dt, dn) {
if(doc.docstatus==1) { if(doc.docstatus==1) {
unhide_field('Make Bank Voucher'); unhide_field('make_bank_voucher');
unhide_field('Update'); unhide_field('update');
} }
else { else {
hide_field('Make Bank Voucher'); hide_field('make_bank_voucher');
hide_field('Update'); hide_field('update');
} }
} }

View File

@ -434,12 +434,12 @@ cur_frm.cscript.calc_other_charges = function(doc , tname , fname , other_fname)
// ------------------ // ------------------
cur_frm.fields_dict['Tax Calculation'].disp_area.innerHTML = '<b style="padding: 8px 0px;">Calculation Details for Taxes, Charges and Landed Cost:</b>'; cur_frm.fields_dict['tax_calculation'].disp_area.innerHTML = '<b style="padding: 8px 0px;">Calculation Details for Taxes, Charges and Landed Cost:</b>';
var cl = getchildren(tname, doc.name, fname); var cl = getchildren(tname, doc.name, fname);
var tax = getchildren('Purchase Taxes and Charges', doc.name, other_fname,doc.doctype); var tax = getchildren('Purchase Taxes and Charges', doc.name, other_fname,doc.doctype);
// make display table // make display table
// ------------------ // ------------------
var otc = make_table(cur_frm.fields_dict['Tax Calculation'].disp_area, cl.length + 1, tax.length + 1, '90%',[],{border:'1px solid #AAA',padding:'2px'}); var otc = make_table(cur_frm.fields_dict['tax_calculation'].disp_area, cl.length + 1, tax.length + 1, '90%',[],{border:'1px solid #AAA',padding:'2px'});
$y(otc,{marginTop:'8px'}); $y(otc,{marginTop:'8px'});
var tax_desc = {}; var tax_desc_rates = []; var net_total = 0; var tax_desc = {}; var tax_desc_rates = []; var net_total = 0;

View File

@ -81,8 +81,8 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
if(doc.docstatus == 1 && doc.status == 'Stopped') if(doc.docstatus == 1 && doc.status == 'Stopped')
cur_frm.add_custom_button('Unstop Purchase Order', cur_frm.cscript['Unstop Purchase Order']); cur_frm.add_custom_button('Unstop Purchase Order', cur_frm.cscript['Unstop Purchase Order']);
if(doc.docstatus == 1) unhide_field(['Repair Purchase Order']); if(doc.docstatus == 1) unhide_field(['repair_purchase_order']);
else hide_field(['Repair Purchase Order']); else hide_field(['repair_purchase_order']);
} }

View File

@ -70,9 +70,9 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.add_custom_button('Unstop ' + cur_frm.cscript.indent_doctype_label, cur_frm.cscript['Unstop Purchase Requisition']) cur_frm.add_custom_button('Unstop ' + cur_frm.cscript.indent_doctype_label, cur_frm.cscript['Unstop Purchase Requisition'])
if(doc.docstatus == 1) if(doc.docstatus == 1)
unhide_field(['Repair Purchase Requisition']); unhide_field(['repair_purchase_requisition']);
else else
hide_field(['Repair Purchase Requisition']); hide_field(['repair_purchase_requisition']);
} }
//======================= validation =================================== //======================= validation ===================================

View File

@ -30,11 +30,11 @@ cur_frm.cscript.onload_post_render = function(doc,cdt,cdn){
cur_frm.cscript.refresh = function(doc,cdt,cdn){ cur_frm.cscript.refresh = function(doc,cdt,cdn){
if(user == doc.kra_approver && doc.status == 'Submitted') if(user == doc.kra_approver && doc.status == 'Submitted')
unhide_field(['Update', 'Declare Completed', 'Calculate Total Score']); unhide_field(['update', 'declare_completed', 'calculate_total_score']);
else hide_field(['Update', 'Declare Completed', 'Calculate Total Score']); else hide_field(['update', 'declare_completed', 'calculate_total_score']);
if(!doc.docstatus) unhide_field('Fetch Template'); if(!doc.docstatus) unhide_field('fetch_template');
else hide_field('Fetch Template'); else hide_field('fetch_template');
} }
@ -119,7 +119,7 @@ cur_frm.cscript.declare_completed = function(doc,cdt,cdn){
$i('declare_completed_dialog_response').innerHTML = 'Done'; $i('declare_completed_dialog_response').innerHTML = 'Done';
refresh_field('status'); refresh_field('status');
declare_completed_dialog.refresh_dt(); declare_completed_dialog.refresh_dt();
hide_field(['Update', 'Declare Completed', 'Calculate Total Score']); hide_field(['update', 'declare_completed', 'calculate_total_score']);
declare_completed_dialog.hide(); declare_completed_dialog.hide();
} }
else if(r.message.status == 'Incomplete'){ else if(r.message.status == 'Incomplete'){

View File

@ -15,8 +15,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
cur_frm.cscript.onload = function(doc,cdt,cdn){ cur_frm.cscript.onload = function(doc,cdt,cdn){
cur_frm.log_div = $a(cur_frm.fields_dict['Import Log1'].wrapper,'div','',{border:'1px solid #CCC', backgroundColor:'#DDD',width : '100%', height : '300px', overflow : 'auto'}); cur_frm.log_div = $a(cur_frm.fields_dict['import_log1'].wrapper,'div','',{border:'1px solid #CCC', backgroundColor:'#DDD',width : '100%', height : '300px', overflow : 'auto'});
hide_field('Import Log1') hide_field('import_log1')
doc.att_fr_date = get_today(); doc.att_fr_date = get_today();
doc.file_list = ''; doc.file_list = '';
doc.overwrite = 0; doc.overwrite = 0;
@ -58,9 +58,9 @@ cur_frm.cscript.import = function(doc,cdt,cdn){
//==================================================== //====================================================
cur_frm.cscript.refresh = function(doc,cdt,cdn){ cur_frm.cscript.refresh = function(doc,cdt,cdn){
if(cur_frm.log_div.innerHTML == '') if(cur_frm.log_div.innerHTML == '')
hide_field('Import Log1'); hide_field('import_log1');
else else
unhide_field('Import Log1'); unhide_field('import_log1');
refresh_field('Import Log1'); refresh_field('import_log1');
} }

View File

@ -34,12 +34,12 @@ cur_frm.cscript.onload = function(doc,cdt,cdn){
} }
cur_frm.cscript.refresh = function(doc,cdt,cdn){ cur_frm.cscript.refresh = function(doc,cdt,cdn){
if((user == doc.exp_approver && doc.approval_status == 'Submitted') || doc.docstatus == 0) unhide_field('Calculate Total Amount'); if((user == doc.exp_approver && doc.approval_status == 'Submitted') || doc.docstatus == 0) unhide_field('calculate_total_amount');
else hide_field('Calculate Total Amount'); else hide_field('calculate_total_amount');
if(user == doc.exp_approver && doc.approval_status == 'Submitted') unhide_field(['Update Voucher', 'Approve', 'Reject']); if(user == doc.exp_approver && doc.approval_status == 'Submitted') unhide_field(['update_voucher', 'approve', 'reject']);
else hide_field(['Update Voucher', 'Approve', 'Reject']); else hide_field(['update_voucher', 'approve', 'reject']);
if(user == doc.exp_approver && doc.approval_status == 'Submitted') set_field_permlevel('remark', 0); if(user == doc.exp_approver && doc.approval_status == 'Submitted') set_field_permlevel('remark', 0);
@ -136,7 +136,7 @@ cur_frm.cscript.approve = function(doc,cdt,cdn){
if(r.message == 'Approved'){ if(r.message == 'Approved'){
$i('approve_voucher_dialog_response').innerHTML = 'Approved'; $i('approve_voucher_dialog_response').innerHTML = 'Approved';
refresh_field('approval_status'); refresh_field('approval_status');
hide_field(['Update Voucher', 'Approve', 'Reject', 'Calculate Total Amount']); hide_field(['update_voucher', 'approve', 'reject', 'calculate_total_amount']);
approve_voucher_dialog.hide(); approve_voucher_dialog.hide();
var args = { var args = {
type: 'Expense Claim Approved', type: 'Expense Claim Approved',
@ -204,7 +204,7 @@ cur_frm.cscript.reject = function(doc,cdt,cdn){
if(r.message == 'Rejected'){ if(r.message == 'Rejected'){
$i('reject_voucher_dialog_response').innerHTML = 'Rejected'; $i('reject_voucher_dialog_response').innerHTML = 'Rejected';
refresh_field('approval_status'); refresh_field('approval_status');
hide_field(['Update Voucher', 'Approve', 'Reject', 'Calculate Total Amount']); hide_field(['update_voucher', 'approve', 'reject', 'calculate_total_amount']);
reject_voucher_dialog.hide(); reject_voucher_dialog.hide();
var args = { var args = {
type: 'Expense Claim Rejected', type: 'Expense Claim Rejected',

View File

@ -16,7 +16,7 @@
var display_activity_log = function(msg) { var display_activity_log = function(msg) {
if(!pscript.ss_html) if(!pscript.ss_html)
pscript.ss_html = $a(cur_frm.fields_dict['Activity Log'].wrapper,'div','',{border:'1px solid #CCC', backgroundColor:'#CCC'}); pscript.ss_html = $a(cur_frm.fields_dict['activity_log'].wrapper,'div','',{border:'1px solid #CCC', backgroundColor:'#CCC'});
pscript.ss_html.innerHTML = '<div style="color:#EEE; background-color:#555;"><b><i>Activity Log:</i><br></b></div>'; pscript.ss_html.innerHTML = '<div style="color:#EEE; background-color:#555;"><b><i>Activity Log:</i><br></b></div>';
pscript.ss_html.innerHTML += '<div style="color:#666; padding: 5px">'+ msg + '</div>'; pscript.ss_html.innerHTML += '<div style="color:#666; padding: 5px">'+ msg + '</div>';
} }

View File

@ -18,9 +18,9 @@
cur_frm.cscript.refresh = function(doc,dt,dn){ cur_frm.cscript.refresh = function(doc,dt,dn){
if(!doc.__islocal) { if(!doc.__islocal) {
set_field_permlevel('item',1); set_field_permlevel('item',1);
unhide_field('Update Cost as on today'); unhide_field('update_cost_as_on_today');
} else { } else {
hide_field('Update Cost as on today'); hide_field('update_cost_as_on_today');
} }
} }