Skip to content

Commit

Permalink
When a deal exists for paid transaction, close it, otherwise create it.
Browse files Browse the repository at this point in the history
  • Loading branch information
thesoftwarephilosopher committed Aug 25, 2021
1 parent e2274af commit c6788ba
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions lib/engine/generate-deals.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,29 @@ function generateDealActions(data) {
}
}
else {
dealCreateActions.push({
dealstage: DealStage.CLOSED_WON,
license: firstFoundPaid,
transactions: transactions,
amount: (price ?? 0).toFixed(2),
})
if (deal) {
// Only close/update evals, leave closed deals alone
if (deal.properties.dealstage === DealStage.EVAL) {
dealUpdateActions.push({
id: deal.id,
license: firstFoundPaid,
transactions,
properties: {
addonlicenseid: firstFoundPaid.addonLicenseId,
dealstage: DealStage.CLOSED_WON,
...(price && { amount: price.toFixed(2) }),
},
});
}
}
else {
dealCreateActions.push({
dealstage: DealStage.CLOSED_WON,
license: firstFoundPaid,
transactions: transactions,
amount: (price ?? 0).toFixed(2),
});
}
}
}

Expand Down

0 comments on commit c6788ba

Please sign in to comment.