// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
erpnext.fs = {}
pscript['onload_Financial Statements'] = function(wrapper) {
wn.ui.make_app_page({
parent: wrapper,
"title": wn._("Financial Statements"),
"single_column": true,
});
erpnext.fs.stmt_type = wrapper.appframe.add_field({
fieldtype:"Select",
fieldname:"stmt_type",
options: ['Select Statement...','Balance Sheet','Profit & Loss']
})
erpnext.fs.stmt_company = wrapper.appframe.add_field({
fieldtype:"Select",
fieldname:"stmt_company",
options: ['Loading Companies...']
})
erpnext.fs.stmt_period = wrapper.appframe.add_field({
fieldtype:"Select",
fieldname:"stmt_period",
options: ['Select Period...', 'Annual', 'Quarterly', 'Monthly']
})
erpnext.fs.stmt_fiscal_year = wrapper.appframe.add_field({
fieldtype:"Select",
fieldname:"stmt_fiscal_year",
options: ['Loading...']
})
wrapper.appframe.add_button(wn._("Create"), function() {
pscript.stmt_new();
}, "icon-refresh")
wrapper.appframe.add_button(wn._("Print"), function() {
_p.go($i('print_html').innerHTML);
}, "icon-print")
$(wrapper).find(".layout-main").html('
\
\
\
'+wn._('Please select options and click on Create')+'
\
').css({"min-height": "400px"});
// load companies
return $c_obj('MIS Control','get_comp','', function(r,rt) {
// company
erpnext.fs.stmt_company.$input.empty()
.add_options(['Select Company...'].concat(r.message.company));
erpnext.fs.stmt_fiscal_year.$input.empty()
.add_options(['Select Year...'].concat(r.message.fiscal_year));
});
}
pscript.stmt_new = function(stmt,company_name,level,period,year) {
$i('stmt_tree').innerHTML = wn._('Refreshing....');
$i('stmt_tree').style.display = 'block';
var company =erpnext.fs.stmt_company.get_value();
var arg = {
statement: erpnext.fs.stmt_type.get_value(),
company: company,
period: erpnext.fs.stmt_period.get_value(),
year: erpnext.fs.stmt_fiscal_year.get_value()
}
return $c_obj('MIS Control', 'get_statement', docstring(arg), function(r,rt) {
var nl = r.message;
var t = $i('stmt_tree');
var stmt_type = erpnext.fs.stmt_type.get_value();
t.innerHTML = '';
var tab = $a($a(t, 'div'),'table','stmt_table');
tab.style.tableLayout = 'fixed';
tab.style.width = '100%';
$i('stmt_title1').innerHTML = erpnext.fs.stmt_company.get_value()
$i('stmt_title2').innerHTML = erpnext.fs.stmt_type.get_value()
+ ' - ' + erpnext.fs.stmt_fiscal_year.get_value();
for(i=0;i