Skip to content

Commit d752bda

Browse files
committed
Minor refactoring
1 parent 5cc57d4 commit d752bda

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

components/quickbooks/sources/common.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,28 +81,26 @@ module.exports = {
8181
await this.processEvent(entity);
8282
},
8383
async processEvent(entity) {
84-
const {name, id, operation} = entity
84+
const {name, id, operation, lastUpdated} = entity
85+
// Unless the record has been deleted, use the id received in the webhook
86+
// to get the full record data
8587
const eventToEmit = {
8688
event_notification: entity,
87-
record_details: {},
89+
record_details: operation === "Delete"
90+
? {}
91+
: await this.quickbooks.getRecordDetails(name, id),
8892
};
89-
// Unless the record has been deleted, use the id received in the webhook
90-
// to get the full record data
91-
if (entity.operation !== "Delete") {
92-
eventToEmit.record_details = await this.quickbooks
93-
.getRecordDetails(name, id);
94-
}
93+
9594
const summary = `${name} ${id} ${this.toPastTense(operation)}`;
96-
const ts = entity?.lastUpdated
97-
? Date.parse(entity.lastUpdated)
95+
const ts = lastUpdated
96+
? Date.parse(lastUpdated)
9897
: Date.now();
9998
const event_id = [
10099
name,
101100
id,
102101
operation,
103102
ts,
104103
].join("-");
105-
console.log(event_id)
106104
this.$emit(eventToEmit, {
107105
id: event_id,
108106
summary,

0 commit comments

Comments
 (0)