bp - transfers - route - minor change
MODIFY
src/integration/billing/BillingIntegration.ts
src/integration/billing/BillingIntegration.ts
@@ -696,7 +696,7 @@ export default abstract class BillingIntegration {
public abstract downloadInvoiceDocument(invoice: BillingInvoice): Promise<Buffer>;
- public abstract downloadTransferDocument(transfer: BillingTransfer): Promise<Buffer>;
+ public abstract downloadTransferInvoiceDocument(transfer: BillingTransfer): Promise<Buffer>;
public abstract chargeInvoice(invoice: BillingInvoice): Promise<BillingInvoice>;

MODIFY
src/integration/billing/stripe/StripeBillingIntegration.ts
src/integration/billing/stripe/StripeBillingIntegration.ts
@@ -383,7 +383,7 @@ export default class StripeBillingIntegration extends BillingIntegration {
}
}
- public async downloadTransferDocument(transfer: BillingTransfer): Promise<Buffer> {
+ public async downloadTransferInvoiceDocument(transfer: BillingTransfer): Promise<Buffer> {
await this.checkConnection();
// Get fresh data because persisted url expires after 30 days
const stripeTransferInvoice = await this.getStripeInvoice(transfer.invoice.invoiceID);

MODIFY
src/server/rest/RestServerService.ts
src/server/rest/RestServerService.ts
@@ -148,7 +148,7 @@ class RequestMapper {
[ServerAction.BILLING_TAXES]: BillingService.handleGetBillingTaxes.bind(this),
[ServerAction.BILLING_INVOICES]: BillingService.handleGetInvoices.bind(this),
[ServerAction.BILLING_DOWNLOAD_INVOICE]: BillingService.handleDownloadInvoice.bind(this),
- [ServerAction.BILLING_DOWNLOAD_TRANSFER]: BillingService.handleDownloadTransfer.bind(this),
+ [ServerAction.BILLING_DOWNLOAD_TRANSFER]: BillingService.handleTransferInvoiceDownload.bind(this),
[ServerAction.BILLING_PAYMENT_METHODS]: BillingService.handleBillingGetPaymentMethods.bind(this),
[ServerAction.OCPI_ENDPOINTS]: OCPIEndpointService.handleGetOcpiEndpoints.bind(this),
[ServerAction.OCPI_ENDPOINT]: OCPIEndpointService.handleGetOcpiEndpoint.bind(this),

MODIFY
src/server/rest/v1/router/api/BillingRouter.ts
src/server/rest/v1/router/api/BillingRouter.ts
@@ -146,9 +146,9 @@ export default class BillingRouter {
}
private buildRouteBillingTransferDownload(): void {
- this.router.get(`/${RESTServerRoute.REST_BILLING_DOWNLOAD_TRANSFER}`, (req: Request, res: Response, next: NextFunction) => {
- req.query.ID = req.params.transferID;
- void RouterUtils.handleRestServerAction(BillingService.handleDownloadTransfer.bind(this), ServerAction.BILLING_DOWNLOAD_TRANSFER, req, res, next);
+ this.router.get(`/${RESTServerRoute.REST_BILLING_TRANSFER_DOWNLOAD_INVOICE}`, (req: Request, res: Response, next: NextFunction) => {
+ req.query.ID = req.params.id;
+ void RouterUtils.handleRestServerAction(BillingService.handleTransferInvoiceDownload.bind(this), ServerAction.BILLING_DOWNLOAD_TRANSFER, req, res, next);
});
}

MODIFY
src/server/rest/v1/service/BillingService.ts
src/server/rest/v1/service/BillingService.ts
@@ -389,16 +389,16 @@ export default class BillingService {
res.end(buffer, 'binary');
}
- public static async handleDownloadTransfer(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
+ public static async handleTransferInvoiceDownload(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Check if component is active
UtilsService.assertComponentIsActiveFromToken(req.user, TenantComponents.BILLING_PLATFORM,
- Action.DOWNLOAD, Entity.BILLING_PLATFORM, MODULE_NAME, 'handleDownloadTransfer');
+ Action.DOWNLOAD, Entity.BILLING_PLATFORM, MODULE_NAME, 'handleTransferInvoiceDownload');
// Filter
const filteredRequest = BillingValidatorRest.getInstance().validateBillingTransferGetReq(req.query);
// Get the Invoice
const billingTransfer = await BillingStorage.getTransfer(req.tenant, filteredRequest.ID);
UtilsService.assertObjectExists(action, billingTransfer, `Transfer ID '${filteredRequest.ID}' does not exist`,
- MODULE_NAME, 'handleDownloadTransfer', req.user);
+ MODULE_NAME, 'handleTransferInvoiceDownload', req.user);
// Check and get authorizations
await UtilsService.checkAndGetTransferAuthorization(req.tenant, req.user, filteredRequest.ID, Action.DOWNLOAD, action, null, {}, true);
// Get the billing impl
@@ -407,17 +407,17 @@ export default class BillingService {
throw new AppError({
errorCode: HTTPError.GENERAL_ERROR,
message: 'Billing service is not configured',
- module: MODULE_NAME, method: 'handleDownloadTransfer',
+ module: MODULE_NAME, method: 'handleTransferInvoiceDownload',
action: action,
user: req.user
});
}
- const buffer = await billingImpl.downloadTransferDocument(billingTransfer);
+ const buffer = await billingImpl.downloadTransferInvoiceDocument(billingTransfer);
if (!billingTransfer.invoice.invoiceID || !buffer) {
throw new AppError({
errorCode: HTTPError.GENERAL_ERROR,
message: 'Transfer document not found',
- module: MODULE_NAME, method: 'handleDownloadTransfer',
+ module: MODULE_NAME, method: 'handleTransferInvoiceDownload',
action: action,
user: req.user
});

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -722,7 +722,7 @@ export enum RESTServerRoute {
REST_BILLING_TRANSFER = 'billing/transfers/:id',
REST_BILLING_TRANSFER_FINALIZE = 'billing/transfers/:id/finalize',
REST_BILLING_TRANSFER_SEND = 'billing/transfers/:id/send',
- REST_BILLING_DOWNLOAD_TRANSFER = 'tranfers/:transferID/download',
+ REST_BILLING_TRANSFER_DOWNLOAD_INVOICE = 'billing/transfers/:id/invoice/download',
// PRICING URLs for CRUD operations
REST_PRICING_DEFINITIONS = 'pricing-definitions',

bp - transfers - route - minor change