get taxes - authorization
MODIFY
src/server/rest/v1/service/AuthorizationService.ts
src/server/rest/v1/service/AuthorizationService.ts
import { Action, AuthorizationActions, AuthorizationContext, AuthorizationFilter, Entity } from '../../../../types/Authorization';
-import { AssetDataResult, BillingInvoiceDataResult, BillingPaymentMethodDataResult, BillingSubaccountsDataResult, BillingTransfersDataResult, CarCatalogDataResult, CarDataResult, ChargingProfileDataResult, ChargingStationDataResult, CompanyDataResult, DataResult, LogDataResult, PricingDefinitionDataResult, RegistrationTokenDataResult, SiteAreaDataResult, SiteDataResult, TagDataResult, UserDataResult } from '../../../../types/DataResult';
-import { BillingAccount, BillingInvoice, BillingPaymentMethod } from '../../../../types/Billing';
+import { AssetDataResult, BillingInvoiceDataResult, BillingPaymentMethodDataResult, BillingSubaccountsDataResult, BillingTaxDataResult, BillingTransfersDataResult, CarCatalogDataResult, CarDataResult, ChargingProfileDataResult, ChargingStationDataResult, CompanyDataResult, DataResult, LogDataResult, PricingDefinitionDataResult, RegistrationTokenDataResult, SiteAreaDataResult, SiteDataResult, TagDataResult, UserDataResult } from '../../../../types/DataResult';
+import { BillingAccount, BillingInvoice, BillingPaymentMethod, BillingTax } from '../../../../types/Billing';
import { Car, CarCatalog } from '../../../../types/Car';
import { ChargePointStatus, OCPPProtocol, OCPPVersion } from '../../../../types/ocpp/OCPPServer';
import { HttpAssetGetRequest, HttpAssetsGetRequest } from '../../../../types/requests/HttpAssetRequest';
@@ -859,6 +859,22 @@ export default class AuthorizationService {
tenant, Entity.INVOICE, userToken, filteredRequest, filteredRequest.ID ? { invoiceID: filteredRequest.ID } : {}, authAction, entityData);
}
+ public static addTaxesAuthorizations(tenant: Tenant, userToken: UserToken, billingTaxes: BillingTaxDataResult,
+ authorizationFilter: AuthorizationFilter): void {
+ // Add Meta Data
+ billingTaxes.metadata = authorizationFilter.metadata;
+ for (const billingTax of billingTaxes.result) {
+ AuthorizationService.addTaxAuthorizations(tenant, userToken, billingTax, authorizationFilter);
+ }
+ }
+
+
+ public static addTaxAuthorizations(tenant: Tenant, userToken: UserToken, billingTax: BillingTax, authorizationFilter: AuthorizationFilter): void {
+ billingTax.canRead = true; // Always true as it should be filtered upfront
+ // Optimize data over the net
+ Utils.removeCanPropertiesWithFalseValue(billingTax);
+ }
+
public static async addInvoicesAuthorizations(tenant: Tenant, userToken: UserToken, billingInvoices: BillingInvoiceDataResult,
authorizationFilter: AuthorizationFilter): Promise<void> {
// Add Meta Data

MODIFY
src/server/rest/v1/service/BillingService.ts
src/server/rest/v1/service/BillingService.ts
@@ -179,8 +179,7 @@ export default class BillingService {
count: taxes.length,
result: taxes,
};
- // We do not have a tax collection on our side - the data comes from the connected account (STRIPE)
- // await AuthorizationService.addTaxesAuthorizations(req.tenant, req.user, dataResult, authorizations, filteredRequest);
+ AuthorizationService.addTaxesAuthorizations(req.tenant, req.user, dataResult, authorizations);
res.json(dataResult);
next();
}

MODIFY
src/types/Authorization.ts
src/types/Authorization.ts
@@ -240,6 +240,8 @@ export interface SiteAuthorizationActions extends AuthorizationActions {
canMaintainPricingDefinitions?: boolean;
}
+export type BillingTaxAuthorizationActions = AuthorizationActions;
+
export interface BillingInvoiceAuthorizationActions extends AuthorizationActions {
canDownload?: boolean;
}

MODIFY
src/types/Billing.ts
src/types/Billing.ts
-import { AuthorizationActions, BillingInvoiceAuthorizationActions, BillingTransferAuthorizationActions } from './Authorization';
+import { AuthorizationActions, BillingInvoiceAuthorizationActions, BillingTaxAuthorizationActions, BillingTransferAuthorizationActions } from './Authorization';
import { ActionsResponse } from './GlobalType';
import CreatedUpdatedProps from './CreatedUpdatedProps';
@@ -57,7 +57,7 @@ export interface BillingChargeInvoiceAction extends ActionsResponse {
billingData?: BillingUserData;
}
-export interface BillingTax {
+export interface BillingTax extends BillingTaxAuthorizationActions {
id: string;
description: string;
displayName: string;

MODIFY
src/types/GlobalType.ts
src/types/GlobalType.ts
-import { BillingAccount, BillingInvoice, BillingPaymentMethod } from './Billing';
+import { BillingAccount, BillingInvoice, BillingPaymentMethod, BillingTax } from './Billing';
import { Car, CarCatalog } from './Car';
import ChargingStation, { Connector } from './ChargingStation';
@@ -85,7 +85,7 @@ export enum ImportStatus {
ERROR = 'E',
}
-export type EntityData = Car|User|Company|Site|SiteArea|Tag|CarCatalog|ChargingStation|PricingDefinition|Log|RegistrationToken|BillingInvoice|BillingPaymentMethod|Setting|BillingAccount|ChargingProfile|Connector;
+export type EntityData = Car|User|Company|Site|SiteArea|Tag|CarCatalog|ChargingStation|PricingDefinition|Log|RegistrationToken|BillingInvoice|BillingPaymentMethod|BillingTax|Setting|BillingAccount|ChargingProfile|Connector;
interface TSGlobal extends Global {
database: MongoDBStorage;

get taxes - authorization