1
0
Files
bigcapital/packages/server/src/modules/TransactionItemEntry/dto/ItemEntry.dto.ts
T
Ahmed Bouhuolia 0d687018f8 feat(server): implement tracking tags for GL entries and reporting
- Add tracking tags infrastructure with 5 database tables
- Create TrackingTags module with CRUD API endpoints
- Associate tags with invoice/bill line items and manual journal entries
- Propagate tags to GL entries (accounts_transactions) via ledger storage
- Add tracking tag filtering to all 12 GL-dependent financial reports:
  - General Ledger, Balance Sheet, Profit & Loss
  - Trial Balance, Journal Sheet, Cash Flow Statement
  - Customer/Vendor Balance Summary
  - Transactions by Customer/Vendor/Reference
  - Sales Tax Liability Summary
- Add filterByTrackingTags query modifier to AccountTransaction model
- Add sdk-ts types and fetch functions for tracking tags
- Add React hooks (useTrackingTags, useCreateTrackingTag, etc.)
- TypeScript typecheck passes across all packages
2026-04-19 00:29:47 +02:00

172 lines
3.3 KiB
TypeScript

import { ToNumber } from '@/common/decorators/Validators';
import { DiscountType } from '@/common/types/Discount';
import { ApiProperty } from '@nestjs/swagger';
import {
IsArray,
IsEnum,
IsIn,
IsInt,
IsNotEmpty,
IsNumber,
IsOptional,
IsString,
ValidateNested,
} from 'class-validator';
import { Type } from 'class-transformer';
import { TrackingTagAssignmentDto } from '@/modules/TrackingTags/dtos/AssignTrackingTags.dto';
export class ItemEntryDto {
@IsInt()
@IsOptional()
@ApiProperty({
description: 'The index of the item entry',
example: 1,
})
index: number;
@IsNotEmpty()
@IsInt()
@ApiProperty({
description: 'The id of the item',
example: 1,
})
itemId: number;
@IsNotEmpty()
@ToNumber()
@IsNumber()
@ApiProperty({
description: 'The rate of the item entry',
example: 1,
})
rate: number;
@IsNotEmpty()
@ToNumber()
@IsNumber()
@ApiProperty({
description: 'The quantity of the item entry',
example: 1,
})
quantity: number;
@IsOptional()
@IsNotEmpty()
@IsNumber()
@ToNumber()
@ApiProperty({
description: 'The discount of the item entry',
example: 1,
})
discount?: number;
@IsOptional()
@IsEnum(DiscountType)
@ApiProperty({
description: 'The type of the discount',
example: DiscountType.Percentage,
})
discountType?: DiscountType = DiscountType.Percentage;
@IsOptional()
@IsString()
@ApiProperty({
description: 'The description of the item entry',
example: 'This is a description',
})
description?: string;
@IsOptional()
@IsNotEmpty()
@IsString()
@ApiProperty({
description: 'The tax code of the item entry',
example: '123456',
})
taxCode?: string;
@IsOptional()
@IsNotEmpty()
@IsInt()
@ApiProperty({
description: 'The tax rate id of the item entry',
example: 1,
})
taxRateId?: number;
@IsOptional()
@IsNotEmpty()
@IsInt()
@ApiProperty({
description: 'The warehouse id of the item entry',
example: 1,
})
warehouseId?: number;
@IsOptional()
@IsNotEmpty()
@IsInt()
@ApiProperty({
description: 'The project id of the item entry',
example: 1,
})
projectId?: number;
@IsOptional()
@IsNotEmpty()
@IsInt()
@ApiProperty({
description: 'The project ref id of the item entry',
example: 1,
})
projectRefId?: number;
@IsOptional()
@IsNotEmpty()
@IsString()
@IsIn(['TASK', 'BILL', 'EXPENSE'])
@ApiProperty({
description: 'The project ref type of the item entry',
example: 'TASK',
})
projectRefType?: string;
@IsOptional()
@IsNotEmpty()
@IsNumber()
@ApiProperty({
description: 'The project ref invoiced amount of the item entry',
example: 100,
})
projectRefInvoicedAmount?: number;
@IsOptional()
@IsNotEmpty()
@IsInt()
@ApiProperty({
description: 'The sell account id of the item entry',
example: 1020,
})
sellAccountId?: number;
@IsOptional()
@IsNotEmpty()
@IsInt()
@ApiProperty({
description: 'The cost account id of the item entry',
example: 1021,
})
costAccountId?: number;
@IsOptional()
@IsArray()
@ValidateNested({ each: true })
@Type(() => TrackingTagAssignmentDto)
@ApiProperty({
description: 'The tracking tags of the item entry',
type: [TrackingTagAssignmentDto],
required: false,
})
trackingTags?: TrackingTagAssignmentDto[];
}