How to access payment item name

The Description field of financal transactions is mostly unused. I am going through the various archetypes setting the derived expression to give something useful to show on the Customers|Accounts screen. For example setting "concat(openvpms:get(.,'location.entity.name'),'/',openvpms:get(.,'clinician.entity.name'))" for the act.customerAccountChargesInvoice archetype is useful to us.

For payments I would like to show the till and the payment type of the first item. The first (the till) is easy, but I am having difficuty with the second. I tried openvpms:get(.,'items[0].target.name') and also openvpms:get(.,'items[1].target.name') but both of these cause errors.

Is there a syntax that will allow me to get the name field of the first payment item?

Regards, Tim G

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: How to access payment item name

There's a few problems with this:

  • the [1] notation is not supported via openvpms:get(), as the collections are unordered; you wouldn't be guaranteed the same item on subsequent calls. You need to use the xpath [] operator instead. This has the same limitation however.
  • the order of derived value evaluation and the save of the items is not guaranteed. So the derived value of the Payment description may be evaluated prior to the first item being saved, or after.

If you aren't concerned with this, the following should work some of the time:

 openvpms:get(openvpms:get(.,'items')[1],'target.name')

-Tim A

Re: How to access payment item name

Tim - thanks for the prompt reply. However, you are correct - the evaluation order is killing me.

I also tried to be clever and prempt Jira-1360 by including the id of the transaction in the description, but since the description is derived before the transaction is written (and thus gets a id number), the id comes out -1.

So I will give up the idea of putting the payment type of the 1st item in the description - after all if you click on the item, you get shown its details and can thus see the payment types.

I thus have the following descriptions being generated:

Transaction Description
Invoice location/clinician
Counter Sale location/author/notes
Credit Note location/clinician
Payment till/author
Refund till/author/notes
Bad Debt Adjustment location/author/notes
Credit Adjustment author/notes
Debit Adjustment author/notes

Thanks for the assist, Regards, Tim G

Syndicate content