feat(server): styling financial reports pdf

This commit is contained in:
Ahmed Bouhuolia
2024-02-19 21:41:15 +02:00
parent 3509026ad8
commit c06a8d9ca3
33 changed files with 210 additions and 56 deletions

View File

@@ -1,41 +1,57 @@
@import "../base.scss";
.sheet{}
html,
body {
font-size: 14px;
}
body{
font-weight: 400;
letter-spacing: 0;
line-height: 1.28581;
text-transform: none;
color: #000;
font-family: Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Open Sans, Helvetica Neue, Icons16, sans-serif;
}
.sheet{
padding: 20px;
}
.sheet__company-name{
margin: 0;
font-size: 1.6rem;
font-size: 1.4rem;
}
.sheet__sheet-type {
margin: 0
}
.sheet__sheet-date {
margin-top: 0.5rem;
margin-top: 0.35rem;
}
.sheet__header {
text-align: center;
margin-bottom: 2rem;
text-align: center;
margin-bottom: 1rem;
}
.sheet__table {
border-top: 1px solid #000;
table-layout: fixed;
border-spacing: 0;
text-align: left;
border-spacing: 0;
text-align: left;
font-size: inherit;
width: 100%;
}
.sheet__table thead th {
color: #000;
border-bottom: 1px solid #000000;
padding: 0.5rem;
color: #000;
border-bottom: 1px solid #000000;
padding: 0.5rem;
}
.sheet__table tbody td {
border-bottom: 0;
padding-top: 0.32rem;
padding-bottom: 0.32rem;
padding-top: 0.28rem;
padding-bottom: 0.28rem;
padding-left: 0.5rem;
padding-right: 0.5rem;
color: #252A31;
border-bottom: 1px solid rgb(37, 42, 49);
border-bottom: 1px solid transparent;
}

View File

@@ -1,6 +1,9 @@
block head
style
//- include ../../css/modules/financial-sheet.css
include ../../css/modules/financial-sheet.css
style.
#{customCSS}
block content
.sheet
@@ -13,9 +16,9 @@ block content
thead
tr
each column in table.columns
th= column.label
th(style=column.style)= column.label
tbody
each row in table.rows
tr
tr(class=row.classNames)
each cell in row.cells
td!= cell.value

View File

@@ -66,12 +66,10 @@ module.exports = {
// sourcemaps: true, // Allow to enable/disable sourcemaps or pass object to configure it.
// minify: true, // Allow to enable/disable minify the source.
},
// {
// src: './assets/sass/editor-style.scss',
// dest: './assets/css',
// sourcemaps: true,
// minify: true,
// },
{
src: `${RESOURCES_PATH}/scss/modules/financial-sheet.scss`,
dest: `${RESOURCES_PATH}/css/modules`,
},
],
// RTL builds.
rtl: [
@@ -114,7 +112,7 @@ module.exports = {
// SASS Configuration for all builds.
sass: {
errLogToConsole: true,
// outputStyle: 'compact',
// outputStyle: 'compact',
},
// CSS MQ Packer configuration for all builds and style tasks.

View File

@@ -2,6 +2,7 @@ import { Inject, Service } from 'typedi';
import { IAPAgingSummaryQuery } from '@/interfaces';
import { TableSheetPdf } from '../TableSheetPdf';
import { APAgingSummaryTableInjectable } from './APAgingSummaryTableInjectable';
import { HtmlTableCss } from './_constants';
@Service()
export class APAgingSummaryPdfInjectable {
@@ -27,7 +28,8 @@ export class APAgingSummaryPdfInjectable {
tenantId,
table.table,
table.meta.sheetName,
table.meta.formattedAsDate
table.meta.formattedAsDate,
HtmlTableCss
);
}
}

View File

@@ -2,6 +2,7 @@ import { Inject, Service } from 'typedi';
import { IARAgingSummaryQuery } from '@/interfaces';
import { TableSheetPdf } from '../TableSheetPdf';
import { ARAgingSummaryTableInjectable } from './ARAgingSummaryTableInjectable';
import { HtmlTableCss } from './_constants';
@Service()
export class ARAgingSummaryPdfInjectable {
@@ -27,7 +28,8 @@ export class ARAgingSummaryPdfInjectable {
tenantId,
table.table,
table.meta.sheetName,
table.meta.formattedDateRange
table.meta.formattedDateRange,
HtmlTableCss
);
}
}

View File

@@ -2,3 +2,11 @@ export enum AgingSummaryRowType {
Contact = 'contact',
Total = 'total',
}
export const HtmlTableCss = `
table tr.row-type--total td{
font-weight: 500;
border-top: 1px solid #bbb;
border-bottom: 3px double #333;
}
`;

View File

