Compare commits
No commits in common. "18dc15e442472f118ded01a65b600992d1da6fa0" and "411458fe4cb4e0ede12ae39d488d2390a4d5ab0b" have entirely different histories.
18dc15e442
...
411458fe4c
|
@ -1,25 +0,0 @@
|
||||||
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,6 +51,12 @@ export class PosTransactionHandler implements IEventHandler<ChangeDocEvent> {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const taxes = await this.taxService.getManyByOptions({
|
||||||
|
where: {
|
||||||
|
status: STATUS.ACTIVE,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const queryRunner = this.dataService
|
const queryRunner = this.dataService
|
||||||
.getRepository()
|
.getRepository()
|
||||||
.manager.connection.createQueryRunner();
|
.manager.connection.createQueryRunner();
|
||||||
|
|
|
@ -189,19 +189,11 @@ export function mappingRevertTransaction(data, type) {
|
||||||
const total_share_tenant =
|
const total_share_tenant =
|
||||||
share_margin > 0 ? (Number(share_margin) / 100) * total_price : 0;
|
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) => {
|
item.bundling_items = item.item.bundling_items?.map((bundling) => {
|
||||||
if (bundling.item_id) return bundling;
|
if (bundling.item_id) return bundling;
|
||||||
|
|
||||||
const basePrice =
|
const basePrice =
|
||||||
(bundling.item_rates ?? bundling.base_price) *
|
(bundling.item_rates ?? bundling.base_price) * +item.qty;
|
||||||
+item.qty *
|
|
||||||
totalAndBundlingRatio;
|
|
||||||
const discount = discountPercent * basePrice;
|
const discount = discountPercent * basePrice;
|
||||||
const total = basePrice - discount;
|
const total = basePrice - discount;
|
||||||
|
|
||||||
|
|
|
@ -12,15 +12,11 @@ export class VipCodeModel
|
||||||
@Column('varchar', { name: 'code' })
|
@Column('varchar', { name: 'code' })
|
||||||
code: string;
|
code: string;
|
||||||
|
|
||||||
@Column('integer', { name: 'discount', nullable: true })
|
@Column('integer', { name: 'discount' })
|
||||||
discount: number;
|
discount: number;
|
||||||
|
|
||||||
@Column('decimal', { nullable: true })
|
|
||||||
discount_value: number;
|
|
||||||
|
|
||||||
@Column('varchar', { name: 'vip_category_id' })
|
@Column('varchar', { name: 'vip_category_id' })
|
||||||
vip_category_id: string;
|
vip_category_id: string;
|
||||||
|
|
||||||
@ManyToOne(() => VipCategoryModel, (model) => model.vip_codes, {
|
@ManyToOne(() => VipCategoryModel, (model) => model.vip_codes, {
|
||||||
onDelete: 'CASCADE',
|
onDelete: 'CASCADE',
|
||||||
onUpdate: 'CASCADE',
|
onUpdate: 'CASCADE',
|
||||||
|
|
|
@ -3,5 +3,4 @@ import { BaseEntity } from 'src/core/modules/domain/entities/base.entity';
|
||||||
export interface VipCodeEntity extends BaseEntity {
|
export interface VipCodeEntity extends BaseEntity {
|
||||||
code: string;
|
code: string;
|
||||||
discount: number;
|
discount: number;
|
||||||
discount_value?: number;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,21 +16,12 @@ export class VipCodeDto extends BaseDto implements VipCodeEntity {
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
name: 'discount',
|
name: 'discount',
|
||||||
type: Number,
|
type: Number,
|
||||||
required: false,
|
required: true,
|
||||||
example: 85,
|
example: 85,
|
||||||
})
|
})
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
discount: number;
|
discount: number;
|
||||||
|
|
||||||
@ApiProperty({
|
|
||||||
name: 'discount_value',
|
|
||||||
type: Number,
|
|
||||||
required: false,
|
|
||||||
example: 25000,
|
|
||||||
})
|
|
||||||
@IsNumber()
|
|
||||||
discount_value: number;
|
|
||||||
|
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
name: 'vip_category',
|
name: 'vip_category',
|
||||||
type: Object,
|
type: Object,
|
||||||
|
|
Loading…
Reference in New Issue