Compare commits
3 Commits
411458fe4c
...
18dc15e442
Author | SHA1 | Date |
---|---|---|
|
18dc15e442 | |
|
198dcb4933 | |
|
901c67137b |
|
@ -0,0 +1,25 @@
|
|||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddDiscountValueToVoucher1728377112337
|
||||
implements MigrationInterface
|
||||
{
|
||||
name = 'AddDiscountValueToVoucher1728377112337';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "vip_codes" ADD "discount_value" numeric`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "vip_codes" ALTER COLUMN "discount" DROP NOT NULL`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "vip_codes" ALTER COLUMN "discount" SET NOT NULL`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "vip_codes" DROP COLUMN "discount_value"`,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -51,12 +51,6 @@ export class PosTransactionHandler implements IEventHandler<ChangeDocEvent> {
|
|||
},
|
||||
});
|
||||
|
||||
const taxes = await this.taxService.getManyByOptions({
|
||||
where: {
|
||||
status: STATUS.ACTIVE,
|
||||
},
|
||||
});
|
||||
|
||||
const queryRunner = this.dataService
|
||||
.getRepository()
|
||||
.manager.connection.createQueryRunner();
|
||||
|
|
|
@ -189,11 +189,19 @@ export function mappingRevertTransaction(data, type) {
|
|||
const total_share_tenant =
|
||||
share_margin > 0 ? (Number(share_margin) / 100) * total_price : 0;
|
||||
|
||||
const bundlingTotalPrice =
|
||||
(item.item?.bundling_items?.reduce(
|
||||
(a, b) => a + Number(b.item_rates ?? b.base_price),
|
||||
0,
|
||||
) ?? 0) * +item.qty;
|
||||
const totalAndBundlingRatio = total_price / bundlingTotalPrice;
|
||||
item.bundling_items = item.item.bundling_items?.map((bundling) => {
|
||||
if (bundling.item_id) return bundling;
|
||||
|
||||
const basePrice =
|
||||
(bundling.item_rates ?? bundling.base_price) * +item.qty;
|
||||
(bundling.item_rates ?? bundling.base_price) *
|
||||
+item.qty *
|
||||
totalAndBundlingRatio;
|
||||
const discount = discountPercent * basePrice;
|
||||
const total = basePrice - discount;
|
||||
|
||||
|
|
|
@ -12,11 +12,15 @@ export class VipCodeModel
|
|||
@Column('varchar', { name: 'code' })
|
||||
code: string;
|
||||
|
||||
@Column('integer', { name: 'discount' })
|
||||
@Column('integer', { name: 'discount', nullable: true })
|
||||
discount: number;
|
||||
|
||||
@Column('decimal', { nullable: true })
|
||||
discount_value: number;
|
||||
|
||||
@Column('varchar', { name: 'vip_category_id' })
|
||||
vip_category_id: string;
|
||||
|
||||
@ManyToOne(() => VipCategoryModel, (model) => model.vip_codes, {
|
||||
onDelete: 'CASCADE',
|
||||
onUpdate: 'CASCADE',
|
||||
|
|
|
@ -3,4 +3,5 @@ import { BaseEntity } from 'src/core/modules/domain/entities/base.entity';
|
|||
export interface VipCodeEntity extends BaseEntity {
|
||||
code: string;
|
||||
discount: number;
|
||||
discount_value?: number;
|
||||
}
|
||||
|
|
|
@ -16,12 +16,21 @@ export class VipCodeDto extends BaseDto implements VipCodeEntity {
|
|||
@ApiProperty({
|
||||
name: 'discount',
|
||||
type: Number,
|
||||
required: true,
|
||||
required: false,
|
||||
example: 85,
|
||||
})
|
||||
@IsNumber()
|
||||
discount: number;
|
||||
|
||||
@ApiProperty({
|
||||
name: 'discount_value',
|
||||
type: Number,
|
||||
required: false,
|
||||
example: 25000,
|
||||
})
|
||||
@IsNumber()
|
||||
discount_value: number;
|
||||
|
||||
@ApiProperty({
|
||||
name: 'vip_category',
|
||||
type: Object,
|
||||
|
|
Loading…
Reference in New Issue