@@ -2,6 +2,7 @@ import { Inject, Service } from 'typedi';
import { IBalanceSheetQuery } from '@/interfaces';
import { BalanceSheetTableInjectable } from './BalanceSheetTableInjectable';
import { TableSheetPdf } from '../TableSheetPdf';
import { HtmlTableCustomCss } from './constants';
@Service()
export class BalanceSheetPdfInjectable {
@@ -27,7 +28,8 @@ export class BalanceSheetPdfInjectable {
tenantId,
table.table,
table.meta.sheetName,
table.meta.formattedDateRange
table.meta.formattedDateRange,
HtmlTableCustomCss
);
}
}

View File

@@ -12,3 +12,15 @@ export enum IROW_TYPE {
NET_INCOME = 'NET_INCOME',
TOTAL = 'TOTAL',
}
export const HtmlTableCustomCss = `
table tr.row-type--total td {
font-weight: 600;
border-top: 1px solid #bbb;
color: #000;
}
table tr.row-type--total.row-id--assets td,
table tr.row-type--total.row-id--liability-equity td {
border-bottom: 3px double #000;
}
`;

View File

@@ -2,6 +2,7 @@ import { Inject } from 'typedi';
import { CashflowTableInjectable } from './CashflowTableInjectable';
import { TableSheetPdf } from '../TableSheetPdf';
import { ICashFlowStatementQuery } from '@/interfaces';
import { HtmlTableCustomCss } from './constants';
export class CashflowTablePdfInjectable {
@Inject()
@@ -21,13 +22,13 @@ export class CashflowTablePdfInjectable {
query: ICashFlowStatementQuery
): Promise<Buffer> {
const table = await this.cashflowTable.table(tenantId, query);
const sheetName = 'Cashflow Sheet';
return this.tableSheetPdf.convertToPdf(
tenantId,
table.table,
sheetName,
table.meta.formattedDateRange
table.meta.sheetName,
table.meta.formattedDateRange,
HtmlTableCustomCss
);
}
}

View File

@@ -1,8 +1,22 @@
export const DISPLAY_COLUMNS_BY = {
DATE_PERIODS: 'date_periods',
TOTAL: 'total',
};
export const MAP_CONFIG = { childrenPath: 'children', pathFormat: 'array' };
export const MAP_CONFIG = { childrenPath: 'children', pathFormat: 'array' };
export const HtmlTableCustomCss = `
table tr.row-type--accounts td {
border-top: 1px solid #bbb;
}
table tr.row-id--cash-end-period {
border-bottom: 3px double #333;
}
table tr.row-type--total {
font-weight: 600;
}
table tr.row-type--total td {
color: #000;
}
table tr.row-type--total:not(:first-child) td {
border-top: 1px solid #bbb;
}`;

View File

@@ -3,6 +3,7 @@ import { ICustomerBalanceSummaryQuery } from '@/interfaces';
import { TableSheetPdf } from '../TableSheetPdf';
import { CustomerBalanceSummaryTableInjectable } from './CustomerBalanceSummaryTableInjectable';
import { HtmlTableCustomCss } from './constants';
@Service()
export class CustomerBalanceSummaryPdf {
@@ -28,7 +29,8 @@ export class CustomerBalanceSummaryPdf {
tenantId,
table.table,
table.meta.sheetName,
table.meta.formattedDateRange
table.meta.formattedDateRange,
HtmlTableCustomCss
);
}
}

View File

@@ -0,0 +1,6 @@
export const HtmlTableCustomCss = `
table tr.row-type--total td {
font-weight: 600;
border-top: 1px solid #bbb;
border-bottom: 3px double #333;
}`;

View File

@@ -2,6 +2,7 @@ import { Inject, Service } from 'typedi';
import { TableSheetPdf } from '../TableSheetPdf';
import { GeneralLedgerTableInjectable } from './GeneralLedgerTableInjectable';
import { IGeneralLedgerSheetQuery } from '@/interfaces';
import { HtmlTableCustomCss } from './constants';
@Service()
export class GeneralLedgerPdf {
@@ -27,7 +28,8 @@ export class GeneralLedgerPdf {
tenantId,
table.table,
table.meta.sheetName,
table.meta.formattedDateRange
table.meta.formattedDateRange,
HtmlTableCustomCss
);
}
}

View File

@@ -0,0 +1,13 @@
export const HtmlTableCustomCss = `
table tr:last-child td {
border-bottom: 1px solid #ececec;
}
table tr.row-type--account td,
table tr.row-type--opening-balance td,
table tr.row-type--closing-balance td{
font-weight: 600;
}
table tr.row-type--closing-balance td {
border-bottom: 1px solid #ececec;
}
`;

View File

