add: transaction billing
This commit is contained in:
@@ -11,6 +11,9 @@ export class UpdatePriceProductDto {
|
||||
@IsNotEmpty()
|
||||
type: productType;
|
||||
|
||||
@IsNotEmpty()
|
||||
productType: string;
|
||||
|
||||
startDate: Date;
|
||||
|
||||
endDate: Date;
|
||||
|
||||
@@ -28,6 +28,11 @@ export class Product extends BaseModel {
|
||||
})
|
||||
basePrice: number;
|
||||
|
||||
@Column({
|
||||
default: 'prepaid',
|
||||
})
|
||||
type: string;
|
||||
|
||||
@ManyToOne(
|
||||
() => {
|
||||
return ProductSubCategories;
|
||||
|
||||
@@ -124,6 +124,7 @@ export class ProductService {
|
||||
status: it[5] == 'active' ? 'ACTIVE' : 'NOT ACTIVE',
|
||||
sub_categories: subCategories,
|
||||
supplier: supplierData,
|
||||
type: it[7] == 'postpaid' ? 'postpaid' : 'prepaid',
|
||||
});
|
||||
|
||||
return await this.productHistoryPrice.insert({
|
||||
@@ -355,12 +356,13 @@ export class ProductService {
|
||||
};
|
||||
}
|
||||
|
||||
async findOne(code: string) {
|
||||
async findOne(code: string, type: string) {
|
||||
try {
|
||||
return await this.productRepository.findOneOrFail({
|
||||
relations: ['supplier'],
|
||||
where: {
|
||||
code: code,
|
||||
type: type,
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
@@ -436,7 +438,7 @@ export class ProductService {
|
||||
code: string,
|
||||
updatePriceProductDto: UpdatePriceProductDto,
|
||||
) {
|
||||
const product = await this.findOne(code);
|
||||
const product = await this.findOne(code, updatePriceProductDto.productType);
|
||||
|
||||
await this.productHistoryPrice.insert({
|
||||
product: product,
|
||||
|
||||
Reference in New Issue
Block a user