41 lines
1.4 KiB
Plaintext
41 lines
1.4 KiB
Plaintext
|
module Workflow.CreditAccount where
|
||
|
|
||
|
import Daml.Finance.Interface.Account.Account qualified as Account (Credit(..), I, exerciseInterfaceByKey)
|
||
|
import Daml.Finance.Interface.Holding.Base qualified as Holding (I)
|
||
|
import Daml.Finance.Interface.Types.Common.Types (AccountKey(..), InstrumentKey)
|
||
|
import Daml.Finance.Interface.Util.Common (qty)
|
||
|
|
||
|
-- | Initiate / Accept template to credit a holding to an existing account.
|
||
|
template Request
|
||
|
with
|
||
|
account : AccountKey
|
||
|
-- ^ The account receiving the holding.
|
||
|
instrument : InstrumentKey
|
||
|
-- ^ The instrument to be credited.
|
||
|
amount : Decimal
|
||
|
-- ^ The number of units of the specified instrument to be credited.
|
||
|
where
|
||
|
signatory account.owner
|
||
|
observer account.custodian
|
||
|
|
||
|
ensure amount > 0.0
|
||
|
|
||
|
choice Accept : ContractId Holding.I
|
||
|
-- ^ Accept the request. In the case of physical assets (e.g. paper certificates, banknotes),
|
||
|
-- a custodian would generally accept the request once they have got hold of the physical
|
||
|
-- asset.
|
||
|
controller account.custodian
|
||
|
do
|
||
|
Account.exerciseInterfaceByKey @Account.I account account.custodian Account.Credit with
|
||
|
quantity = qty amount instrument
|
||
|
|
||
|
choice Decline : ()
|
||
|
-- ^ Decline the request.
|
||
|
controller account.custodian
|
||
|
do pure ()
|
||
|
|
||
|
choice Withdraw : ()
|
||
|
-- ^ Withdraw the request.
|
||
|
controller account.owner
|
||
|
do pure ()
|