mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 19:58:11 +00:00
fix
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
BadRequestException,
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
@@ -93,7 +94,13 @@ export class FirstMileController {
|
||||
@ApiOperation({ summary: 'Generate the first-mile delivery-fee invoice' })
|
||||
async generateInvoice(@Param('id', ParseUUIDPipe) id: string) {
|
||||
const record = await this.firstMileService.findById(id);
|
||||
return this.firstMileInvoiceService.ensureInvoiceFor(record);
|
||||
const invoice = await this.firstMileInvoiceService.ensureInvoiceFor(record);
|
||||
if (!invoice) {
|
||||
throw new BadRequestException(
|
||||
'Cannot generate invoice: the leg has no billable amount. Add distance and ensure a FIRST_MILE rate is configured, and the booking has a company.',
|
||||
);
|
||||
}
|
||||
return invoice;
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
BadRequestException,
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
@@ -118,6 +119,12 @@ export class LastMileController {
|
||||
@ApiOperation({ summary: 'Generate the delivery-fee invoice for a last-mile leg' })
|
||||
async generateInvoice(@Param('id', ParseUUIDPipe) id: string) {
|
||||
const record = await this.lastMileService.findById(id);
|
||||
return this.lastMileInvoiceService.ensureInvoiceFor(record);
|
||||
const invoice = await this.lastMileInvoiceService.ensureInvoiceFor(record);
|
||||
if (!invoice) {
|
||||
throw new BadRequestException(
|
||||
'Cannot generate invoice: the leg has no billable amount. Add distance and ensure a LAST_MILE rate is configured, and the booking has a company.',
|
||||
);
|
||||
}
|
||||
return invoice;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user