From 0788570ce7aaf5bf4f13a8839bd5add3bc11451f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 20 Apr 2012 13:31:05 +0530 Subject: [PATCH 1/2] automatically write off feature in sales invoice --- .../doctype/sales_invoice/sales_invoice.js | 22 +- .../doctype/sales_invoice/sales_invoice.txt | 206 +++++++++--------- 2 files changed, 127 insertions(+), 101 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 4e7a51a261..cddb92e90b 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -86,13 +86,19 @@ cur_frm.cscript.hide_fields = function(doc, cdt, cdn) { if(cint(doc.is_pos) == 1) { hide_field(par_flds); + $(cur_frm.fields_dict.payments_section.row.wrapper).toggle(true); + $(cur_frm.fields_dict.advances.row.wrapper).toggle(false); for(f in item_flds_normal) cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_normal[f], false); for(f in item_flds_pos) cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_pos[f], (doc.update_stock==1?true:false)); } else { unhide_field(par_flds); + $(cur_frm.fields_dict.payments_section.row.wrapper).toggle(false); + $(cur_frm.fields_dict.advances.row.wrapper).toggle(true); for(f in item_flds_normal) cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_normal[f], true); for(f in item_flds_pos) cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_pos[f], false); } + if (doc.docstatus==1) $(cur_frm.fields_dict.recurring_invoice.row.wrapper).toggle(true); + else $(cur_frm.fields_dict.recurring_invoice.row.wrapper).toggle(false); // India related fields var cp = wn.control_panel; @@ -236,9 +242,21 @@ cur_frm.cscript.debit_to = function(doc,dt,dn) { //refresh advance amount //------------------------------------------------- -cur_frm.cscript.paid_amount = function(doc,dt,dn){ + +cur_frm.cscript.write_off_outstanding_amount_automatically = function(doc) { + if (doc.write_off_outstanding_amount_automatically == 1) + doc.write_off_amount = flt(doc.grand_total) - flt(doc.paid_amount); + doc.outstanding_amount = flt(doc.grand_total) - flt(doc.paid_amount) - flt(doc.write_off_amount); - refresh_field('outstanding_amount'); + refresh_field(['write_off_amount', 'outstanding_amount']); +} + +cur_frm.cscript.paid_amount = function(doc) { + cur_frm.cscript.write_off_outstanding_amount_automatically(doc); +} + +cur_frm.cscript.write_off_amount = function(doc) { + cur_frm.cscript.write_off_outstanding_amount_automatically(doc); } diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.txt b/erpnext/accounts/doctype/sales_invoice/sales_invoice.txt index c851e75952..6e76145291 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.txt +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.txt @@ -3,9 +3,9 @@ # These values are common in all dictionaries { - 'creation': '2012-04-11 13:17:25', + 'creation': '2012-04-13 11:56:18', 'docstatus': 0, - 'modified': '2012-04-13 11:26:44', + 'modified': '2012-04-20 11:52:36', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -27,7 +27,7 @@ 'server_code_error': u' ', 'show_in_menu': 0, 'subject': u'To %(customer_name)s worth %(currency)s %(grand_total_export)s due on %(due_date)s | %(outstanding_amount)s outstanding', - 'version': 418 + 'version': 1 }, # These values are common for all DocField @@ -580,23 +580,6 @@ 'trigger': u'Client' }, - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'section_break1', - 'fieldtype': u'Section Break', - 'permlevel': 0 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'column_break3', - 'fieldtype': u'Column Break', - 'permlevel': 0, - 'width': u'50%' - }, - # DocField { 'description': u'Will be calculated automatically when you enter the details', @@ -611,83 +594,6 @@ 'reqd': 1 }, - # DocField - { - 'colour': u'White:FFF', - 'depends_on': u'eval:doc.is_pos==1', - 'doctype': u'DocField', - 'fieldname': u'cash_bank_account', - 'fieldtype': u'Link', - 'label': u'Cash/Bank Account', - 'oldfieldname': u'cash_bank_account', - 'oldfieldtype': u'Link', - 'options': u'Account', - 'permlevel': 0, - 'print_hide': 1 - }, - - # DocField - { - 'colour': u'White:FFF', - 'depends_on': u'eval:doc.is_pos==1', - 'doctype': u'DocField', - 'fieldname': u'paid_amount', - 'fieldtype': u'Currency', - 'label': u'Paid Amount', - 'oldfieldname': u'paid_amount', - 'oldfieldtype': u'Currency', - 'permlevel': 0, - 'print_hide': 1, - 'trigger': u'Client' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'column_break4', - 'fieldtype': u'Column Break', - 'permlevel': 0, - 'width': u'50%' - }, - - # DocField - { - 'colour': u'White:FFF', - 'depends_on': u'eval:doc.is_pos==1', - 'doctype': u'DocField', - 'fieldname': u'write_off_account', - 'fieldtype': u'Link', - 'label': u'Write Off Account', - 'options': u'Account', - 'permlevel': 0, - 'print_hide': 1 - }, - - # DocField - { - 'colour': u'White:FFF', - 'depends_on': u'eval:doc.is_pos==1', - 'doctype': u'DocField', - 'fieldname': u'write_off_cost_center', - 'fieldtype': u'Link', - 'label': u'Write Off Cost Center', - 'options': u'Cost Center', - 'permlevel': 0, - 'print_hide': 1 - }, - - # DocField - { - 'colour': u'White:FFF', - 'depends_on': u'eval:doc.is_pos==1', - 'doctype': u'DocField', - 'fieldname': u'write_off_amount', - 'fieldtype': u'Currency', - 'label': u'Write Off Amount', - 'permlevel': 0, - 'print_hide': 1 - }, - # DocField { 'doctype': u'DocField', @@ -938,6 +844,109 @@ 'print_hide': 1 }, + # DocField + { + 'colour': u'White:FFF', + 'doctype': u'DocField', + 'fieldname': u'payments_section', + 'fieldtype': u'Section Break', + 'label': u'Payments', + 'permlevel': 0 + }, + + # DocField + { + 'colour': u'White:FFF', + 'doctype': u'DocField', + 'fieldname': u'column_break3', + 'fieldtype': u'Column Break', + 'permlevel': 0, + 'width': u'50%' + }, + + # DocField + { + 'colour': u'White:FFF', + 'doctype': u'DocField', + 'fieldname': u'paid_amount', + 'fieldtype': u'Currency', + 'label': u'Paid Amount', + 'oldfieldname': u'paid_amount', + 'oldfieldtype': u'Currency', + 'permlevel': 0, + 'print_hide': 1, + 'trigger': u'Client' + }, + + # DocField + { + 'colour': u'White:FFF', + 'doctype': u'DocField', + 'fieldname': u'cash_bank_account', + 'fieldtype': u'Link', + 'label': u'Cash/Bank Account', + 'oldfieldname': u'cash_bank_account', + 'oldfieldtype': u'Link', + 'options': u'Account', + 'permlevel': 0, + 'print_hide': 1 + }, + + # DocField + { + 'colour': u'White:FFF', + 'doctype': u'DocField', + 'fieldname': u'column_break4', + 'fieldtype': u'Column Break', + 'permlevel': 0, + 'width': u'50%' + }, + + # DocField + { + 'colour': u'White:FFF', + 'doctype': u'DocField', + 'fieldname': u'write_off_outstanding_amount_automatically', + 'fieldtype': u'Check', + 'label': u'Write Off Outstanding Amount Automatically', + 'permlevel': 0 + }, + + # DocField + { + 'colour': u'White:FFF', + 'doctype': u'DocField', + 'fieldname': u'write_off_amount', + 'fieldtype': u'Currency', + 'label': u'Write Off Amount', + 'permlevel': 0, + 'print_hide': 1 + }, + + # DocField + { + 'colour': u'White:FFF', + 'doctype': u'DocField', + 'fieldname': u'write_off_account', + 'fieldtype': u'Link', + 'label': u'Write Off Account', + 'options': u'Account', + 'permlevel': 0, + 'print_hide': 1 + }, + + # DocField + { + 'colour': u'White:FFF', + 'doctype': u'DocField', + 'fieldname': u'write_off_cost_center', + 'fieldtype': u'Link', + 'label': u'Write Off Cost Center', + 'options': u'Cost Center', + 'permlevel': 0, + 'print_hide': 1 + }, + # DocField { 'colour': u'White:FFF', @@ -1232,7 +1241,6 @@ # DocField { 'colour': u'White:FFF', - 'depends_on': u'eval:!doc.is_pos', 'doctype': u'DocField', 'fieldname': u'advances', 'fieldtype': u'Section Break', @@ -1369,7 +1377,7 @@ # DocField { - 'depends_on': u'eval:doc.docstatus==1', + 'colour': u'White:FFF', 'doctype': u'DocField', 'fieldname': u'recurring_invoice', 'fieldtype': u'Section Break', From f30d1a051550c53608dd5a0489e0dea448e5f868 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 20 Apr 2012 13:37:49 +0530 Subject: [PATCH 2/2] report builder - sort, save, pre-select columns, Report DocType --- .../doctype/question_control/__init__.py | 0 .../question_control/question_control.txt | 30 -------------- .../page/question_view/question_view.js | 2 +- js/all-app.js | 39 +++++++++++++------ js/all-web.js | 39 +++++++++++++------ 5 files changed, 57 insertions(+), 53 deletions(-) delete mode 100644 erpnext/knowledge_base/doctype/question_control/__init__.py delete mode 100644 erpnext/knowledge_base/doctype/question_control/question_control.txt diff --git a/erpnext/knowledge_base/doctype/question_control/__init__.py b/erpnext/knowledge_base/doctype/question_control/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/knowledge_base/doctype/question_control/question_control.txt b/erpnext/knowledge_base/doctype/question_control/question_control.txt deleted file mode 100644 index b1443363c2..0000000000 --- a/erpnext/knowledge_base/doctype/question_control/question_control.txt +++ /dev/null @@ -1,30 +0,0 @@ -# DocType, Question Control -[ - - # These values are common in all dictionaries - { - 'creation': '2012-03-27 14:36:02', - 'docstatus': 0, - 'modified': '2012-03-27 14:36:02', - 'modified_by': u'Administrator', - 'owner': u'Administrator' - }, - - # These values are common for all DocType - { - 'colour': u'White:FFF', - 'doctype': 'DocType', - 'issingle': 1, - 'module': u'Knowledge Base', - 'name': '__common__', - 'section_style': u'Simple', - 'server_code_error': u' ', - 'version': 1 - }, - - # DocType, Question Control - { - 'doctype': 'DocType', - 'name': u'Question Control' - } -] \ No newline at end of file diff --git a/erpnext/knowledge_base/page/question_view/question_view.js b/erpnext/knowledge_base/page/question_view/question_view.js index 86a2b98166..dedf09c4ff 100644 --- a/erpnext/knowledge_base/page/question_view/question_view.js +++ b/erpnext/knowledge_base/page/question_view/question_view.js @@ -16,7 +16,7 @@ pscript['onload_question-view'] = function(wrapper) { wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.layout-appframe')); - wrapper.appframe.title('Knowledge Base'); + wrapper.appframe.title('Knowledge Base'); wrapper.add_answer_area = $('.add-answer-area').get(0); } diff --git a/js/all-app.js b/js/all-app.js index 8c1058bed3..d22d502915 100644 --- a/js/all-app.js +++ b/js/all-app.js @@ -214,7 +214,7 @@ if(!wn.boot.user_info[uid].fullname) wn.boot.user_info[uid].fullname=uid;if(!wn.boot.user_info[uid].image) wn.boot.user_info[uid].image=def.image;return wn.boot.user_info[uid];} wn.provide('wn.user');$.extend(wn.user,{name:wn.boot.profile.name,has_role:function(rl){if(typeof rl=='string')rl=[rl];for(var i in rl){if(wn.boot.profile.roles.indexOf(rl[i])!=-1) -return true;}}}) +return true;}},is_report_manager:function(){return wn.user.has_role(['Administrator','System Manager','Report Manager']);}}) wn.session_alive=true;$(document).bind('mousemove',function(){wn.session_alive=true;if(wn.session_alive_timeout) clearTimeout(wn.session_alive_timeout);wn.session_alive_timeout=setTimeout('wn.session_alive=false;',30000);}) /* @@ -251,7 +251,7 @@ throw new SyntaxError('JSON.parse');};}}()); wn.re_route={} wn.route=function(){if(wn.re_route[window.location.hash]){window.location.hash=wn.re_route[window.location.hash];} wn._cur_route=window.location.hash;route=wn.get_route();switch(route[0]){case"List":wn.views.doclistview.show(route[1]);break;case"Form":if(route.length>3){route[2]=route.splice(2).join('/');} -wn.views.formview.show(route[1],route[2]);break;case"Report":wn.views.reportview.show(route[1],route[2]);break;case"Report2":wn.views.reportview2.show(route[1],route[2]);break;default:wn.views.pageview.show(route[0]);}} +wn.views.formview.show(route[1],route[2]);break;case"Report":wn.views.reportview.show(route[1],route[2]);break;case"Report2":wn.views.reportview2.show();break;default:wn.views.pageview.show(route[0]);}} wn.get_route=function(route){if(!route) route=window.location.hash;if(route.substr(0,1)=='#')route=route.substr(1);if(route.substr(0,1)=='!')route=route.substr(1);return $.map(route.split('/'),function(r){return decodeURIComponent(r);});} wn.set_route=function(){route=$.map(arguments,function(a){return encodeURIComponent(a)}).join('/');window.location.hash=route;wn.app.set_favicon();} @@ -268,11 +268,11 @@ this.prepare_opts();$.extend(this,this.opts);$(this.parent).html(repl('\ \
\
\ +
\
\ \
\ -
\
\
\ \ @@ -327,7 +327,7 @@ return this.filters[i];}}});wn.ui.Filter=Class.extend({init:function(opts){$.ext \ \ \ - \ + \ \ \ \ @@ -345,8 +345,9 @@ df.fieldtype=df.original_type;else df.original_type=df.fieldtype;df.description='';df.reqd=0;if(fieldtype){df.fieldtype=fieldtype;return;} if(df.fieldtype=='Check'){df.fieldtype='Select';df.options='No\nYes';}else if(['Text','Text Editor','Code','Link'].indexOf(df.fieldtype)!=-1){df.fieldtype='Data';}},set_default_condition:function(df,fieldtype){if(!fieldtype){if(df.fieldtype=='Data'){this.$w.find('.condition').val('like');}else{this.$w.find('.condition').val('=');}}},get_value:function(){var me=this;var val=me.field.get_value();var cond=me.$w.find('.condition').val();if(me.field.df.original_type=='Check'){val=(val=='Yes'?1:0);} if(cond=='like'){val=val+'%';} -return[me.fieldselect.$select.find('option:selected').attr('table'),me.field.df.fieldname,me.$w.find('.condition').val(),cstr(val)];}});wn.ui.FieldSelect=Class.extend({init:function(parent,doctype,filter_fields){this.doctype=doctype;this.fields_by_name={};this.$select=$('').appendTo(parent);if(filter_fields){for(var i in filter_fields) +this.add_field_option(this.filter_fields[i])}else{this.build_options();}},build_options:function(){var me=this;me.table_fields=[];var std_filters=[{fieldname:'name',fieldtype:'Data',label:'ID',parent:me.doctype},{fieldname:'modified',fieldtype:'Date',label:'Last Modified',parent:me.doctype},{fieldname:'owner',fieldtype:'Data',label:'Created By',parent:me.doctype},{fieldname:'creation',fieldtype:'Date',label:'Created On',parent:me.doctype},{fieldname:'_user_tags',fieldtype:'Data',label:'Tags',parent:me.doctype}];if(this.with_blank){this.$select.append($('\ \ \ - \ + \ \ \ \ @@ -232,8 +232,9 @@ df.fieldtype=df.original_type;else df.original_type=df.fieldtype;df.description='';df.reqd=0;if(fieldtype){df.fieldtype=fieldtype;return;} if(df.fieldtype=='Check'){df.fieldtype='Select';df.options='No\nYes';}else if(['Text','Text Editor','Code','Link'].indexOf(df.fieldtype)!=-1){df.fieldtype='Data';}},set_default_condition:function(df,fieldtype){if(!fieldtype){if(df.fieldtype=='Data'){this.$w.find('.condition').val('like');}else{this.$w.find('.condition').val('=');}}},get_value:function(){var me=this;var val=me.field.get_value();var cond=me.$w.find('.condition').val();if(me.field.df.original_type=='Check'){val=(val=='Yes'?1:0);} if(cond=='like'){val=val+'%';} -return[me.fieldselect.$select.find('option:selected').attr('table'),me.field.df.fieldname,me.$w.find('.condition').val(),cstr(val)];}});wn.ui.FieldSelect=Class.extend({init:function(parent,doctype,filter_fields){this.doctype=doctype;this.fields_by_name={};this.$select=$('').appendTo(parent);if(filter_fields){for(var i in filter_fields) +this.add_field_option(this.filter_fields[i])}else{this.build_options();}},build_options:function(){var me=this;me.table_fields=[];var std_filters=[{fieldname:'name',fieldtype:'Data',label:'ID',parent:me.doctype},{fieldname:'modified',fieldtype:'Date',label:'Last Modified',parent:me.doctype},{fieldname:'owner',fieldtype:'Data',label:'Created By',parent:me.doctype},{fieldname:'creation',fieldtype:'Date',label:'Created On',parent:me.doctype},{fieldname:'_user_tags',fieldtype:'Data',label:'Tags',parent:me.doctype}];if(this.with_blank){this.$select.append($('