Skip to content

Commit 436412b

Browse files
committed
WIP
1 parent c6d7120 commit 436412b

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

dbschema/project.esdl

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,16 @@ module default {
156156

157157
trigger addRemovePeriodicReports after update for each
158158
when (
159-
__old__.mouStart != __new__.mouStart
160-
or __old__.mouEnd != __new__.mouEnd
161-
or __old__.financialReportPeriod != __new__.financialReportPeriod
159+
__old__.mouStart ?!= __new__.mouStart
160+
or __old__.mouEnd ?!= __new__.mouEnd
161+
or __old__.financialReportPeriod ?!= __new__.financialReportPeriod
162162
)
163163
do (
164164
with
165-
existingReportPeriods := (
166-
select FinancialReport
165+
existingReports := (
166+
select PeriodicReport
167167
filter .container.id = __old__.id
168-
).period,
168+
),
169169
interval := (
170170
select (if __new__.financialReportPeriod = default::ReportPeriod.Monthly then '1' else '3')
171171
),
@@ -174,13 +174,13 @@ module default {
174174
__new__.mouEnd,
175175
interval
176176
)
177-
if __old__.financialReportPeriod != __new__.financialReportPeriod (
177+
select (if __old__.financialReportPeriod ?!= __new__.financialReportPeriod then (
178178
with
179179
reportPeriodsWithoutFiles := (
180-
select existingReportPeriods
180+
select existingReports
181181
filter not exists .reportFile
182182
),
183-
deletedReportPeriods : = (
183+
deletedReportPeriods := (
184184
for reportPeriod in reportPeriodsWithoutFiles
185185
union (
186186
delete reportPeriod
@@ -213,14 +213,14 @@ module default {
213213
with
214214
requestedReportPeriodsForInsertion := (
215215
select requestedReportPeriods
216-
filter requestedReportPeriods not in existingReportPeriods
216+
filter requestedReportPeriods not in existingReports.period
217217
),
218218
requestedReportPeriodsForDeletion := (
219-
select existingReportPeriods
220-
filter existingReportPeriods not in requestedReportPeriods
219+
select existingReports.period
220+
filter existingReports.period not in requestedReportPeriods
221221
),
222-
applicableReportPeriodsForDeletion := (
223-
select PeriodicReport[is FinancialReport | NarrativeReport]
222+
applicableReportsForDeletion := (
223+
select PeriodicReport
224224
filter .period in requestedReportPeriodsForDeletion
225225
and not exists .reportFile
226226
),
@@ -247,11 +247,13 @@ module default {
247247
period := reportPeriod
248248
})
249249
))
250-
for reportPeriod in applicableReportPeriodsForDeletion
250+
for report in applicableReportsForDeletion
251251
union (
252-
delete reportPeriod
252+
delete report
253+
# filter report is typeof default::FinancialReport
254+
# or report is typeof default::NarrativeReport
253255
)
254-
)
256+
))
255257
);
256258
}
257259

0 commit comments

Comments
 (0)