From: Kilian Saffran Date: Mon, 1 Oct 2018 07:40:14 +0000 (+0200) Subject: accounting modifications X-Git-Tag: 3.24.5^0 X-Git-Url: http://cloud.dks.lu/git/?a=commitdiff_plain;h=7a375ff70ecc451030df593473731003e6b71fb0;p=creorga.git accounting modifications --- diff --git a/app_v3/chrome/content/js/license.js b/app_v3/chrome/content/js/license.js index 6ccbe59..74810c1 100644 --- a/app_v3/chrome/content/js/license.js +++ b/app_v3/chrome/content/js/license.js @@ -80,7 +80,7 @@ var license = { // if (lickey.match(reglid) != "" && (expiration) && (test <= expiration)){ // navigation.load_deck(2); // } - dump(e.message); + //dump(e.message); return data; } @@ -111,13 +111,13 @@ var license = { var cruuid = appdb.generate_uuid(); var dbname = system.profiledir() + system.sep() + cruuid +".sqlite"; var dbclone = system.appdir() + system.sep() +"defaults"+system.sep()+"profile"+system.sep()+"creorga.sqlite"; - dump("DB to clone: " + dbclone); + //dump("DB to clone: " + dbclone); OS.File.copy(dbclone, dbname); apppref.setpreference("support.database.currentdb.num", 1); apppref.setpreference("support.database.currentdb.db",dbname); appdb.dbFile=FileUtils.File(apppref.getpreference("support.database.currentdb.db")); var nb = {name:'Crèche',uuid:cruuid,dbnum:1,path:{local:system.profiledir(),remote:null},lastsync:null}; - dump("Database set:" + JSON.stringify(nb) + "\n"); + //dump("Database set:" + JSON.stringify(nb) + "\n"); apppref.setpreference("support.database.1", nb); curcfg.loadconfig(1); //dump(appdb.dbFile.path + "\n"); diff --git a/app_v3/chrome/content/modules/accounting/js/accounting.js b/app_v3/chrome/content/modules/accounting/js/accounting.js index 510fe2f..891937a 100644 --- a/app_v3/chrome/content/modules/accounting/js/accounting.js +++ b/app_v3/chrome/content/modules/accounting/js/accounting.js @@ -28,6 +28,7 @@ function initdata(){ if (configdata != '') { pconfig = JSON.parse(configdata); } + if (!pconfig.printlayout) { pconfig.printlayout = 'list'; apppref.setpreference("pageconfig.accounting",pconfig); @@ -67,7 +68,6 @@ function initdata(){ //load_column_selection(); } - function load_accounting_table(){ //dump("accounting:" + JSON.stringify(pconfig) + "\n"); var accyear = pconfig.accmonth.substring(3,7); diff --git a/app_v3/chrome/content/modules/accounting/js/accountingchild.js b/app_v3/chrome/content/modules/accounting/js/accountingchild.js index d4f4188..827f149 100644 --- a/app_v3/chrome/content/modules/accounting/js/accountingchild.js +++ b/app_v3/chrome/content/modules/accounting/js/accountingchild.js @@ -23,7 +23,7 @@ function initdata(){ var ccreche = appdb.dbquery("select uuid from creche LIMIT 1;"); crecheuuid = ccreche.sqldata[0].uuid; importpath = FileUtils.File(curcfg.path.local + system.sep() +"imports" + system.sep() + crecheuuid); - + check_accountingtable(); load_childlist(); if (pconfig.accchild) { // @@ -93,7 +93,7 @@ function load_accounting_table(){ "case when acc.invoiceamount is not null then printf(\"%.2f\",COALESCE(acc.invoiceamount,0.00)) || '€' || case when acc.invoicedate is not null then '
(' || strftime('%d.%m.%Y',acc.invoicedate) || ')' || CASE WHEN acc.reminderdate1 IS NOT NULL THEN '
R1:' || strftime('%d.%m.%Y',acc.reminderdate1) ELSE '' END || CASE WHEN acc.reminderdate2 IS NOT NULL THEN '
R2:' || strftime('%d.%m.%Y',acc.reminderdate2) ELSE '' END || CASE WHEN acc.reminderdate3 IS NOT NULL THEN '
R3:' || strftime('%d.%m.%Y',acc.reminderdate3) ELSE '' END else '' end else '' end as invoiced, " + "case when acc.payedamount is not null then printf(\"%.2f\",COALESCE(acc.payedamount,0.00)) || '€' || case when acc.payeddate is not null then '
(' || strftime('%d.%m.%Y',acc.payeddate) || ')' else '' end else '' end as payement," + "case when acc.benefitamount is not null then printf(\"%.2f\",COALESCE(acc.benefitamount,0.00)) || '€' else '' end as benefitamount," + - "'' || CASE WHEN acc.invoicefile IS NOT NULL and acc.invoicefile != '' THEN '' ELSE '' END AS act " + + "'' || CASE WHEN acc.invoicefile IS NOT NULL and acc.invoicefile != '' THEN '' ELSE '' END AS act " + "FROM ( SELECT pch.childname, pch.childuuid, px.calweek, px.calmonth, px.sumdurationcalweek, px.sumlunchcalweek, " + "CASE WHEN px.sumdurationcalweek IS NOT NULL AND pch.checkservicenumber IS NOT NULL THEN ( SELECT coalesce(wc0.costsperhour,0.00) FROM costs wc0 WHERE wc0.startdate < date('"+yearmin+"','+' || caldays || ' days') and wc0.weeklyhourslimit <= px.sumdurationcalweek ORDER BY wc0.startdate DESC,wc0.weeklyhourslimit DESC LIMIT 1 ) WHEN px.sumdurationcalweek IS NOT NULL AND pch.checkservicenumber IS NULL THEN ( SELECT coalesce(wc0.costperhourfallback,0.00) FROM costs wc0 WHERE wc0.startdate < date('"+yearmin+"','+' || caldays || ' days') and wc0.weeklyhourslimit <= px.sumdurationcalweek ORDER BY wc0.startdate DESC,wc0.weeklyhourslimit DESC LIMIT 1 ) ELSE NULL END AS weekhourcosts,"+ @@ -140,7 +140,8 @@ function load_accounting_table(){ var accdata = appdb.dbquery(accsql); - //jsdump(accsql); + //jsdump("accchildsql"); + //jsdump(accsql); var headerdata = getlabels("calmonth,weekdetails,reference,invoiced,payement,benefitamount,act"); //,monthtotalhourcosts,monthtotallunchcosts,monthtotalcosts @@ -516,4 +517,16 @@ function onhidecolumn(coltohide) { header: 'Décompte par enfant' }); //dump("Hide column " + coltohide + "\n"); -} \ No newline at end of file +} + +function check_accountingtable(){ + var cols = appdb.dbquery("SELECT type, name,tbl_name,sql FROM sqlite_master where tbl_name='accounting';"); + //jsdump(JSON.stringify(cols)); + if (cols.sqldata[0].sql.indexOf("nocheckservice") == -1){ + //jsdump("Install missing column! ALTER TABLE accounting add column nocheckservice integer"); + appdb.dbexec("ALTER TABLE accounting add column nocheckservice integer;"); + } + // else { + // jsdump("missing column found!"); + // } +}