40
loading...
This website collects cookies to deliver better user experience
const CashRegisterService = {
async register(data) {
const t = await sequelize.transaction();
data.map(register => {
let cashRegister = await CashRegister.upsert(register, {transaction: t})
if(!cashRegister) {
throw new Error('Error when trying populate Cash Register')
}
this.associateProductLine(cashRegister[0], {...register, t});
this.associateTreatmentLine(cashRegister[0], {...register, t});
})
t.commit();
}
}
const CashRegisterService = {
async register(data) {
const t = await sequelize.transaction();
data.map(register => {
let cashRegister = await CashRegister.upsert(register, {transaction: t})
if(!cashRegister) {
throw new Error('Error when trying populate Cash Register')
}
await this.associateProductLine(cashRegister[0], {...register, t});
await this.associateTreatmentLine(cashRegister[0], {...register, t});
})
t.commit();
}
}
const CashRegisterService = {
async register(data) {
const t = await sequelize.transaction();
await Promise.all(data.map(register => {
let cashRegister = await CashRegister.upsert(register, {transaction: t})
if(!cashRegister) {
throw new Error('Error when trying populate Cash Register')
}
await this.associateProductLine(cashRegister[0], {...register, t});
await this.associateTreatmentLine(cashRegister[0], {...register, t});
}))
t.commit();
}
}
const CashRegisterService = {
async register(data) {
const t = await sequelize.transaction();
await Promise.all(data.map(register => {
let cashRegister = await CashRegister.upsert(register, {transaction: t})
if(!cashRegister) {
throw new Error('Error when trying populate Cash Register')
}
await this.associateProductLine(cashRegister[0], register);
await this.associateTreatmentLine(cashRegister[0], {...register, t});
})).then(async result => {
await t.commit();
}).catch(async error => {
await t.rollback();
throw error;
})
}
}