Daml Finance - InstrumentQuantity : How to access sub parameters like, unit, quantity etc

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 >100

both 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

Hi @Ashok_Raj,

I believe it should be

given that

  • amount is of type Decimal rather than Int
  • we need to evaluate the predicate before we call assert, hence the $ operator