Skip to content

Commit

Permalink
Generalise helper
Browse files Browse the repository at this point in the history
  • Loading branch information
rexcfnghk committed Sep 30, 2024
1 parent 537d55d commit 9a0acba
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Q3/daml/LoanWorkflowWithRepayment.daml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ createTokenForChange minter owner repayment tokens =
else Some $ Token with value = totalTokenValue - repayment; ..
where totalTokenValue = tokenValue tokens

addChangeToDisbursements : Optional (ContractId Token) -> [ContractId Token] -> [ContractId Token]
-- Only add to disbursements when there is a change
addChangeToDisbursements : Optional a -> [a] -> [a]
addChangeToDisbursements (Some cid) = (cid ::)
addChangeToDisbursements None = identity

Expand Down Expand Up @@ -119,7 +120,7 @@ template Loan
existingDisbursements <- getDisbursementMap disbursementCids

let existingDisbursementTotal = tokenValue $ values existingDisbursements
let newDisbursementTotal = amount + existingDisbursementTotal
newDisbursementTotal = amount + existingDisbursementTotal

assertMsg "Total disbursement amount cannot be more than approved amount" (newDisbursementTotal <= approvedAmount)

Expand Down

0 comments on commit 9a0acba

Please sign in to comment.