@@ -2,6 +2,7 @@ import { Inject, Service } from 'typedi';
import { InventoryDetailsTableInjectable } from './InventoryDetailsTableInjectable';
import { TableSheetPdf } from '../TableSheetPdf';
import { IInventoryDetailsQuery } from '@/interfaces';
import { HtmlTableCustomCss } from './constant';
@Service()
export class InventoryDetailsTablePdf {
@@ -27,7 +28,8 @@ export class InventoryDetailsTablePdf {
tenantId,
table.table,
table.meta.sheetName,
table.meta.formattedDateRange
table.meta.formattedDateRange,
HtmlTableCustomCss
);
}
}

View File

@@ -0,0 +1,7 @@
export const HtmlTableCustomCss = `
table tr.row-type--item td,
table tr.row-type--opening-entry td,
table tr.row-type--closing-entry td{
font-weight: 500;
}
`;

View File

@@ -2,6 +2,7 @@ import { Inject, Service } from "typedi";
import { InventoryValuationSheetTableInjectable } from "./InventoryValuationSheetTableInjectable";
import { TableSheetPdf } from "../TableSheetPdf";
import { IInventoryValuationReportQuery } from "@/interfaces";
import { HtmlTableCustomCss } from "./_constants";
@Service()
@@ -28,7 +29,8 @@ export class InventoryValuationSheetPdf {
tenantId,
table.table,
table.meta.sheetName,
table.meta.formattedDateRange
table.meta.formattedDateRange,
HtmlTableCustomCss
);
}
}

View File

@@ -2,3 +2,11 @@ export enum ROW_TYPE {
ITEM = 'ITEM',
TOTAL = 'TOTAL',
}
export const HtmlTableCustomCss = `
table tr.row-type--total td {
border-top: 1px solid #bbb;
font-weight: 600;
border-bottom: 3px double #000;
}
`;

View File

@@ -2,6 +2,7 @@ import { IJournalReportQuery } from '@/interfaces';
import { TableSheetPdf } from '../TableSheetPdf';
import { JournalSheetTableInjectable } from './JournalSheetTableInjectable';
import { Inject, Service } from 'typedi';
import { HtmlTableCustomCss } from './constant';
@Service()
export class JournalSheetPdfInjectable {
@@ -27,7 +28,8 @@ export class JournalSheetPdfInjectable {
tenantId,
table.table,
table.meta.sheetName,
table.meta.formattedDateRange
table.meta.formattedDateRange,
HtmlTableCustomCss
);
}
}

View File

@@ -0,0 +1,10 @@
export const HtmlTableCustomCss = `
table tr.row-type--total td{
font-weight: 600;
}
table tr td:not(:first-child) {
border-left: 1px solid #ececec;
}
table tr:last-child td {
border-bottom: 1px solid #ececec;
}`;

View File

@@ -2,6 +2,7 @@ import { Inject, Service } from 'typedi';
import { IProfitLossSheetQuery } from '@/interfaces';
import { ProfitLossSheetTableInjectable } from './ProfitLossSheetTableInjectable';
import { TableSheetPdf } from '../TableSheetPdf';
import { HtmlTableCustomCss } from './constants';
@Service()
export class ProfitLossTablePdfInjectable {
@@ -27,7 +28,8 @@ export class ProfitLossTablePdfInjectable {
tenantId,
table.table,
table.meta.sheetName,
table.meta.formattedDateRange
table.meta.formattedDateRange,
HtmlTableCustomCss
);
}
}

View File

@@ -18,4 +18,12 @@ export const TOTAL_NODE_TYPES = [
ProfitLossNodeType.ACCOUNTS,
ProfitLossNodeType.AGGREGATE,
ProfitLossNodeType.EQUATION
];
];
export const HtmlTableCustomCss =`
table tr.row-type--total td {
font-weight: 600;
border-top: 1px solid #bbb;
color: #000;
}
`;

View File

@@ -2,6 +2,7 @@ import { Inject, Service } from 'typedi';
import { TableSheetPdf } from '../TableSheetPdf';
import { PurchasesByItemsTableInjectable } from './PurchasesByItemsTableInjectable';
import { IPurchasesByItemsReportQuery } from '@/interfaces/PurchasesByItemsSheet';
import { HtmlTableCustomCss } from './_types';
@Service()
export class PurchasesByItemsPdf {
@@ -27,7 +28,8 @@ export class PurchasesByItemsPdf {
tenantId,
table.table,
table.meta.sheetName,
table.meta.formattedDateRange
table.meta.formattedDateRange,
HtmlTableCustomCss
);
}
}

View File

@@ -2,4 +2,12 @@
export enum ROW_TYPE {
TOTAL = 'TOTAL',
ITEM = 'ITEM'
}
}
export const HtmlTableCustomCss = `
table tr.row-type--total td {
border-top: 1px solid #bbb;
border-bottom: 3px double #000;
font-weight: 600;
}
`;

View File

