35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import {
|
|
default_profit_formula,
|
|
default_sales_formula,
|
|
} from 'src/core/strings/constants/default-data.constants';
|
|
import { SalesPriceFormulaModel } from 'src/modules/transaction/sales-price-formula/data/models/sales-price-formula.model';
|
|
import { Connection } from 'typeorm';
|
|
import { Factory, Seeder } from 'typeorm-seeding';
|
|
|
|
export class SeedDefaultFormula implements Seeder {
|
|
public async run(factory: Factory, connection: Connection): Promise<void> {
|
|
try {
|
|
const sales_formula = new SalesPriceFormulaModel();
|
|
Object.assign(sales_formula, {
|
|
...default_sales_formula,
|
|
created_at: new Date().getTime(),
|
|
updated_at: new Date().getTime(),
|
|
});
|
|
|
|
const profit_formula = new SalesPriceFormulaModel();
|
|
Object.assign(profit_formula, {
|
|
...default_profit_formula,
|
|
created_at: new Date().getTime(),
|
|
updated_at: new Date().getTime(),
|
|
});
|
|
|
|
await connection
|
|
.createQueryBuilder()
|
|
.insert()
|
|
.into(SalesPriceFormulaModel)
|
|
.values([sales_formula, profit_formula])
|
|
.execute();
|
|
} catch (error) {}
|
|
}
|
|
}
|