Skip to content

Commit

Permalink
Minor improvements to the Annual Clients Report.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcameron committed Aug 1, 2024
1 parent cd108fd commit 5138e21
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 19 deletions.
4 changes: 4 additions & 0 deletions client/src/css/structure.css
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@
color : #505050;
}

.no-top-margin {
margin-top: 0;
}

/**
* Application Header
*
Expand Down
3 changes: 2 additions & 1 deletion client/src/i18n/en/report.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@
"HIDE_LOCKED_CLIENTS" : "Hide Locked Clients",
"HIDE_LOCKED_CLIENTS_HELP_TEXT" : "Selecting yes will filter out all locked clients from the report. By default, the value is no.",
"INCLUDE_CASH_CLIENTS" : "Include Cash Clients",
"INCLUDE_CASH_CLIENTS_HELP_TEXT" : "Selecting this option will add in cash debtor groups. By default only non-cash clients (conventions) are queried."
"INCLUDE_CASH_CLIENTS_HELP_TEXT" : "Selecting this option will add in cash debtor groups. By default only non-cash clients (conventions) are queried.",
"NO_LOCKED_CLIENTS_FOUND" : "No locked clients found."
},
"CLOSING_BALANCE": "Closing Balance",
"COMPARE_INVOICED_RECEIVED": {
Expand Down
2 changes: 2 additions & 0 deletions client/src/i18n/en/table.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"BY": "by",
"CASHBOX": "Cashbox",
"CASES": "Cases",
"CASHQ": "Cash?",
"CANCEL_CASH": "Cancel Cash Payment",
"CHARGE": "cost",
"CHARGES": "costs",
Expand Down Expand Up @@ -152,6 +153,7 @@
"LISTS": "Registered price list",
"LOADING": "Fetching data from the server.",
"LOCKED": "Locked",
"LOCKEDQ": "Locked?",
"LOT": "Lot / Batch",
"LONGITUDE": "Longitude",
"LATITUDE": "Latitude",
Expand Down
3 changes: 2 additions & 1 deletion client/src/i18n/fr/report.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@
"HIDE_LOCKED_CLIENTS" : "Masquer les clients verrouillés",
"HIDE_LOCKED_CLIENTS_HELP_TEXT" : "Si vous sélectionnez oui, tous les clients verrouillés seront filtrés dans le rapport. Par défaut, la valeur est non.",
"INCLUDE_CASH_CLIENTS" : "Inclure les payant cash",
"INCLUDE_CASH_CLIENTS_HELP_TEXT" : "La sélection de cette option ajoutera des groupes de débiteurs en espèces. Par défaut, seules les conventions sont interrogées."
"INCLUDE_CASH_CLIENTS_HELP_TEXT" : "La sélection de cette option ajoutera des groupes de débiteurs en espèces. Par défaut, seules les conventions sont interrogées.",
"NO_LOCKED_CLIENTS_FOUND" : "Aucun client bloqué n'a été trouvé."
},
"UNPAID_INVOICE_PAYMENTS_REPORT": {
"TITLE": "Rapport de Factures Non-Payées",
Expand Down
2 changes: 2 additions & 0 deletions client/src/i18n/fr/table.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"CANCEL_CASH": "Annuler le paiement",
"BY": "Par",
"CASES": "Cas",
"CASHQ": "Cash ?",
"CASHBOX": "Caisse",
"CHARGE": "Charge",
"CHARGES": "Charges",
Expand Down Expand Up @@ -152,6 +153,7 @@
"LISTS": "Liste des prix enregistrés",
"LOADING": "Récupération des données à partir du serveur.",
"LOCKED": "Bloquée",
"LOCKEDQ": "Bloquée ?",
"LONGITUDE": "Longitude",
"LATITUDE": "Latitude",
"LOT": "Lot",
Expand Down
6 changes: 5 additions & 1 deletion client/src/modules/debtors/groups.list.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ <h5 style="margin-top : 0px;"></span><span translate> FORM.LABELS.ACCOUNT_NUMBER
<a data-method="update" ui-sref="debtorGroups.update({uuid : debtorGroup.uuid})" class=""><span class="fa fa-pencil-square-o" aria-hidden="true"></span> <span translate>DEBTOR_GROUP.EDIT</span></a>
</div>
</div>

<div class="row" ng-if="debtorGroup.note">
<div class="col-md-9">
<h5 class="no-top-margin">{{ debtorGroup.note }}</h5>
</div>
</div>
<div class="row">
<div class="col-md-9">
<div class="row">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
{{> head }}

<style>
th.rotate {
height: 11ex;
white-space: nowrap;
padding-bottom: 6px !important;
}
th.rotate > div {
-webkit-transform: translateX(25%) translateY(25%) rotate(-90deg);
transform: translateX(25%) translateY(25%) rotate(-90deg);
width: 3ex;
padding-left: 6px !important;
}
th.right {
text-align: right;
}
td.center {
text-align: center;
}
</style>

<body>
<main class="container">
{{#> header }}
<h4 class="text-right text-capitalize">
{{ fiscalYear.label }}
<strong>{{fiscalYear.label}}</strong><br/>
{{date fiscalYear.start_date "MMMM YYYY"}} - {{date fiscalYear.end_date "MMMM YYYY"}}
</h4>
{{/header}}

Expand All @@ -16,39 +37,56 @@
<tr class="text-capitalize text-center" style="background-color: #ddd;">
<th>{{translate "TABLE.COLUMNS.ACCOUNT"}}</th>
<th>{{translate "TABLE.COLUMNS.NAME"}}</th>
<th>{{translate "REPORT.OPENING_BALANCE"}}</th>
<th>{{translate "TABLE.COLUMNS.DEBIT"}}</th>
<th>{{translate "TABLE.COLUMNS.CREDIT"}}</th>
<th>{{translate "FORM.LABELS.DIFFERENCE"}}</th>
<th>{{translate "REPORT.CLOSING_BALANCE"}}</th>
{{#if includeCashClients}}
<th class="rotate"><div>{{translate "TABLE.COLUMNS.CASHQ"}}</div></th>
{{/if}}
{{#if showLockedColumn}}
<th class="rotate"><div>{{translate "TABLE.COLUMNS.LOCKEDQ"}}</div></th>
{{/if}}
<th class="right">{{translate "REPORT.OPENING_BALANCE"}}</th>
<th class="right">{{translate "TABLE.COLUMNS.DEBIT"}}</th>
<th class="right">{{translate "TABLE.COLUMNS.CREDIT"}}</th>
<th class="right">{{translate "FORM.LABELS.DIFFERENCE"}}</th>
<th class="right">{{translate "REPORT.CLOSING_BALANCE"}}</th>
</tr>
</thead>
<tbody>
<!-- print a row for each debtor account-->
{{#each rows as | row |}}
<tr>
<td>{{row.accountNumber}}</td>
<td>{{row.groupName }}</td>
<td>{{row.groupName}}</td>
{{#if ../includeCashClients}}
<td class="center">{{#if row.isConvention}}{{else}}<strong>X</strong>{{/if}}</td>
{{/if}}
{{#if ../showLockedColumn}}
<td class="center">{{#if row.locked}}<strong>X</strong>{{/if}}</td>
{{/if}}
<td class="text-right">{{debcred row.openingBalance row.currencyId}}</td>
<td class="text-right">{{debcred row.debit row.currencyId}}</td>
<td class="text-right">{{debcred row.credit row.currencyId}}</td>
<td class="text-right">{{debcred row.movement row.currencyId}}</td>
<td class="text-right">{{debcred row.closingBalance row.currencyId}}</td>
</tr>
{{else}}
{{> emptyTable columns="6" }}
{{> emptyTable columns="{{../numCols}}" }}
{{/each}}
</tbody>

<tfoot>
<th colspan="2">{{translate "TABLE.COLUMNS.TOTAL"}}</th>
<th colspan="{{skipCols}}">{{translate "TABLE.COLUMNS.TOTAL"}}</th>
<th class="text-right">{{debcred footer.openingBalance footer.currencyId}}</th>
<th class="text-right">{{debcred footer.debit footer.currencyId}}</th>
<th class="text-right">{{debcred footer.credit footer.currencyId}}</th>
<th class="text-right">{{debcred footer.movement footer.currencyId}}</th>
<th class="text-right">{{debcred footer.closingBalance footer.currencyId}}</th>
</tfoot>
</table>
{{#if noLockedClientsFound}}
<div style="padding-top: 1ex">
<hr4 ><strong>* {{translate "REPORT.CLIENTS.NO_LOCKED_CLIENTS_FOUND"}}</strong></hr4>
</div>
{{/if}}
</section>
</main>
</body>
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ async function setupAnnualClientsReport(options, enterprise) {
const currencyId = Number(options.currencyId);

// convert to an integer
const shouldHideLockedClients = Number(hideLockedClients);
const shouldIncludeCashClients = Number(includeCashClients);
const shouldHideLockedClients = Number(hideLockedClients);
const showLockedClients = shouldHideLockedClients === 0 ? 1 : 0;

const [fiscalYear, exchange] = await Promise.all([
Fiscal.lookupFiscalYear(fiscalId),
Expand All @@ -33,8 +34,26 @@ async function setupAnnualClientsReport(options, enterprise) {
getTotalsFooter(fiscalYear.id, currencyId, rate, shouldHideLockedClients, shouldIncludeCashClients),
]);

// Computations for optional columns
const numLocked = rows.reduce((sum, row) => sum + (row.locked ? 1 : 0), 0);
const noLockedClientsFound = Number(!shouldHideLockedClients && (numLocked === 0));
const showLockedColumn = Number(!shouldHideLockedClients && (numLocked > 0));
const skipCols = 2 + shouldIncludeCashClients + (showLockedColumn ? 1 : 0);
const numCols = 6 + skipCols;

return {
rows, footer, fiscalYear, exchangeRate : rate, currencyId,
rows,
footer,
fiscalYear,
exchangeRate : rate,
currencyId,
lockedClients : showLockedClients,
showLockedColumn,
noLockedClientsFound,
numLocked,
includeCashClients : shouldIncludeCashClients,
skipCols,
numCols,
};
}

Expand Down Expand Up @@ -91,7 +110,8 @@ function getDebtorGroupMovements(fiscalYearId, currencyId, rate, hideLockedClien
const hiddenClientsCondition = ' AND dg.locked = 0 ';
const excludeCashClientsCondition = 'AND dg.is_convention = 1 ';
const sql = `
SELECT ac.number AS accountNumber, dg.name AS groupName,
SELECT act.number AS accountNumber, dg.name AS groupName,
dg.locked, dg.is_convention AS isConvention,
IFNULL(SUM(IF(p.number = 0, pt.debit - pt.credit, 0)), 0) * ${rate} AS openingBalance,
IFNULL(SUM(IF(p.number > 0, pt.debit, 0)), 0) * ${rate} AS debit,
IFNULL(SUM(IF(p.number > 0, pt.credit, 0)), 0) * ${rate} AS credit,
Expand All @@ -100,13 +120,13 @@ function getDebtorGroupMovements(fiscalYearId, currencyId, rate, hideLockedClien
${currencyId} as currencyId
FROM debtor_group dg
LEFT JOIN period_total pt ON dg.account_id = pt.account_id
LEFT JOIN account ac ON ac.id = pt.account_id
LEFT JOIN account act ON act.id = pt.account_id
LEFT JOIN period p ON p.id = pt.period_id
WHERE pt.fiscal_year_id = ?
${hideLockedClients ? hiddenClientsCondition : ''}
${includeCashClients ? '' : excludeCashClientsCondition}
GROUP BY pt.account_id
ORDER BY ac.number ASC, dg.name DESC;
ORDER BY act.number ASC, dg.name DESC;
`;

return db.exec(sql, fiscalYearId);
Expand All @@ -123,7 +143,7 @@ function getTotalsFooter(fiscalYearId, currencyId, rate, hideLockedClients = 0,
const hiddenClientsCondition = ' AND dg.locked = 0 ';
const excludeCashClientsCondition = 'AND dg.is_convention = 1 ';
const sql = `
SELECT ac.number AS accountNumber, ac.label AS accountLabel,
SELECT act.number AS accountNumber, act.label AS accountLabel,
IFNULL(SUM(IF(p.number = 0, pt.debit - pt.credit, 0)), 0) * ${rate} AS openingBalance,
IFNULL(SUM(IF(p.number > 0, pt.debit, 0)), 0) * ${rate} AS debit,
IFNULL(SUM(IF(p.number > 0, pt.credit, 0)), 0) * ${rate} AS credit,
Expand All @@ -132,7 +152,7 @@ function getTotalsFooter(fiscalYearId, currencyId, rate, hideLockedClients = 0,
${currencyId} as currencyId
FROM debtor_group dg
LEFT JOIN period_total pt ON dg.account_id = pt.account_id
LEFT JOIN account ac ON ac.id = pt.account_id
LEFT JOIN account act ON act.id = pt.account_id
LEFT JOIN period p ON p.id = pt.period_id
WHERE pt.fiscal_year_id = ?
${hideLockedClients ? hiddenClientsCondition : ''}
Expand Down

0 comments on commit 5138e21

Please sign in to comment.