From cfa7d75621ad176e4a1cfc83e352e56f0a9f4d4f Mon Sep 17 00:00:00 2001 From: nik gaffney Date: Sun, 29 Aug 2021 12:06:08 +0200 Subject: [PATCH] Is there some tightness, cramping, squeezing? --- css/styles.css | 2 +- f20-budget.pl | 155 +++++++++++++++++++++++++++++++++---------------- 2 files changed, 106 insertions(+), 51 deletions(-) diff --git a/css/styles.css b/css/styles.css index a51dbca..a32fcc3 100644 --- a/css/styles.css +++ b/css/styles.css @@ -54,7 +54,7 @@ body { border-style: dotted; border-color: #ffa000; font-family: Courier; - font-size: 1.5em + font-size: 1.5em; text-align: center; padding: 5px; margin-top: 5px; diff --git a/f20-budget.pl b/f20-budget.pl index 1df1b10..0024076 100644 --- a/f20-budget.pl +++ b/f20-budget.pl @@ -8,7 +8,7 @@ no warnings qw(experimental::smartmatch); ############################################################################## # # -# configuration details are kept in a separate file # +# configuration options are kept in a separate file # # # ############################################################################## @@ -660,52 +660,101 @@ sub compile_budget { my $dbh = DBI->connect($db_conect,$db_user,$db_pass) or die ("can't connect: $DBI::errstr"); - my $sqld = qq( SELECT * FROM nonfinance LEFT JOIN agents on nonfinance.agent_id=agents.id LEFT JOIN budgets ON nonfinance.budget_id=budgets.id - LEFT JOIN locations ON locations.structure=budgets.location WHERE nonfinance.budget_id=$budget_id AND nonfinance.status='delivered' ORDER BY nonfinance.item); + my $sqld = qq( + SELECT * FROM nonfinance + LEFT JOIN agents ON nonfinance.agent_id=agents.id + LEFT JOIN budgets ON nonfinance.budget_id=budgets.id + LEFT JOIN locations ON locations.structure=budgets.location + WHERE nonfinance.budget_id=$budget_id + AND nonfinance.status='delivered' + ORDER BY nonfinance.item); my $sthd = $dbh->prepare($sqld); $sthd->execute; - my $sqlol = qq( SELECT * FROM nonfinance LEFT JOIN agents on nonfinance.agent_id=agents.id LEFT JOIN budgets ON nonfinance.budget_id=budgets.id - LEFT JOIN locations ON locations.structure=budgets.location WHERE nonfinance.budget_id=$budget_id AND nonfinance.status!='delivered' AND kind='labour' ORDER BY nonfinance.item); + my $sqlol = qq( + SELECT * FROM nonfinance + LEFT JOIN agents on nonfinance.agent_id=agents.id + LEFT JOIN budgets ON nonfinance.budget_id=budgets.id + LEFT JOIN locations ON locations.structure=budgets.location + WHERE nonfinance.budget_id=$budget_id + AND nonfinance.status!='delivered' + AND kind='labour' + ORDER BY nonfinance.item); my $sthol = $dbh->prepare($sqlol); $sthol->execute; - my $sqlor = qq( SELECT * FROM nonfinance LEFT JOIN agents on nonfinance.agent_id=agents.id LEFT JOIN budgets ON nonfinance.budget_id=budgets.id - LEFT JOIN locations ON locations.structure=budgets.location WHERE nonfinance.budget_id=$budget_id AND nonfinance.status!='delivered' AND kind='resources' ORDER BY nonfinance.item); + my $sqlor = qq( + SELECT * FROM nonfinance + LEFT JOIN agents on nonfinance.agent_id=agents.id + LEFT JOIN budgets ON nonfinance.budget_id=budgets.id + LEFT JOIN locations ON locations.structure=budgets.location + WHERE nonfinance.budget_id=$budget_id + AND nonfinance.status!='delivered' + AND kind='resources' + ORDER BY nonfinance.item); my $sthor = $dbh->prepare($sqlor); $sthor->execute; - my $sqldl = qq( SELECT * FROM nonfinance LEFT JOIN agents on nonfinance.agent_id=agents.id LEFT JOIN budgets ON nonfinance.budget_id=budgets.id - LEFT JOIN locations ON locations.structure=budgets.location WHERE nonfinance.budget_id=$budget_id AND nonfinance.status='delivered' AND kind='labour' ORDER BY nonfinance.item); + my $sqldl = qq( + SELECT * FROM nonfinance + LEFT JOIN agents on nonfinance.agent_id=agents.id + LEFT JOIN budgets ON nonfinance.budget_id=budgets.id + LEFT JOIN locations ON locations.structure=budgets.location + WHERE nonfinance.budget_id=$budget_id + AND nonfinance.status='delivered' + AND kind='labour' + ORDER BY nonfinance.item); my $sthdl = $dbh->prepare($sqldl); $sthdl->execute; - my $sqldr = qq( SELECT * FROM nonfinance LEFT JOIN agents on nonfinance.agent_id=agents.id LEFT JOIN budgets ON nonfinance.budget_id=budgets.id - LEFT JOIN locations ON locations.structure=budgets.location WHERE nonfinance.budget_id=$budget_id AND nonfinance.status='delivered' AND kind='resources' ORDER BY nonfinance.item); + my $sqldr = qq( + SELECT * FROM nonfinance + LEFT JOIN agents on nonfinance.agent_id=agents.id + LEFT JOIN budgets ON nonfinance.budget_id=budgets.id + LEFT JOIN locations ON locations.structure=budgets.location + WHERE nonfinance.budget_id=$budget_id + AND nonfinance.status='delivered' + AND kind='resources' + ORDER BY nonfinance.item); my $sthdr = $dbh->prepare($sqldr); $sthdr->execute; - ## count potential deposits - my $sqla = qq( SELECT COUNT(fullname) AS qty FROM agents WHERE budget_id=$budget_id AND status!='staff'); + my $sqla = qq( + SELECT COUNT(fullname) AS qty FROM agents + WHERE budget_id=$budget_id + AND status!='staff'); my $stha = $dbh->prepare($sqla); $stha->execute; ## count deposits received - my $sqlar = qq( SELECT COUNT(fullname) AS qty FROM agents WHERE budget_id=$budget_id AND status='deposit'); + my $sqlar = qq( + SELECT COUNT(fullname) AS qty FROM agents + WHERE budget_id=$budget_id + AND status='deposit'); my $sthar = $dbh->prepare($sqlar); $sthar->execute; - my $sqlc = qq( SELECT COUNT(*) FROM nonfinance LEFT JOIN agents on nonfinance.agent_id=agent.id LEFT JOIN budgets ON nonfinance.budget_id=budgets.id - LEFT JOIN locations ON locations.structure=budgets.location WHERE nonfinance.budget_id=$budget_id); + my $sqlc = qq( + SELECT COUNT(*) FROM nonfinance + LEFT JOIN agents on nonfinance.agent_id=agent.id + LEFT JOIN budgets ON nonfinance.budget_id=budgets.id + LEFT JOIN locations ON locations.structure=budgets.location + WHERE nonfinance.budget_id=$budget_id); my $sthc = $dbh->prepare($sqlc); $sthc->execute; - my $sqlf = qq( SELECT * FROM finance WHERE budget_id=$budget_id ORDER by amount); + my $sqlf = qq( + SELECT * FROM finance WHERE budget_id=$budget_id + ORDER by amount); my $sthf = $dbh->prepare($sqlf); $sthf->execute; - my $sqlb = qq( SELECT *, date_format(deliver_date,'%d-%m-%Y') AS end_date FROM budgets LEFT JOIN locations on budgets.location=locations.structure WHERE budgets.id=$budget_id); + my $sqlb = qq( + SELECT *, date_format(deliver_date,'%d-%m-%Y') + AS end_date FROM budgets + LEFT JOIN locations on budgets.location=locations.structure + WHERE budgets.id=$budget_id); my $sthb = $dbh->prepare($sqlb); $sthb->execute; @@ -721,8 +770,12 @@ sub compile_budget { my $sthse = $dbh->prepare($sqlse); $sthse->execute; - my $sqlr = qq( SELECT name, fullname, codename from finance LEFT JOIN agents ON finance.agent_id=agents.id - LEFT JOIN budgets ON finance.budget_id = budgets.id WHERE finance.budget_id="$budget_id" AND finance.agent_id="$agent_id"); + my $sqlr = qq( + SELECT name, fullname, codename FROM finance + LEFT JOIN agents ON finance.agent_id=agents.id + LEFT JOIN budgets ON finance.budget_id = budgets.id + WHERE finance.budget_id="$budget_id" + AND finance.agent_id="$agent_id"); my $sthr = $dbh->prepare($sqlr); $sthr->execute; @@ -730,17 +783,27 @@ sub compile_budget { SELECT budget_id, item, cost, currency, type FROM expenditure LEFT JOIN budgets on expenditure.budget_id=budgets.id - WHERE expenditure.budget_id = '$budget_id' + WHERE expenditure.budget_id = '$budget_id' AND type='fee' ORDER BY expenditure.item); my $sthef = $dbh->prepare($sqlef); $sthef->execute; - my $sqlem = qq( SELECT budget_id, item, cost, currency, type FROM expenditure LEFT JOIN budgets on expenditure.budget_id=budgets.id WHERE expenditure.budget_id = '$budget_id' AND type='materials' ORDER BY expenditure.item); + my $sqlem = qq( + SELECT budget_id, item, cost, currency, type FROM expenditure + LEFT JOIN budgets on expenditure.budget_id=budgets.id + WHERE expenditure.budget_id = '$budget_id' + AND type='materials' + ORDER BY expenditure.item); my $sthem = $dbh->prepare($sqlem); $sthem->execute; - my $sqlex = qq( SELECT budget_id, item, cost, currency, type FROM expenditure LEFT JOIN budgets on expenditure.budget_id=budgets.id WHERE expenditure.budget_id = '$budget_id' AND type='misc' ORDER BY expenditure.item); + my $sqlex = qq( + SELECT budget_id, item, cost, currency, type FROM expenditure + LEFT JOIN budgets on expenditure.budget_id=budgets.id + WHERE expenditure.budget_id = '$budget_id' + AND type='misc' + ORDER BY expenditure.item); my $sthex = $dbh->prepare($sqlex); $sthex->execute; @@ -850,14 +913,12 @@ END print_item("$recordex->{item}", ">$recordex->{currency}$display_cost"); } - print_subtotal("INCOME: / donations, contributions, sums, funds"); while (my $recordf = $sthf->fetchrow_hashref) { print_item("", sprintf("€%.2f", $recordf->{amount})); } - ## actual paid deposits while (my $recordar = $sthar->fetchrow_hashref) { while (my @sum = $sths->fetchrow_array()) { @@ -879,13 +940,13 @@ END $display_surplus =~ s/(\d)(?=(\d{3})+(\D|$))/$1\,/g; ## add commma print_subtotal("RUNNING total OUT:","€$display_runningex"); + print_subtotal(" "," "); # spacing between running & balance lines print_subtotal("BALANCE OF FINANCIAL TRADE:"," €$display_surplus"); } print <