@@ -2,6 +2,7 @@ import { Inject, Service } from 'typedi';
import { ISalesByItemsReportQuery } from '@/interfaces';
import { SalesByItemsTableInjectable } from './SalesByItemsTableInjectable';
import { TableSheetPdf } from '../TableSheetPdf';
import { HtmlTableCustomCss } from './constants';
@Service()
export class SalesByItemsPdfInjectable {
@@ -27,7 +28,8 @@ export class SalesByItemsPdfInjectable {
tenantId,
table.table,
table.meta.sheetName,
table.meta.formattedDateRange
table.meta.formattedDateRange,
HtmlTableCustomCss
);
}
}

View File

@@ -1,6 +1,12 @@
export enum ROW_TYPE {
ITEM = 'ITEM',
TOTAL = 'TOTAL',
}
}
export const HtmlTableCustomCss = `
table tr.row-type--total td {
border-top: 1px solid #bbb;
border-bottom: 3px double #000;
font-weight: 600;
}
`;

View File

@@ -2,6 +2,7 @@ import { Inject, Service } from 'typedi';
import { ITrialBalanceSheetQuery } from '@/interfaces';
import { TableSheetPdf } from '../TableSheetPdf';
import { TrialBalanceSheetTableInjectable } from './TrialBalanceSheetTableInjectable';
import { HtmlTableCustomCss } from './_constants';
@Service()
export class TrialBalanceSheetPdfInjectable {
@@ -27,7 +28,8 @@ export class TrialBalanceSheetPdfInjectable {
tenantId,
table.table,
table.meta.sheetName,
table.meta.formattedDateRange
table.meta.formattedDateRange,
HtmlTableCustomCss
);
}
}

View File

@@ -2,7 +2,6 @@ import * as R from 'ramda';
import FinancialSheet from '../FinancialSheet';
import { FinancialTable } from '../FinancialTable';
import {
IBalanceSheetStatementData,
ITableColumn,
ITableColumnAccessor,
ITableRow,

View File

@@ -1,5 +1,12 @@
export enum IROW_TYPE {
ACCOUNT = 'ACCOUNT',
TOTAL = 'TOTAL',
}
}
export const HtmlTableCustomCss = `
table tr.row-type--total td{
border-top: 1px solid #bbb;
font-weight: 500;
border-bottom: 3px double #000;
}
`;

View File

@@ -41,7 +41,7 @@ export class VendorBalanceSummaryReport extends ContactBalanceSummaryReport {
/**
* Customer section mapper.
* @param {IVendor} vendor
* @param {IVendor} vendor
* @returns {IVendorBalanceSummaryVendor}
*/
private vendorMapper = (vendor: IVendor): IVendorBalanceSummaryVendor => {
@@ -58,7 +58,7 @@ export class VendorBalanceSummaryReport extends ContactBalanceSummaryReport {
/**
* Mappes the vendor model object to vendor balance summary section.
* @param {IVendor[]} vendors - Customers.
* @param {IVendor[]} vendors - Customers.
* @returns {IVendorBalanceSummaryVendor[]}
*/
private vendorsMapper = (
@@ -77,7 +77,7 @@ export class VendorBalanceSummaryReport extends ContactBalanceSummaryReport {
/**
* Retrieve the vendors sections of the report.
* @param {IVendor} vendors
* @param {IVendor} vendors
* @returns {IVendorBalanceSummaryVendor[]}
*/
private getVendorsSection(vendors: IVendor[]): IVendorBalanceSummaryVendor[] {

View File

@@ -72,6 +72,5 @@ export class VendorBalanceSummaryApplication {
*/
public pdf(tenantId: number, query: IVendorBalanceSummaryQuery) {
return this.vendorBalanceSummaryPdf.pdf(tenantId, query);
}
}

View File

@@ -2,6 +2,7 @@ import { Inject, Service } from 'typedi';
import { IVendorBalanceSummaryQuery } from '@/interfaces';
import { TableSheetPdf } from '../TableSheetPdf';
import { VendorBalanceSummaryTableInjectable } from './VendorBalanceSummaryTableInjectable';
import { HtmlTableCustomCss } from './constants';
@Service()
export class VendorBalanceSummaryPdf {
@@ -22,13 +23,13 @@ export class VendorBalanceSummaryPdf {
query: IVendorBalanceSummaryQuery
): Promise<Buffer> {
const table = await this.vendorBalanceSummaryTable.table(tenantId, query);
return this.tableSheetPdf.convertToPdf(
tenantId,
table.table,
table.meta.sheetName,
table.meta.formattedAsDate
table.meta.formattedAsDate,
HtmlTableCustomCss
);
}
}

View File

@@ -0,0 +1,6 @@
export const HtmlTableCustomCss = `
table tr.row-type--total td {
font-weight: 600;
border-top: 1px solid #bbb;
border-bottom: 3px double #333;
}`;