Akkount example question

Hello,

In the akkount example https://github.com/cuba-platform/sample-akkount:


public BigDecimal getBalance(final UUID accountId, final Date date) 

I don’t understand (the purpose) why do you use final Date date. When do we provide different dates? It’s used only currentTimestamp() that return current date.
The App works without final Date date as well.

Please advise.
-n

Hi,
The service is capable of calculating balance for any date. The client sends current date as a parameter to the service. This is how the app works.

Doesn’t work(see below). Maybe you refer to …Report by categories.
image

Is there any possibility to convey the (new modified) date (from the generic filter) to middleware (persistence Interface) or the only solution is to use dataManager in UIController?
The goal is to modify the Balance and accounts accordingly to date filter.

Maybe I can use something like

public BigDecimal getBalance(final UUID accountId, final Date startdate, final Date enddate)

and pass parameters.

You can obtain current values of filter parameters, see the docs.

Hello,

I’ve chosen to use my own dateField(s).
I use this query:

select e from myEntity e where e.date >= :start and e.date<=:end

Unfortunately if I delete (manually) the (end) date and apply the filter again I have this error:
Caused by: com.haulmont.cuba.core.global.DevelopmentException:Parameter end is not used in the query at com.haulmont.cuba.core.app.JpqlQueryBuilder.getQuery(JpqlQueryBuilder.java:188) ~[na:na] at com.haulmont.cuba.core.app.RdbmsStore.createQuery(RdbmsStore.java:713) ~[na:na] at com.haulmont.cuba.core.app.RdbmsStore.loadList(RdbmsStore.java:231) ~[na:na] at com.haulmont.cuba.core.app.DataManagerBean.loadList(DataManagerBean.java:78) ~[na:na] at com.haulmont.cuba.core.app.DataServiceBean.loadList(DataServiceBean.java:54) ~[na:na] at sun.reflect.GeneratedMethodAccessor133.invoke(Unknown Source) ~[na:na] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_221] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_221] at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) ~[spring-aop-5.1.6.RELEASE.jar:5.1.6.RELEASE] ...etc
Could be the same issue with:

Is there any workaround?
I use platform 7.1.1

Yes, use Query conditions.

Can you help me please with the same example using setCondition(programatically)?
Now if I delete (manually) the (end) date and apply the filter again, I don’t have any errors but myentityDl.load() doesn’t work.

It works now (I put myentityDl.load() in the wrong place).

For those who are interested: the example has been updated, the mobile-friendly UI has been reimplemented in React.
See GitHub - cuba-platform/sample-akkount-cuba7: A simple personal finance application

2 Likes