invoice number

This commit is contained in:
2026-04-04 15:24:29 +03:30
parent b29bf380ce
commit b5d555e9ab
15 changed files with 583 additions and 529 deletions
@@ -1,4 +1,4 @@
import { Collection, Entity, ManyToOne, OptionalProps, Property,OneToMany } from '@mikro-orm/core';
import { Collection, Entity, ManyToOne, OptionalProps, Property, OneToMany, Opt } from '@mikro-orm/core';
import { Product } from 'src/modules/product/entities/product.entity';
import { BaseEntity } from 'src/common/entities/base.entity';
import { Invoice } from './invoice.entity';
@@ -7,7 +7,7 @@ import { Order } from 'src/modules/order/entities/order.entity';
@Entity({ tableName: 'invoice_items' })
export class InvoiceItem extends BaseEntity {
[OptionalProps]?: 'createdAt' | 'deletedAt' | 'subTotal' | 'total';
[OptionalProps]?: 'createdAt' | 'deletedAt' | 'discount' | 'description' | 'confirmedAt';
@ManyToOne(() => Invoice)
invoice!: Invoice;
@@ -22,16 +22,15 @@ export class InvoiceItem extends BaseEntity {
@Property({ type: 'int' })
quantity!: number;
@Property({ type: 'int' })
unitPrice: number;
@Property({ type: 'int', fieldName: 'unit_price' })
unitPrice!: number;
@Property({
type: 'int',
// columnType: 'int GENERATED ALWAYS AS (COALESCE(unit_price, 0) * quantity) STORED',
// persist: false,
nullable: true
columnType: 'int GENERATED ALWAYS AS (COALESCE(unit_price, 0) * quantity) STORED',
persist: false,
})
subTotal!: number;
subTotal!: number & Opt;
@Property({
type: 'int',
@@ -41,11 +40,10 @@ export class InvoiceItem extends BaseEntity {
@Property({
type: 'int',
nullable: true,
// columnType: 'int GENERATED ALWAYS AS ((COALESCE(unit_price, 0) * quantity) - COALESCE(discount, 0)) STORED',
// persist: false
columnType: 'int GENERATED ALWAYS AS ((COALESCE(unit_price, 0) * quantity) - COALESCE(discount, 0)) STORED',
persist: false
})
total!: number;
total!: number & Opt;
@Property({ type: 'text', nullable: true })
description?: string;