feat: wip sales tax summary report

This commit is contained in:
Ahmed Bouhuolia
2023-09-02 01:50:24 +02:00
parent eb03a38553
commit 801ea5dfdb
4 changed files with 29 additions and 15 deletions

View File

@@ -5,13 +5,9 @@ import asyncMiddleware from '@/api/middleware/asyncMiddleware';
import BaseFinancialReportController from '../BaseFinancialReportController';
import { AbilitySubject, ReportsAction } from '@/interfaces';
import CheckPolicies from '@/api/middleware/CheckPolicies';
import HasTenancyService from '@/services/Tenancy/TenancyService';
import { SalesTaxLiabilitySummaryService } from '@/services/FinancialStatements/SalesTaxLiabilitySummary/SalesTaxLiabilitySummaryService';
export default class SalesTaxLiabilitySummary extends BaseFinancialReportController {
@Inject()
private tenancy: HasTenancyService;
@Inject()
private salesTaxLiabilitySummaryService: SalesTaxLiabilitySummaryService;

View File

@@ -13,13 +13,15 @@ export interface SalesTaxLiabilitySummaryAmount {
export interface SalesTaxLiabilitySummaryTotal {
taxableAmount: SalesTaxLiabilitySummaryAmount;
taxAmount: SalesTaxLiabilitySummaryAmount;
collectedTaxAmount: SalesTaxLiabilitySummaryAmount;
}
export interface SalesTaxLiabilitySummaryRate {
taxName: string;
taxCode: string;
taxableAmount: SalesTaxLiabilitySummaryAmount;
taxAmount: SalesTaxLiabilitySummaryAmount;
taxPercentage: any;
collectedTaxAmount: SalesTaxLiabilitySummaryAmount;
}
export enum SalesTaxLiabilitySummaryTableRowType {

View File

@@ -53,11 +53,19 @@ export class SalesTaxLiabilitySummary extends FinancialSheet {
: 0;
const salesTaxAmount = salesTax ? salesTax.credit - salesTax.debit : 0;
// Calculates the tax percentage.
const taxPercentage = salesTaxAmount / payableTaxAmount;
const taxPercentageRate = taxPercentage / 100;
// Calculates the payable tax amount.
const collectedTaxAmount = payableTax ? payableTax.debit : 0;
return {
taxName: taxRate.name,
taxCode: taxRate.code,
taxName: `${taxRate.name} (${taxRate.rate}%)`,
taxableAmount: this.getAmountMeta(salesTaxAmount),
taxAmount: this.getAmountMeta(payableTaxAmount),
taxPercentage: this.getPercentageAmountMeta(taxPercentageRate),
collectedTaxAmount: this.getAmountMeta(collectedTaxAmount),
};
};
@@ -79,10 +87,12 @@ export class SalesTaxLiabilitySummary extends FinancialSheet {
): SalesTaxLiabilitySummaryTotal => {
const taxableAmount = sumBy(nodes, 'taxableAmount.amount');
const taxAmount = sumBy(nodes, 'taxAmount.amount');
const collectedTaxAmount = sumBy(nodes, 'collectedTaxAmount.amount');
return {
taxableAmount: this.getTotalAmountMeta(taxableAmount),
taxAmount: this.getTotalAmountMeta(taxAmount),
collectedTaxAmount: this.getTotalAmountMeta(collectedTaxAmount),
};
};

View File

@@ -44,9 +44,10 @@ export class SalesTaxLiabilitySummaryTable extends R.compose(
*/
private get taxRateRowAccessor() {
return [
{ key: 'taxName', value: 'taxName' },
{ key: 'taxCode', accessor: 'taxCode' },
{ key: 'taxName', accessor: 'taxName' },
{ key: 'taxPercentage', accessor: 'taxPercentage.formattedAmount' },
{ key: 'taxableAmount', accessor: 'taxableAmount.formattedAmount' },
{ key: 'collectedTax', accessor: 'collectedTaxAmount.formattedAmount' },
{ key: 'taxAmount', accessor: 'taxAmount.formattedAmount' },
];
}
@@ -57,9 +58,10 @@ export class SalesTaxLiabilitySummaryTable extends R.compose(
*/
private get taxRateTotalRowAccessors() {
return [
{ key: 'taxName', value: '' },
{ key: 'taxCode', accessor: 'taxCode' },
{ key: 'taxName', value: 'Total' },
{ key: 'taxPercentage', value: '' },
{ key: 'taxableAmount', accessor: 'taxableAmount.formattedAmount' },
{ key: 'collectedTax', accessor: 'collectedTaxAmount.formattedAmount' },
{ key: 'taxAmount', accessor: 'taxAmount.formattedAmount' },
];
}
@@ -122,7 +124,7 @@ export class SalesTaxLiabilitySummaryTable extends R.compose(
}
/**
* Retrieve the table rows.
* Retrieves the table rows.
* @returns {ITableRow[]}
*/
public tableRows(): ITableRow[] {
@@ -133,7 +135,7 @@ export class SalesTaxLiabilitySummaryTable extends R.compose(
}
/**
* Retrieve the table columns.
* Retrieves the table columns.
* @returns {ITableColumn[]}
*/
public tableColumns(): ITableColumn[] {
@@ -143,13 +145,17 @@ export class SalesTaxLiabilitySummaryTable extends R.compose(
key: 'taxName',
},
{
label: 'Tax Code',
key: 'taxCode',
label: 'Tax Percentage',
key: 'taxPercentage',
},
{
label: 'Taxable Amount',
key: 'taxableAmount',
},
{
label: 'Collected Tax',
key: 'collectedTax',
},
{
label: 'Tax Rate',
key: 'taxRate',