...
Create a policy_balance table with those columns per “benefit”
type
numberOf
amount
periodicity
benefit detail name (visit hospital … )
Type
Item
service
policy limits
id
id of item/service
OR limits type (new table ?)
insuree id(only for limits that are personnal)
benefit id (policy)
date of validity (policy end date) ??
balance (actually approved)
provisional (submitted claim)
temporary (draft claim)
limits
...
For all policy,
for all insuree covered by policy
get all claim details covered by policy (column in item and services)
update the common limits
update the individual limit
save limits for item and service that have limits (date or number , 2 limits if both)
save all cached enquiry
Schedule task to update
...