print invoice field in order
deploy to danak / build_and_deploy (push) Has been cancelled

This commit is contained in:
2026-07-01 12:26:55 +03:30
parent 2a633a28b4
commit bd084e2e63
7 changed files with 45 additions and 2 deletions
@@ -1,5 +1,5 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsArray, IsNotEmpty, IsObject, IsOptional, IsString } from 'class-validator';
import { IsArray, IsBoolean, IsNotEmpty, IsObject, IsOptional, IsString } from 'class-validator';
import { SetCarDeliveryDto } from './set-car-delivery.dto';
@@ -33,6 +33,16 @@ export class SetAllCartParmsDto {
@IsString()
tableNumber?: string;
@ApiProperty({
description: 'Whether the customer wants a printed invoice',
required: false,
default: false,
example: false,
})
@IsOptional()
@IsBoolean()
printInvoice?: boolean;
@ApiProperty()
@IsOptional()
@IsObject()
@@ -19,6 +19,7 @@ export interface Cart {
paymentMethodId?: string;
deliveryMethodId?: string;
description?: string;
printInvoice?: boolean;
tableNumber?: string;
attachments?: string[];
paymentDesc?: string;
+5 -1
View File
@@ -28,7 +28,7 @@ export class CartService {
* Set all cart parameters at once
*/
async setAllCartParams(userId: string, restaurantId: string, params: SetAllCartParmsDto): Promise<Cart> {
const { deliveryMethodId, paymentMethodId, addressId, carAddress, description, tableNumber, attachments, paymentDesc } = params;
const { deliveryMethodId, paymentMethodId, addressId, carAddress, description, tableNumber, printInvoice, attachments, paymentDesc } = params;
// get existing cart (or throw)
const cart = await this.findOneOrFail(userId, restaurantId);
@@ -117,6 +117,10 @@ export class CartService {
cart.description = description;
}
if (printInvoice !== undefined) {
cart.printInvoice = printInvoice;
}
if (paymentMethod.method === PaymentMethodEnum.CreditCard) {
this.validationService.assertCreditCardPaymentDetails(paymentMethod, paymentDesc, attachments);
cart.paymentDesc = paymentDesc?.trim() || undefined;
@@ -92,6 +92,9 @@ export class Order extends BaseEntity {
@Property({ type: 'text', nullable: true })
description?: string;
@Property({ type: 'boolean', default: false })
printInvoice: boolean = false;
@Property({ nullable: true })
tableNumber?: string;
@@ -87,6 +87,7 @@ export class OrdersService {
total: cart.total || 0,
totalItems: cart.totalItems || 0,
description: cart.description,
printInvoice: cart.printInvoice ?? false,
tableNumber: cart.tableNumber,
status: OrderStatus.PENDING_PAYMENT,
history: [{ status: OrderStatus.PENDING_PAYMENT, changedAt: new Date() }],
@@ -199,6 +200,7 @@ export class OrdersService {
total,
totalItems,
description: dto.description,
printInvoice: false,
tableNumber: dto.tableNumber,
status: OrderStatus.PENDING_PAYMENT,
history: [{ status: OrderStatus.PENDING_PAYMENT, changedAt: new Date() }],