diff --git a/packages/server/src/modules/Accounts/Accounts.controller.ts b/packages/server/src/modules/Accounts/Accounts.controller.ts index 8cb887027..0e000a5ca 100644 --- a/packages/server/src/modules/Accounts/Accounts.controller.ts +++ b/packages/server/src/modules/Accounts/Accounts.controller.ts @@ -117,7 +117,10 @@ export class AccountsController { status: 200, description: 'The account types have been successfully retrieved.', schema: { - $ref: getSchemaPath(AccountTypeResponseDto), + type: 'array', + items: { + $ref: getSchemaPath(AccountTypeResponseDto), + }, }, }) async getAccountTypes() { diff --git a/packages/server/src/modules/BillPayments/BillPayments.controller.ts b/packages/server/src/modules/BillPayments/BillPayments.controller.ts index 1ec750cd3..686fb6aa4 100644 --- a/packages/server/src/modules/BillPayments/BillPayments.controller.ts +++ b/packages/server/src/modules/BillPayments/BillPayments.controller.ts @@ -9,16 +9,27 @@ import { Query, } from '@nestjs/common'; import { BillPaymentsApplication } from './BillPaymentsApplication.service'; -import { ApiOperation, ApiParam, ApiTags } from '@nestjs/swagger'; +import { + ApiExtraModels, + ApiOperation, + ApiParam, + ApiResponse, + ApiTags, + getSchemaPath, +} from '@nestjs/swagger'; import { CreateBillPaymentDto, EditBillPaymentDto, } from './dtos/BillPayment.dto'; import { GetBillPaymentsFilterDto } from './dtos/GetBillPaymentsFilter.dto'; import { BillPaymentsPages } from './commands/BillPaymentsPages.service'; +import { BillPaymentResponseDto } from './dtos/BillPaymentResponse.dto'; +import { PaginatedResponseDto } from '@/common/dtos/PaginatedResults.dto'; @Controller('bill-payments') @ApiTags('Bill Payments') +@ApiExtraModels(BillPaymentResponseDto) +@ApiExtraModels(PaginatedResponseDto) export class BillPaymentsController { constructor( private billPaymentsApplication: BillPaymentsApplication, @@ -114,6 +125,13 @@ export class BillPaymentsController { @Get(':billPaymentId') @ApiOperation({ summary: 'Retrieves the bill payment details.' }) + @ApiResponse({ + status: 200, + description: 'The bill payment details have been successfully retrieved.', + schema: { + $ref: getSchemaPath(BillPaymentResponseDto), + }, + }) @ApiParam({ name: 'billPaymentId', required: true, @@ -126,6 +144,23 @@ export class BillPaymentsController { @Get() @ApiOperation({ summary: 'Retrieves the bill payments list.' }) + @ApiResponse({ + status: 200, + description: 'The bill payments have been successfully retrieved.', + schema: { + allOf: [ + { $ref: getSchemaPath(PaginatedResponseDto) }, + { + properties: { + data: { + type: 'array', + items: { $ref: getSchemaPath(BillPaymentResponseDto) }, + }, + }, + }, + ], + }, + }) @ApiParam({ name: 'filterDTO', required: true, diff --git a/packages/server/src/modules/BillPayments/dtos/BillPaymentResponse.dto.ts b/packages/server/src/modules/BillPayments/dtos/BillPaymentResponse.dto.ts new file mode 100644 index 000000000..ceece7bc8 --- /dev/null +++ b/packages/server/src/modules/BillPayments/dtos/BillPaymentResponse.dto.ts @@ -0,0 +1,140 @@ +import { ApiProperty } from '@nestjs/swagger'; +import { Type } from 'class-transformer'; +import { AttachmentLinkDto } from '@/modules/Attachments/dtos/Attachment.dto'; + +// Minimal Bill response for entry +class BillResponseDto { + @ApiProperty({ description: 'The bill ID', example: 1 }) + id: number; + + @ApiProperty({ description: 'The bill number', example: 'BILL-001' }) + billNo: string; + + @ApiProperty({ + description: 'The formatted bill date', + example: '2024-01-01', + }) + formattedBillDate: string; + + @ApiProperty({ description: 'The formatted due date', example: '2024-01-15' }) + formattedDueDate: string; + + @ApiProperty({ + description: 'The formatted total amount', + example: '1,000.00 USD', + }) + totalFormatted: string; +} + +export class BillPaymentEntryResponseDto { + @ApiProperty({ + description: 'The payment amount formatted', + example: '100.00', + }) + paymentAmountFormatted: string; + + @ApiProperty({ description: 'The bill details', type: BillResponseDto }) + @Type(() => BillResponseDto) + bill: BillResponseDto; +} + +export class BillPaymentResponseDto { + @ApiProperty({ + description: 'The unique identifier of the bill payment', + example: 1, + }) + id: number; + + @ApiProperty({ description: 'The vendor ID', example: 1 }) + vendorId: number; + + @ApiProperty({ description: 'The amount paid', example: 100 }) + amount: number; + + @ApiProperty({ + description: 'The currency code', + example: 'USD', + required: false, + }) + currencyCode?: string; + + @ApiProperty({ description: 'The payment account ID', example: 2 }) + paymentAccountId: number; + + @ApiProperty({ + description: 'The payment number', + example: 'PAY-2024-001', + required: false, + }) + paymentNumber?: string; + + @ApiProperty({ description: 'The payment date', example: '2024-01-01' }) + paymentDate: string; + + @ApiProperty({ + description: 'The formatted payment date', + example: '2024-01-01', + }) + formattedPaymentDate: string; + + @ApiProperty({ + description: 'The exchange rate', + example: 1, + required: false, + }) + exchangeRate?: number; + + @ApiProperty({ + description: 'Statement or note', + example: 'Payment for January bills', + required: false, + }) + statement?: string; + + @ApiProperty({ + description: 'Reference number', + example: 'REF-123', + required: false, + }) + reference?: string; + + @ApiProperty({ description: 'The branch ID', example: 1, required: false }) + branchId?: number; + + @ApiProperty({ description: 'The formatted amount', example: '100.00 USD' }) + formattedAmount: string; + + @ApiProperty({ + description: 'The date when the payment was created', + example: '2024-01-01T12:00:00Z', + }) + createdAt: Date; + + @ApiProperty({ + description: 'The formatted created at date', + example: '2024-01-01', + }) + formattedCreatedAt: string; + + @ApiProperty({ + description: 'The date when the payment was last updated', + example: '2024-01-02T12:00:00Z', + required: false, + }) + updatedAt?: Date; + + @ApiProperty({ + description: 'The entries of the bill payment', + type: [BillPaymentEntryResponseDto], + }) + @Type(() => BillPaymentEntryResponseDto) + entries: BillPaymentEntryResponseDto[]; + + @ApiProperty({ + description: 'The attachments of the bill payment', + type: [AttachmentLinkDto], + required: false, + }) + @Type(() => AttachmentLinkDto) + attachments?: AttachmentLinkDto[]; +} diff --git a/packages/server/src/modules/Bills/Bills.controller.ts b/packages/server/src/modules/Bills/Bills.controller.ts index 573fa2ac7..29d3d2869 100644 --- a/packages/server/src/modules/Bills/Bills.controller.ts +++ b/packages/server/src/modules/Bills/Bills.controller.ts @@ -1,4 +1,11 @@ -import { ApiOperation, ApiParam, ApiTags } from '@nestjs/swagger'; +import { + ApiExtraModels, + ApiOperation, + ApiParam, + ApiResponse, + ApiTags, + getSchemaPath, +} from '@nestjs/swagger'; import { Controller, Post, @@ -12,9 +19,13 @@ import { import { BillsApplication } from './Bills.application'; import { IBillsFilter } from './Bills.types'; import { CreateBillDto, EditBillDto } from './dtos/Bill.dto'; +import { BillResponseDto } from './dtos/BillResponse.dto'; +import { PaginatedResponseDto } from '@/common/dtos/PaginatedResults.dto'; @Controller('bills') @ApiTags('Bills') +@ApiExtraModels(BillResponseDto) +@ApiExtraModels(PaginatedResponseDto) export class BillsController { constructor(private billsApplication: BillsApplication) {} @@ -50,6 +61,23 @@ export class BillsController { @Get() @ApiOperation({ summary: 'Retrieves the bills.' }) + @ApiResponse({ + status: 200, + description: 'The bill details has been retrieved successfully', + schema: { + allOf: [ + { $ref: getSchemaPath(PaginatedResponseDto) }, + { + properties: { + data: { + type: 'array', + items: { $ref: getSchemaPath(BillResponseDto) }, + }, + }, + }, + ], + }, + }) @ApiParam({ name: 'id', required: true, @@ -61,7 +89,9 @@ export class BillsController { } @Get(':id/payment-transactions') - @ApiOperation({ summary: 'Retrieve the specific bill associated payment transactions.' }) + @ApiOperation({ + summary: 'Retrieve the specific bill associated payment transactions.', + }) @ApiParam({ name: 'id', required: true, @@ -74,6 +104,13 @@ export class BillsController { @Get(':id') @ApiOperation({ summary: 'Retrieves the bill details.' }) + @ApiResponse({ + status: 200, + description: 'The bill details have been successfully retrieved.', + schema: { + $ref: getSchemaPath(BillResponseDto), + }, + }) @ApiParam({ name: 'id', required: true, diff --git a/packages/server/src/modules/Bills/dtos/BillResponse.dto.ts b/packages/server/src/modules/Bills/dtos/BillResponse.dto.ts new file mode 100644 index 000000000..b082b1496 --- /dev/null +++ b/packages/server/src/modules/Bills/dtos/BillResponse.dto.ts @@ -0,0 +1,202 @@ +import { ApiProperty } from '@nestjs/swagger'; +import { ItemEntryDto } from '@/modules/TransactionItemEntry/dto/ItemEntry.dto'; +import { AttachmentLinkDto } from '@/modules/Attachments/dtos/Attachment.dto'; +import { DiscountType } from '@/common/types/Discount'; + +export class BillResponseDto { + @ApiProperty({ + description: 'The unique identifier of the bill', + example: 1, + }) + id: number; + + @ApiProperty({ + description: 'The bill number', + example: 'BILL-2024-001', + }) + billNumber: string; + + @ApiProperty({ + description: 'The date the bill was issued', + example: '2024-03-15T00:00:00Z', + }) + billDate: Date; + + @ApiProperty({ + description: 'The due date of the bill', + example: '2024-04-15T00:00:00Z', + }) + dueDate: Date; + + @ApiProperty({ + description: 'The reference number', + example: 'PO-2024-001', + required: false, + }) + referenceNo?: string; + + @ApiProperty({ + description: 'The ID of the vendor', + example: 1001, + }) + vendorId: number; + + @ApiProperty({ + description: 'The exchange rate for currency conversion', + example: 1.25, + required: false, + }) + exchangeRate?: number; + + @ApiProperty({ + description: 'The currency code', + example: 'USD', + required: false, + }) + currencyCode?: string; + + @ApiProperty({ + description: 'Additional notes about the bill', + example: 'Office supplies and equipment for Q2 2024', + required: false, + }) + note?: string; + + @ApiProperty({ + description: 'Whether tax is inclusive in the item rates', + example: false, + required: false, + }) + isInclusiveTax?: boolean; + + @ApiProperty({ + description: 'The line items of the bill', + type: [ItemEntryDto], + }) + entries: ItemEntryDto[]; + + @ApiProperty({ + description: 'The ID of the warehouse', + example: 101, + required: false, + }) + warehouseId?: number; + + @ApiProperty({ + description: 'The ID of the branch', + example: 201, + required: false, + }) + branchId?: number; + + @ApiProperty({ + description: 'The ID of the project', + example: 301, + required: false, + }) + projectId?: number; + + @ApiProperty({ + description: 'The attachments of the bill', + type: [AttachmentLinkDto], + required: false, + }) + attachments?: AttachmentLinkDto[]; + + @ApiProperty({ + description: 'The discount value', + example: 100, + required: false, + }) + discount?: number; + + @ApiProperty({ + description: 'The type of discount (percentage or fixed)', + enum: DiscountType, + example: DiscountType.Amount, + required: false, + }) + discountType?: DiscountType; + + @ApiProperty({ + description: 'The adjustment amount', + example: 50, + required: false, + }) + adjustment?: number; + + @ApiProperty({ + description: 'The total amount of tax withheld', + example: 50, + required: false, + }) + taxAmountWithheld?: number; + + @ApiProperty({ + description: 'The balance of the bill', + example: 1000, + }) + balance: number; + + @ApiProperty({ + description: 'The amount paid', + example: 500, + }) + paymentAmount: number; + + @ApiProperty({ + description: 'The amount credited', + example: 0, + required: false, + }) + creditedAmount?: number; + + @ApiProperty({ + description: 'The subtotal amount before tax and adjustments', + example: 900, + }) + subtotal: number; + + @ApiProperty({ + description: 'The total amount including tax and adjustments', + example: 1000, + }) + total: number; + + @ApiProperty({ + description: 'The due amount remaining to be paid', + example: 500, + }) + dueAmount: number; + + @ApiProperty({ + description: 'Whether the bill is overdue', + example: false, + }) + isOverdue: boolean; + + @ApiProperty({ + description: 'Whether the bill is partially paid', + example: true, + }) + isPartiallyPaid: boolean; + + @ApiProperty({ + description: 'Whether the bill is fully paid', + example: false, + }) + isFullyPaid: boolean; + + @ApiProperty({ + description: 'The date when the bill was created', + example: '2024-03-15T00:00:00Z', + }) + createdAt: Date; + + @ApiProperty({ + description: 'The date when the bill was last updated', + example: '2024-03-16T00:00:00Z', + required: false, + }) + updatedAt?: Date; +} diff --git a/packages/server/src/modules/CreditNotes/CreditNotes.controller.ts b/packages/server/src/modules/CreditNotes/CreditNotes.controller.ts index b4e590bcc..b8da211f3 100644 --- a/packages/server/src/modules/CreditNotes/CreditNotes.controller.ts +++ b/packages/server/src/modules/CreditNotes/CreditNotes.controller.ts @@ -1,4 +1,11 @@ -import { ApiTags, ApiOperation, ApiResponse, ApiParam } from '@nestjs/swagger'; +import { + ApiTags, + ApiOperation, + ApiResponse, + ApiParam, + ApiExtraModels, + getSchemaPath, +} from '@nestjs/swagger'; import { Body, Controller, @@ -12,9 +19,13 @@ import { import { CreditNoteApplication } from './CreditNoteApplication.service'; import { ICreditNotesQueryDTO } from './types/CreditNotes.types'; import { CreateCreditNoteDto, EditCreditNoteDto } from './dtos/CreditNote.dto'; +import { CreditNoteResponseDto } from './dtos/CreditNoteResponse.dto'; +import { PaginatedResponseDto } from '@/common/dtos/PaginatedResults.dto'; @Controller('credit-notes') @ApiTags('Credit Notes') +@ApiExtraModels(CreditNoteResponseDto) +@ApiExtraModels(PaginatedResponseDto) export class CreditNotesController { /** * @param {CreditNoteApplication} creditNoteApplication - The credit note application service. @@ -39,7 +50,13 @@ export class CreditNotesController { @Get(':id') @ApiOperation({ summary: 'Get a specific credit note by ID' }) @ApiParam({ name: 'id', description: 'Credit note ID', type: 'number' }) - @ApiResponse({ status: 200, description: 'Returns the credit note' }) + @ApiResponse({ + status: 200, + description: 'Returns the credit note', + schema: { + $ref: getSchemaPath(CreditNoteResponseDto), + }, + }) @ApiResponse({ status: 404, description: 'Credit note not found' }) getCreditNote(@Param('id') creditNoteId: number) { return this.creditNoteApplication.getCreditNote(creditNoteId); @@ -47,7 +64,23 @@ export class CreditNotesController { @Get() @ApiOperation({ summary: 'Get all credit notes' }) - @ApiResponse({ status: 200, description: 'Returns a list of credit notes' }) + @ApiResponse({ + status: 200, + description: 'Returns a list of credit notes', + schema: { + allOf: [ + { $ref: getSchemaPath(PaginatedResponseDto) }, + { + properties: { + data: { + type: 'array', + items: { $ref: getSchemaPath(CreditNoteResponseDto) }, + }, + }, + }, + ], + }, + }) getCreditNotes(@Query() creditNotesQuery: ICreditNotesQueryDTO) { return this.creditNoteApplication.getCreditNotes(creditNotesQuery); } diff --git a/packages/server/src/modules/CreditNotes/dtos/CreditNoteResponse.dto.ts b/packages/server/src/modules/CreditNotes/dtos/CreditNoteResponse.dto.ts new file mode 100644 index 000000000..d1c05132b --- /dev/null +++ b/packages/server/src/modules/CreditNotes/dtos/CreditNoteResponse.dto.ts @@ -0,0 +1,266 @@ +import { ApiProperty } from '@nestjs/swagger'; +import { ItemEntryDto } from '@/modules/TransactionItemEntry/dto/ItemEntry.dto'; +import { AttachmentLinkDto } from '@/modules/Attachments/dtos/Attachment.dto'; +import { DiscountType } from '@/common/types/Discount'; + +export class CreditNoteResponseDto { + @ApiProperty({ + description: 'The unique identifier of the credit note', + example: 1, + }) + id: number; + + @ApiProperty({ + description: 'The date of the credit note', + example: '2023-01-01T00:00:00Z', + }) + creditNoteDate: Date; + + @ApiProperty({ description: 'The credit note number', example: 'CN-001' }) + creditNoteNumber: string; + + @ApiProperty({ + description: 'The reference number', + example: 'REF-001', + required: false, + }) + referenceNo?: string; + + @ApiProperty({ description: 'The ID of the customer', example: 1 }) + customerId: number; + + @ApiProperty({ + description: 'The exchange rate for currency conversion', + example: 1.0, + required: false, + }) + exchangeRate?: number; + + @ApiProperty({ + description: 'The currency code', + example: 'USD', + required: false, + }) + currencyCode?: string; + + @ApiProperty({ + description: 'Custom note on the credit note', + example: 'Thank you for your business', + required: false, + }) + note?: string; + + @ApiProperty({ + description: 'Terms and conditions of the credit note', + example: 'Valid for 30 days', + required: false, + }) + termsConditions?: string; + + @ApiProperty({ + description: 'Whether the credit note is open', + example: true, + }) + isOpen: boolean; + + @ApiProperty({ + description: 'Whether the credit note is closed', + example: false, + }) + isClosed: boolean; + + @ApiProperty({ + description: 'The line items of the credit note', + type: [ItemEntryDto], + }) + entries: ItemEntryDto[]; + + @ApiProperty({ + description: 'The ID of the warehouse', + example: 1, + required: false, + }) + warehouseId?: number; + + @ApiProperty({ + description: 'The ID of the branch', + example: 1, + required: false, + }) + branchId?: number; + + @ApiProperty({ + description: 'The attachments of the credit note', + type: [AttachmentLinkDto], + required: false, + }) + attachments?: AttachmentLinkDto[]; + + @ApiProperty({ + description: 'The discount value', + example: 10, + required: false, + }) + discount?: number; + + @ApiProperty({ + description: 'The type of discount (percentage or fixed)', + enum: DiscountType, + example: DiscountType.Percentage, + required: false, + }) + discountType?: DiscountType; + + @ApiProperty({ + description: 'The adjustment amount', + example: 5, + required: false, + }) + adjustment?: number; + + @ApiProperty({ + description: 'The ID of the PDF template', + example: 1, + required: false, + }) + pdfTemplateId?: number; + + @ApiProperty({ + description: 'The total amount of credits remaining', + example: 100, + required: false, + }) + creditsRemaining?: number; + + @ApiProperty({ + description: 'The total amount of credits used', + example: 50, + required: false, + }) + creditsUsed?: number; + + @ApiProperty({ + description: 'The subtotal amount before discount and adjustments', + example: 900, + }) + subtotal: number; + + @ApiProperty({ + description: 'The subtotal amount in local currency', + example: 900, + required: false, + }) + subtotalLocal?: number; + + @ApiProperty({ + description: 'The discount amount', + example: 10, + required: false, + }) + discountAmount?: number; + + @ApiProperty({ + description: 'The discount amount in local currency', + example: 10, + required: false, + }) + discountAmountLocal?: number; + + @ApiProperty({ + description: 'The discount percentage', + example: 10, + required: false, + }) + discountPercentage?: number; + + @ApiProperty({ + description: 'The adjustment amount in local currency', + example: 5, + required: false, + }) + adjustmentLocal?: number; + + @ApiProperty({ + description: 'The total amount after discount and adjustments', + example: 1000, + }) + total: number; + + @ApiProperty({ + description: 'The total amount in local currency', + example: 1000, + required: false, + }) + totalLocal?: number; + + @ApiProperty({ + description: 'The date when the credit note was created', + example: '2023-01-01T00:00:00Z', + }) + createdAt: Date; + + @ApiProperty({ + description: 'The date when the credit note was last updated', + example: '2023-01-02T00:00:00Z', + required: false, + }) + updatedAt?: Date; + + // Formatted fields from transformer + @ApiProperty({ + description: 'Formatted credit note date', + example: '2023-01-01', + }) + formattedCreditNoteDate: string; + + @ApiProperty({ + description: 'Formatted created at date', + example: '2023-01-01', + }) + formattedCreatedAt: string; + + @ApiProperty({ description: 'Formatted amount', example: '$1,000.00' }) + formattedAmount: string; + + @ApiProperty({ + description: 'Formatted credits remaining', + example: '$100.00', + }) + formattedCreditsRemaining: string; + + @ApiProperty({ description: 'Formatted credits used', example: '$50.00' }) + formattedCreditsUsed: string; + + @ApiProperty({ description: 'Formatted subtotal', example: '$900.00' }) + formattedSubtotal: string; + + @ApiProperty({ description: 'Formatted discount amount', example: '$10.00' }) + discountAmountFormatted: string; + + @ApiProperty({ + description: 'Formatted discount amount in local currency', + example: '$10.00', + }) + discountAmountLocalFormatted: string; + + @ApiProperty({ description: 'Formatted discount percentage', example: '10%' }) + discountPercentageFormatted: string; + + @ApiProperty({ description: 'Formatted adjustment', example: '$5.00' }) + adjustmentFormatted: string; + + @ApiProperty({ + description: 'Formatted adjustment in local currency', + example: '$5.00', + }) + adjustmentLocalFormatted: string; + + @ApiProperty({ description: 'Formatted total', example: '$1,000.00' }) + totalFormatted: string; + + @ApiProperty({ + description: 'Formatted total in local currency', + example: '$1,000.00', + }) + totalLocalFormatted: string; +} diff --git a/packages/server/src/modules/InventoryAdjutments/queries/GetInventoryAdjustments.service.ts b/packages/server/src/modules/InventoryAdjutments/queries/GetInventoryAdjustments.service.ts index 61916e7be..a95d42901 100644 --- a/packages/server/src/modules/InventoryAdjutments/queries/GetInventoryAdjustments.service.ts +++ b/packages/server/src/modules/InventoryAdjutments/queries/GetInventoryAdjustments.service.ts @@ -46,7 +46,6 @@ export class GetInventoryAdjustmentsService { this.inventoryAdjustmentModel(), filter, ); - const { results, pagination } = await this.inventoryAdjustmentModel() .query() .onBuild((query) => { @@ -62,10 +61,7 @@ export class GetInventoryAdjustmentsService { results, new InventoryAdjustmentTransformer(), ); - return { - data, - pagination, - }; + return { data, pagination }; } /** diff --git a/packages/server/src/modules/PaymentReceived/PaymentsReceived.controller.ts b/packages/server/src/modules/PaymentReceived/PaymentsReceived.controller.ts index dc7fbef76..950e81b8b 100644 --- a/packages/server/src/modules/PaymentReceived/PaymentsReceived.controller.ts +++ b/packages/server/src/modules/PaymentReceived/PaymentsReceived.controller.ts @@ -1,4 +1,10 @@ -import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; +import { + ApiExtraModels, + ApiOperation, + ApiResponse, + ApiTags, + getSchemaPath, +} from '@nestjs/swagger'; import { Body, Controller, @@ -22,9 +28,15 @@ import { EditPaymentReceivedDto, } from './dtos/PaymentReceived.dto'; import { AcceptType } from '@/constants/accept-type'; +import { PaymentReceivedResponseDto } from './dtos/PaymentReceivedResponse.dto'; +import { PaginatedResponseDto } from '@/common/dtos/PaginatedResults.dto'; +import { PaymentReceivedStateResponseDto } from './dtos/PaymentReceivedStateResponse.dto'; @Controller('payments-received') @ApiTags('Payments Received') +@ApiExtraModels(PaymentReceivedResponseDto) +@ApiExtraModels(PaginatedResponseDto) +@ApiExtraModels(PaymentReceivedStateResponseDto) export class PaymentReceivesController { constructor(private paymentReceivesApplication: PaymentReceivesApplication) {} @@ -106,6 +118,23 @@ export class PaymentReceivesController { @Get() @ApiOperation({ summary: 'Retrieves the payment received list.' }) + @ApiResponse({ + status: 200, + description: 'The payment received has been retrieved successfully.', + schema: { + allOf: [ + { $ref: getSchemaPath(PaginatedResponseDto) }, + { + properties: { + data: { + type: 'array', + items: { $ref: getSchemaPath(PaymentReceivedResponseDto) }, + }, + }, + }, + ], + }, + }) public getPaymentsReceived( @Query() filterDTO: Partial, ) { @@ -117,6 +146,9 @@ export class PaymentReceivesController { @ApiResponse({ status: 200, description: 'The payment received state has been successfully retrieved.', + schema: { + $ref: getSchemaPath(PaymentReceivedStateResponseDto), + }, }) public getPaymentReceivedState() { return this.paymentReceivesApplication.getPaymentReceivedState(); @@ -143,6 +175,9 @@ export class PaymentReceivesController { status: 200, description: 'The payment received details have been successfully retrieved.', + schema: { + $ref: getSchemaPath(PaymentReceivedResponseDto), + }, }) public async getPaymentReceive( @Param('id', ParseIntPipe) paymentReceiveId: number, diff --git a/packages/server/src/modules/PaymentReceived/dtos/PaymentReceivedResponse.dto.ts b/packages/server/src/modules/PaymentReceived/dtos/PaymentReceivedResponse.dto.ts new file mode 100644 index 000000000..ad4e586f2 --- /dev/null +++ b/packages/server/src/modules/PaymentReceived/dtos/PaymentReceivedResponse.dto.ts @@ -0,0 +1,199 @@ +import { ApiProperty } from '@nestjs/swagger'; +import { Type } from 'class-transformer'; +import { AttachmentLinkDto } from '@/modules/Attachments/dtos/Attachment.dto'; +import { AccountResponseDto } from '@/modules/Accounts/dtos/AccountResponse.dto'; +import { BranchResponseDto } from '@/modules/Branches/dtos/BranchResponse.dto'; + +class PaymentReceivedEntryResponseDto { + @ApiProperty({ description: 'ID of the entry', example: 1 }) + id: number; + + @ApiProperty({ description: 'Index of the entry', example: 0 }) + index: number; + + @ApiProperty({ description: 'ID of the payment received', example: 1 }) + paymentReceiveId: number; + + @ApiProperty({ description: 'ID of the invoice', example: 10 }) + invoiceId: number; + + @ApiProperty({ description: 'Amount paid for this invoice', example: 100 }) + paymentAmount: number; + + @ApiProperty({ description: 'Formatted paid amount', example: '100.00' }) + paymentAmountFormatted: string; + + @ApiProperty({ + description: 'Invoice details', + example: { + id: 10, + invoiceNo: 'INV-001', + total: 1000, + dueAmount: 500, + customerId: 1, + }, + }) + invoice: any; // Use a minimal inline object or import a minimal DTO if available +} + +export class PaymentReceivedResponseDto { + @ApiProperty({ + description: 'The unique identifier of the payment received', + example: 1, + }) + id: number; + + @ApiProperty({ description: 'The payment receive number', example: 'PR-001' }) + paymentReceiveNo: string; + + @ApiProperty({ + description: 'The date of the payment', + example: '2023-01-01T00:00:00Z', + }) + paymentDate: Date | string; + + @ApiProperty({ + description: 'The formatted payment date', + example: '2023-01-01', + }) + formattedPaymentDate: string; + + @ApiProperty({ description: 'The customer ID', example: 1 }) + customerId: number; + + @ApiProperty({ + description: 'The reference number', + example: 'REF-001', + required: false, + }) + referenceNo?: string; + + @ApiProperty({ description: 'The amount received', example: 100 }) + amount: number; + + @ApiProperty({ description: 'The formatted amount', example: '100.00' }) + formattedAmount: string; + + @ApiProperty({ description: 'The currency code', example: 'USD' }) + currencyCode: string; + + @ApiProperty({ description: 'The exchange rate', example: 1.0 }) + exchangeRate: number; + + @ApiProperty({ description: 'The formatted exchange rate', example: '1.00' }) + formattedExchangeRate: string; + + @ApiProperty({ + description: 'The statement or note', + example: 'Payment for invoice INV-001', + required: false, + }) + statement?: string; + + @ApiProperty({ description: 'The ID of the deposit account', example: 2 }) + depositAccountId: number; + + @ApiProperty({ + description: 'Deposit account details', + type: () => AccountResponseDto, + }) + @Type(() => AccountResponseDto) + depositAccount: AccountResponseDto; + + @ApiProperty({ + description: 'The ID of the branch', + example: 1, + required: false, + }) + branchId?: number; + + @ApiProperty({ + description: 'Branch details', + type: () => BranchResponseDto, + required: false, + }) + @Type(() => BranchResponseDto) + branch?: BranchResponseDto; + + @ApiProperty({ + description: 'The ID of the PDF template', + example: 1, + required: false, + }) + pdfTemplateId?: number; + + @ApiProperty({ + description: 'PDF template details', + required: false, + example: { + id: 1, + templateName: 'Default', + resource: 'PaymentReceive', + attributes: { primaryColor: '#000000' }, + }, + }) + pdfTemplate?: { + id: number; + templateName: string; + resource: string; + attributes: Record; + }; + + @ApiProperty({ + description: 'The user ID who created the payment', + example: 5, + }) + userId: number; + + @ApiProperty({ + description: 'The date when the payment was created', + example: '2023-01-01T00:00:00Z', + }) + createdAt: Date | string; + + @ApiProperty({ + description: 'The formatted created at date', + example: '2023-01-01', + }) + formattedCreatedAt: string; + + @ApiProperty({ + description: 'The date when the payment was last updated', + example: '2023-01-02T00:00:00Z', + required: false, + }) + updatedAt?: Date | string; + + @ApiProperty({ + description: 'The entries of the payment received', + type: [PaymentReceivedEntryResponseDto], + example: [ + { + id: 1, + index: 0, + paymentReceiveId: 1, + invoiceId: 10, + paymentAmount: 100, + paymentAmountFormatted: '100.00', + invoice: { + id: 10, + invoiceNo: 'INV-001', + total: 1000, + dueAmount: 500, + customerId: 1, + }, + }, + ], + }) + @Type(() => PaymentReceivedEntryResponseDto) + entries: PaymentReceivedEntryResponseDto[]; + + @ApiProperty({ + description: 'The attachments of the payment received', + type: [AttachmentLinkDto], + required: false, + example: [{ key: 'file-uuid-1' }, { key: 'file-uuid-2' }], + }) + @Type(() => AttachmentLinkDto) + attachments?: AttachmentLinkDto[]; +} diff --git a/packages/server/src/modules/PaymentReceived/dtos/PaymentReceivedStateResponse.dto.ts b/packages/server/src/modules/PaymentReceived/dtos/PaymentReceivedStateResponse.dto.ts new file mode 100644 index 000000000..6a3692046 --- /dev/null +++ b/packages/server/src/modules/PaymentReceived/dtos/PaymentReceivedStateResponse.dto.ts @@ -0,0 +1,11 @@ +import { ApiProperty } from '@nestjs/swagger'; + +export class PaymentReceivedStateResponseDto { + @ApiProperty({ + description: 'The ID of the default PDF template for payment received', + example: 1, + type: Number, + nullable: true, + }) + defaultTemplateId: number; +} diff --git a/packages/server/src/modules/SaleEstimates/SaleEstimates.controller.ts b/packages/server/src/modules/SaleEstimates/SaleEstimates.controller.ts index a2011edba..7f9e6bb53 100644 --- a/packages/server/src/modules/SaleEstimates/SaleEstimates.controller.ts +++ b/packages/server/src/modules/SaleEstimates/SaleEstimates.controller.ts @@ -1,4 +1,11 @@ -import { ApiOperation, ApiParam, ApiResponse, ApiTags } from '@nestjs/swagger'; +import { + ApiExtraModels, + ApiOperation, + ApiParam, + ApiResponse, + ApiTags, + getSchemaPath, +} from '@nestjs/swagger'; import { Body, Controller, @@ -25,9 +32,15 @@ import { } from './dtos/SaleEstimate.dto'; import { AcceptType } from '@/constants/accept-type'; import { Response } from 'express'; +import { SaleEstimateResponseDto } from './dtos/SaleEstimateResponse.dto'; +import { PaginatedResponseDto } from '@/common/dtos/PaginatedResults.dto'; +import { SaleEstiamteStateResponseDto } from './dtos/SaleEstimateStateResponse.dto'; @Controller('sale-estimates') @ApiTags('Sale Estimates') +@ApiExtraModels(SaleEstimateResponseDto) +@ApiExtraModels(PaginatedResponseDto) +@ApiExtraModels(SaleEstiamteStateResponseDto) export class SaleEstimatesController { /** * @param {SaleEstimatesApplication} saleEstimatesApplication - Sale estimates application. @@ -101,6 +114,9 @@ export class SaleEstimatesController { @ApiResponse({ status: 200, description: 'Sale estimate state retrieved successfully', + schema: { + $ref: getSchemaPath(SaleEstiamteStateResponseDto), + }, }) public getSaleEstimateState() { return this.saleEstimatesApplication.getSaleEstimateState(); @@ -111,6 +127,19 @@ export class SaleEstimatesController { @ApiResponse({ status: 200, description: 'Sale estimates retrieved successfully', + schema: { + allOf: [ + { $ref: getSchemaPath(SaleEstimateResponseDto) }, + { + properties: { + data: { + type: 'array', + items: { $ref: getSchemaPath(SaleEstimateResponseDto) }, + }, + }, + }, + ], + }, }) public getSaleEstimates(@Query() filterDTO: ISalesEstimatesFilter) { return this.saleEstimatesApplication.getSaleEstimates(filterDTO); @@ -224,7 +253,16 @@ export class SaleEstimatesController { } @Get(':id') - @ApiOperation({ summary: 'Retrieves the sale estimate details.' }) + @ApiOperation({ + summary: 'Retrieves the sale estimate details.', + }) + @ApiResponse({ + status: 200, + description: 'The sale estimate details have been successfully retrieved.', + schema: { + $ref: getSchemaPath(SaleEstimateResponseDto), + }, + }) @ApiParam({ name: 'id', required: true, diff --git a/packages/server/src/modules/SaleEstimates/dtos/SaleEstimateResponse.dto.ts b/packages/server/src/modules/SaleEstimates/dtos/SaleEstimateResponse.dto.ts new file mode 100644 index 000000000..72dde351c --- /dev/null +++ b/packages/server/src/modules/SaleEstimates/dtos/SaleEstimateResponse.dto.ts @@ -0,0 +1,206 @@ +import { ApiProperty } from '@nestjs/swagger'; +import { Type } from 'class-transformer'; +import { ItemEntryDto } from '@/modules/TransactionItemEntry/dto/ItemEntry.dto'; +import { AttachmentLinkDto } from '@/modules/Attachments/dtos/Attachment.dto'; + +export class SaleEstimateResponseDto { + // Model attributes + @ApiProperty({ description: 'Unique identifier of the customer', example: 1 }) + customerId: number; + + @ApiProperty({ description: 'Date of the estimate', example: '2024-01-01' }) + estimateDate: string; + + @ApiProperty({ + description: 'Expiration date of the estimate', + example: '2024-01-31', + }) + expirationDate: string; + + @ApiProperty({ + description: 'Reference number of the estimate', + example: 'EST-2024-001', + }) + reference: string; + + @ApiProperty({ description: 'Estimate number', example: 'EST-2024-001' }) + estimateNumber: string; + + @ApiProperty({ + description: 'Note for the estimate', + example: 'This is a note.', + }) + note: string; + + @ApiProperty({ + description: 'Terms and conditions for the estimate', + example: 'Payment due in 30 days.', + }) + termsConditions: string; + + @ApiProperty({ + description: 'Email to send the estimate to', + example: 'customer@email.com', + }) + sendToEmail: string; + + @ApiProperty({ + description: 'Exchange rate used for the estimate', + example: 1, + }) + exchangeRate: number; + + @ApiProperty({ description: 'Amount of the estimate', example: 1000 }) + amount: number; + + @ApiProperty({ description: 'Currency code', example: 'USD' }) + currencyCode: string; + + @ApiProperty({ + description: 'Delivered at date', + example: '2024-01-05', + required: false, + }) + deliveredAt?: string; + + @ApiProperty({ + description: 'Approved at date', + example: '2024-01-10', + required: false, + }) + approvedAt?: string; + + @ApiProperty({ + description: 'Rejected at date', + example: '2024-01-15', + required: false, + }) + rejectedAt?: string; + + @ApiProperty({ description: 'User ID who created the estimate', example: 42 }) + userId: number; + + @ApiProperty({ + description: 'Converted to invoice ID', + example: 100, + required: false, + }) + convertedToInvoiceId?: number; + + @ApiProperty({ + description: 'Converted to invoice at date', + example: '2024-02-01', + required: false, + }) + convertedToInvoiceAt?: string; + + @ApiProperty({ + description: 'Created at date', + example: '2024-01-01', + required: false, + }) + createdAt?: string; + + @ApiProperty({ + description: 'Updated at date', + example: '2024-01-10', + required: false, + }) + updatedAt?: string; + + @ApiProperty({ description: 'Branch ID', example: 2, required: false }) + branchId?: number; + + @ApiProperty({ description: 'Warehouse ID', example: 3, required: false }) + warehouseId?: number; + + @ApiProperty({ description: 'Discount value', example: 100 }) + discount: number; + + @ApiProperty({ description: 'Discount type', example: 'amount' }) + discountType: string; + + @ApiProperty({ description: 'Adjustment value', example: 50 }) + adjustment: number; + + // Formatted/virtual fields + @ApiProperty({ + description: 'Formatted subtotal of the estimate', + example: '1,000.00', + }) + formattedSubtotal: string; + + @ApiProperty({ + description: 'Formatted total amount of the estimate', + example: '1,200.00', + }) + formattedAmount: string; + + @ApiProperty({ + description: 'Formatted estimate date', + example: '2024-01-01', + }) + formattedEstimateDate: string; + + @ApiProperty({ + description: 'Formatted expiration date', + example: '2024-01-31', + }) + formattedExpirationDate: string; + + @ApiProperty({ + description: 'Formatted delivered at date', + example: '2024-01-05', + }) + formattedDeliveredAtDate: string; + + @ApiProperty({ + description: 'Formatted approved at date', + example: '2024-01-10', + }) + formattedApprovedAtDate: string; + + @ApiProperty({ + description: 'Formatted rejected at date', + example: '2024-01-15', + }) + formattedRejectedAtDate: string; + + @ApiProperty({ description: 'Formatted discount amount', example: '100.00' }) + discountAmountFormatted: string; + + @ApiProperty({ description: 'Formatted discount percentage', example: '10%' }) + discountPercentageFormatted: string; + + @ApiProperty({ description: 'Formatted adjustment amount', example: '50.00' }) + adjustmentFormatted: string; + + @ApiProperty({ description: 'Formatted total', example: '1,150.00' }) + totalFormatted: string; + + @ApiProperty({ + description: 'Formatted total in local currency', + example: '1,200.00', + }) + totalLocalFormatted: string; + + @ApiProperty({ + description: 'Formatted created at date', + example: '2024-01-01', + }) + formattedCreatedAt: string; + + @ApiProperty({ + description: 'Entries of the sale estimate', + type: [ItemEntryDto], + }) + @Type(() => ItemEntryDto) + entries: ItemEntryDto[]; + + @ApiProperty({ + description: 'Attachments of the sale estimate', + type: [AttachmentLinkDto], + }) + @Type(() => AttachmentLinkDto) + attachments: AttachmentLinkDto[]; +} diff --git a/packages/server/src/modules/SaleEstimates/dtos/SaleEstimateStateResponse.dto.ts b/packages/server/src/modules/SaleEstimates/dtos/SaleEstimateStateResponse.dto.ts new file mode 100644 index 000000000..e2a5eb98a --- /dev/null +++ b/packages/server/src/modules/SaleEstimates/dtos/SaleEstimateStateResponse.dto.ts @@ -0,0 +1,11 @@ +import { ApiProperty } from '@nestjs/swagger'; + +export class SaleEstiamteStateResponseDto { + @ApiProperty({ + description: 'The ID of the default PDF template for sale estimates', + example: 1, + type: Number, + nullable: true, + }) + defaultTemplateId: number; +} diff --git a/packages/server/src/modules/SaleInvoices/SaleInvoices.controller.ts b/packages/server/src/modules/SaleInvoices/SaleInvoices.controller.ts index 04514ec47..c0b364162 100644 --- a/packages/server/src/modules/SaleInvoices/SaleInvoices.controller.ts +++ b/packages/server/src/modules/SaleInvoices/SaleInvoices.controller.ts @@ -36,10 +36,14 @@ import { } from './dtos/SaleInvoice.dto'; import { AcceptType } from '@/constants/accept-type'; import { SaleInvoiceResponseDto } from './dtos/SaleInvoiceResponse.dto'; +import { PaginatedResponseDto } from '@/common/dtos/PaginatedResults.dto'; +import { SaleInvoiceStateResponseDto } from './dtos/SaleInvoiceState.dto'; @Controller('sale-invoices') @ApiTags('Sale Invoices') @ApiExtraModels(SaleInvoiceResponseDto) +@ApiExtraModels(PaginatedResponseDto) +@ApiExtraModels(SaleInvoiceStateResponseDto) @ApiHeader({ name: 'organization-id', description: 'The organization id', @@ -143,6 +147,9 @@ export class SaleInvoicesController { @ApiResponse({ status: 200, description: 'The sale invoice state has been successfully retrieved.', + schema: { + $ref: getSchemaPath(SaleInvoiceStateResponseDto), + }, }) @ApiResponse({ status: 404, description: 'The sale invoice not found.' }) getSaleInvoiceState() { @@ -191,6 +198,19 @@ export class SaleInvoicesController { @ApiResponse({ status: 200, description: 'The sale invoices have been successfully retrieved.', + schema: { + allOf: [ + { $ref: getSchemaPath(PaginatedResponseDto) }, + { + properties: { + data: { + type: 'array', + items: { $ref: getSchemaPath(SaleInvoiceResponseDto) }, + }, + }, + }, + ], + }, }) getSaleInvoices(@Query() filterDTO: Partial) { return this.saleInvoiceApplication.getSaleInvoices(filterDTO); diff --git a/packages/server/src/modules/SaleReceipts/SaleReceipts.controller.ts b/packages/server/src/modules/SaleReceipts/SaleReceipts.controller.ts index 8474d0c33..845c8e073 100644 --- a/packages/server/src/modules/SaleReceipts/SaleReceipts.controller.ts +++ b/packages/server/src/modules/SaleReceipts/SaleReceipts.controller.ts @@ -13,7 +13,14 @@ import { Res, } from '@nestjs/common'; import { SaleReceiptApplication } from './SaleReceiptApplication.service'; -import { ApiOperation, ApiParam, ApiResponse, ApiTags } from '@nestjs/swagger'; +import { + ApiExtraModels, + ApiOperation, + ApiParam, + ApiResponse, + ApiTags, + getSchemaPath, +} from '@nestjs/swagger'; import { CreateSaleReceiptDto, EditSaleReceiptDto, @@ -21,9 +28,15 @@ import { import { ISalesReceiptsFilter } from './types/SaleReceipts.types'; import { AcceptType } from '@/constants/accept-type'; import { Response } from 'express'; +import { SaleReceiptResponseDto } from './dtos/SaleReceiptResponse.dto'; +import { PaginatedResponseDto } from '@/common/dtos/PaginatedResults.dto'; +import { SaleReceiptStateResponseDto } from './dtos/SaleReceiptState.dto'; @Controller('sale-receipts') @ApiTags('Sale Receipts') +@ApiExtraModels(SaleReceiptResponseDto) +@ApiExtraModels(PaginatedResponseDto) +@ApiExtraModels(SaleReceiptStateResponseDto) export class SaleReceiptsController { constructor(private saleReceiptApplication: SaleReceiptApplication) {} @@ -48,6 +61,13 @@ export class SaleReceiptsController { @Get('state') @ApiOperation({ summary: 'Retrieves the sale receipt state.' }) + @ApiResponse({ + status: 200, + description: 'The sale receipt has been retrieved.', + schema: { + $ref: getSchemaPath(SaleReceiptStateResponseDto), + }, + }) getSaleReceiptState() { return this.saleReceiptApplication.getSaleReceiptState(); } @@ -85,6 +105,9 @@ export class SaleReceiptsController { @ApiResponse({ status: 200, description: 'The sale receipt details have been successfully retrieved.', + schema: { + $ref: getSchemaPath(SaleReceiptResponseDto), + }, }) @ApiResponse({ status: 404, description: 'The sale receipt not found.' }) @ApiParam({ @@ -119,6 +142,23 @@ export class SaleReceiptsController { @Get() @ApiOperation({ summary: 'Retrieves the sale receipts paginated list' }) + @ApiResponse({ + status: 200, + description: '', + schema: { + allOf: [ + { $ref: getSchemaPath(PaginatedResponseDto) }, + { + properties: { + data: { + type: 'array', + items: { $ref: getSchemaPath(SaleReceiptResponseDto) }, + }, + }, + }, + ], + }, + }) getSaleReceipts(@Query() filterDTO: Partial) { return this.saleReceiptApplication.getSaleReceipts(filterDTO); } diff --git a/packages/server/src/modules/SaleReceipts/dtos/SaleReceiptResponse.dto.ts b/packages/server/src/modules/SaleReceipts/dtos/SaleReceiptResponse.dto.ts new file mode 100644 index 000000000..a5029a000 --- /dev/null +++ b/packages/server/src/modules/SaleReceipts/dtos/SaleReceiptResponse.dto.ts @@ -0,0 +1,246 @@ +import { ApiProperty } from '@nestjs/swagger'; +import { Type } from 'class-transformer'; +import { DiscountType } from '@/common/types/Discount'; +import { ItemEntryDto } from '@/modules/TransactionItemEntry/dto/ItemEntry.dto'; +import { AttachmentLinkDto } from '@/modules/Attachments/dtos/Attachment.dto'; +import { CustomerResponseDto } from '@/modules/Customers/dtos/CustomerResponse.dto'; +import { AccountResponseDto } from '@/modules/Accounts/dtos/AccountResponse.dto'; +import { BranchResponseDto } from '@/modules/Branches/dtos/BranchResponse.dto'; +import { WarehouseResponseDto } from '@/modules/Warehouses/dtos/WarehouseResponse.dto'; + +export class SaleReceiptResponseDto { + @ApiProperty({ + description: 'The unique identifier of the sale receipt', + example: 1, + }) + id: number; + + @ApiProperty({ + description: 'The date of the sale receipt', + example: '2024-01-01T00:00:00Z', + }) + receiptDate: Date; + + @ApiProperty({ description: 'The receipt number', example: 'SR-2024-001' }) + receiptNumber: string; + + @ApiProperty({ + description: 'The reference number', + example: 'REF-001', + required: false, + }) + referenceNo?: string; + + @ApiProperty({ description: 'The ID of the customer', example: 1 }) + customerId: number; + + @ApiProperty({ + description: 'The customer details', + type: CustomerResponseDto, + }) + @Type(() => CustomerResponseDto) + customer: CustomerResponseDto; + + @ApiProperty({ description: 'The ID of the deposit account', example: 1 }) + depositAccountId: number; + + @ApiProperty({ + description: 'The deposit account details', + type: AccountResponseDto, + }) + @Type(() => AccountResponseDto) + depositAccount: AccountResponseDto; + + @ApiProperty({ + description: 'The exchange rate for currency conversion', + example: 1.0, + required: false, + }) + exchangeRate?: number; + + @ApiProperty({ + description: 'The currency code', + example: 'USD', + required: false, + }) + currencyCode?: string; + + @ApiProperty({ + description: 'The message on the receipt', + example: 'Thank you for your payment', + required: false, + }) + receiptMessage?: string; + + @ApiProperty({ + description: 'The statement on the receipt', + example: 'Paid in full', + required: false, + }) + statement?: string; + + @ApiProperty({ description: 'Whether the receipt is closed', example: false }) + closed: boolean; + + @ApiProperty({ + description: 'The date when the receipt was closed', + example: '2024-01-02T00:00:00Z', + required: false, + }) + closedAt?: Date | string; + + @ApiProperty({ + description: 'The ID of the warehouse', + example: 1, + required: false, + }) + warehouseId?: number; + + @ApiProperty({ + description: 'The warehouse details', + type: WarehouseResponseDto, + required: false, + }) + @Type(() => WarehouseResponseDto) + warehouse?: WarehouseResponseDto; + + @ApiProperty({ + description: 'The ID of the branch', + example: 1, + required: false, + }) + branchId?: number; + + @ApiProperty({ + description: 'The branch details', + type: BranchResponseDto, + required: false, + }) + @Type(() => BranchResponseDto) + branch?: BranchResponseDto; + + @ApiProperty({ + description: 'The entries of the sale receipt', + type: [ItemEntryDto], + }) + @Type(() => ItemEntryDto) + entries: ItemEntryDto[]; + + @ApiProperty({ + description: 'The attachments of the sale receipt', + type: [AttachmentLinkDto], + required: false, + }) + @Type(() => AttachmentLinkDto) + attachments?: AttachmentLinkDto[]; + + @ApiProperty({ + description: 'The discount value', + example: 100, + required: false, + }) + discount?: number; + + @ApiProperty({ + description: 'The type of discount (percentage or fixed)', + enum: DiscountType, + example: DiscountType.Percentage, + required: false, + }) + discountType?: DiscountType; + + @ApiProperty({ + description: 'The adjustment amount', + example: 50, + required: false, + }) + adjustment?: number; + + @ApiProperty({ + description: 'The subtotal amount before discount and adjustments', + example: 900, + }) + subtotal: number; + + @ApiProperty({ description: 'The subtotal in local currency', example: 900 }) + subtotalLocal: number; + + @ApiProperty({ description: 'The formatted subtotal', example: '900.00' }) + subtotalFormatted: string; + + @ApiProperty({ + description: 'The formatted subtotal in local currency', + example: '900.00', + }) + subtotalLocalFormatted: string; + + @ApiProperty({ + description: 'The total amount after discount and adjustments', + example: 1000, + }) + total: number; + + @ApiProperty({ description: 'The total in local currency', example: 1000 }) + totalLocal: number; + + @ApiProperty({ description: 'The formatted total', example: '1,000.00' }) + totalFormatted: string; + + @ApiProperty({ + description: 'The formatted total in local currency', + example: '1,000.00', + }) + totalLocalFormatted: string; + + @ApiProperty({ description: 'The formatted amount', example: '1,000.00' }) + formattedAmount: string; + + @ApiProperty({ + description: 'The formatted receipt date', + example: '2024-01-01', + }) + formattedReceiptDate: string; + + @ApiProperty({ + description: 'The formatted closed at date', + example: '2024-01-02', + }) + formattedClosedAtDate: string; + + @ApiProperty({ + description: 'The formatted created at date', + example: '2024-01-01', + }) + formattedCreatedAt: string; + + @ApiProperty({ + description: 'The formatted discount amount', + example: '100.00', + }) + discountAmountFormatted: string; + + @ApiProperty({ + description: 'The formatted discount percentage', + example: '10%', + }) + discountPercentageFormatted: string; + + @ApiProperty({ + description: 'The formatted adjustment amount', + example: '50.00', + }) + adjustmentFormatted: string; + + @ApiProperty({ + description: 'The date when the receipt was created', + example: '2024-01-01T00:00:00Z', + }) + createdAt: Date; + + @ApiProperty({ + description: 'The date when the receipt was last updated', + example: '2024-01-02T00:00:00Z', + required: false, + }) + updatedAt?: Date; +} diff --git a/packages/server/src/modules/SaleReceipts/dtos/SaleReceiptState.dto.ts b/packages/server/src/modules/SaleReceipts/dtos/SaleReceiptState.dto.ts new file mode 100644 index 000000000..32ebc4107 --- /dev/null +++ b/packages/server/src/modules/SaleReceipts/dtos/SaleReceiptState.dto.ts @@ -0,0 +1,11 @@ +import { ApiProperty } from '@nestjs/swagger'; + +export class SaleReceiptStateResponseDto { + @ApiProperty({ + description: 'The ID of the default PDF template for sale invoices', + example: 1, + type: Number, + nullable: true, + }) + defaultTemplateId: number; +}