Compare commits

..

No commits in common. "18dc15e442472f118ded01a65b600992d1da6fa0" and "411458fe4cb4e0ede12ae39d488d2390a4d5ab0b" have entirely different histories.

6 changed files with 9 additions and 50 deletions

View File

@ -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"`,
);
}
}

View File

@ -51,6 +51,12 @@ export class PosTransactionHandler implements IEventHandler<ChangeDocEvent> {
},
});
const taxes = await this.taxService.getManyByOptions({
where: {
status: STATUS.ACTIVE,
},
});
const queryRunner = this.dataService
.getRepository()
.manager.connection.createQueryRunner();

View File

@ -189,19 +189,11 @@ 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 *
totalAndBundlingRatio;
(bundling.item_rates ?? bundling.base_price) * +item.qty;
const discount = discountPercent * basePrice;
const total = basePrice - discount;

View File

@ -12,15 +12,11 @@ export class VipCodeModel
@Column('varchar', { name: 'code' })
code: string;
@Column('integer', { name: 'discount', nullable: true })
@Column('integer', { name: 'discount' })
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',

View File

@ -3,5 +3,4 @@ import { BaseEntity } from 'src/core/modules/domain/entities/base.entity';
export interface VipCodeEntity extends BaseEntity {
code: string;
discount: number;
discount_value?: number;
}

View File

@ -16,21 +16,12 @@ export class VipCodeDto extends BaseDto implements VipCodeEntity {
@ApiProperty({
name: 'discount',
type: Number,
required: false,
required: true,
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,