reintroduced update for draft order

This commit is contained in:
--list
2021-06-17 10:40:16 +02:00
parent 0223b89a73
commit cc430e3f4d
2 changed files with 25 additions and 20 deletions

View File

@@ -206,4 +206,9 @@ describe("DraftOrderService", () => {
})
})
describe("update", () => {
fail('implement tests for update');
})
})

View File

@@ -338,33 +338,33 @@ class DraftOrderService extends BaseService {
})
}
/**
*
* @param {String} doId
* @param {} data
* @returns
* Updates a draft order with the given data
* @param {String} doId - id of the draft order
* @param {DraftOrder} data - values to update the order with
* @returns {Promise<DraftOrder>} the updated draft order
*/
async update(doId, data){
return this.atomicPhase_(async manager => {
// const doRepo = manager.getCustomRepository(this.draftOrderRepository_)
// const draftOrder = await this.retrieve(doId)
// let touched = false
const doRepo = manager.getCustomRepository(this.draftOrderRepository_)
const draftOrder = await this.retrieve(doId)
let touched = false
// if(data.no_notification_order !== undefined){
// touched = true
// draftOrder.no_notification_order = data.no_notification_order
// }
if(data.no_notification_order !== undefined){
touched = true
draftOrder.no_notification_order = data.no_notification_order
}
// if(touched){
// doRepo.save(draftOrder)
if(touched){
doRepo.save(draftOrder)
// await this.eventBus_
// .withTransaction(manager)
// .emit(DraftOrderService.Events.UPDATED, {
// id: draftOrder.id
// })
// }
await this.eventBus_
.withTransaction(manager)
.emit(DraftOrderService.Events.UPDATED, {
id: draftOrder.id
})
}
// return draftOrder
return draftOrder
})
}
}