Daml Finance - InstrumentQuantity : How to access sub parameters like, unit, quantity etc
- Ashok_RajOP
In Daml finance, InstrumentQuantity is a common type that’s used for capturing both the unit and amount, like in case of issuance request to specify the requested quantity. I want to use a variable of that type in a service and make checks like if the requested quantity is above a certain value. I tried the following.
CreateAuditedIssuanceRequest{id; description; account; quantity; quantityAudited} <- fetchAndArchive createAuditedIssuanceRequestCid assert quantity.amount > quantityAudited.amount assert quantity.unit.id == quantityAudited.unit.id assert quantity.amount > 100 assert quantity >100both quantityAudited and quantity are of type InstrumentQuantity.
I got a lot of errors related to trying to access nonexistent field. and type mismatch. Can you point me in the right direction
- Matteo_Limberto
Hi @Ashok_Raj,
I believe it should be
Ashok_Raj:assert $ quantity.amount > 100.0given that
amountis of typeDecimalrather thanInt- we need to evaluate the predicate before we call
assert, hence the$operator