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 BaseFinancialReportController from '../BaseFinancialReportController';
import { AbilitySubject, ReportsAction } from '@/interfaces'; import { AbilitySubject, ReportsAction } from '@/interfaces';
import CheckPolicies from '@/api/middleware/CheckPolicies'; import CheckPolicies from '@/api/middleware/CheckPolicies';
import HasTenancyService from '@/services/Tenancy/TenancyService';
import { SalesTaxLiabilitySummaryService } from '@/services/FinancialStatements/SalesTaxLiabilitySummary/SalesTaxLiabilitySummaryService'; import { SalesTaxLiabilitySummaryService } from '@/services/FinancialStatements/SalesTaxLiabilitySummary/SalesTaxLiabilitySummaryService';
export default class SalesTaxLiabilitySummary extends BaseFinancialReportController { export default class SalesTaxLiabilitySummary extends BaseFinancialReportController {
@Inject()
private tenancy: HasTenancyService;
@Inject() @Inject()
private salesTaxLiabilitySummaryService: SalesTaxLiabilitySummaryService; private salesTaxLiabilitySummaryService: SalesTaxLiabilitySummaryService;

View File

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

View File

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

View File

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