Billing: Add possibility to automatically add business shares

This commit is contained in:
2024-01-17 18:59:25 +01:00
parent 668eb9a2d0
commit b52c09a176
13 changed files with 116 additions and 19 deletions

View File

@ -52,7 +52,7 @@ namespace Elwig.Helpers.Billing {
ROUND(
IIF({Data.ConsiderContractPenalties}, COALESCE(u.total_penalty, 0) / POW(10, 4 - 2), 0) +
IIF({Data.ConsiderTotalPenalty}, COALESCE(b.total_penalty, 0), 0) +
IIF({Data.ConsiderAutoBusinessShares}, 0, 0)
IIF({Data.ConsiderAutoBusinessShares}, -COALESCE(a.business_shares * s.bs_value, 0), 0) / POW(10, s.precision - 2)
) AS modifiers,
lc.modifiers AS prev_modifiers
FROM season s
@ -84,6 +84,11 @@ namespace Elwig.Helpers.Billing {
FROM v_total_under_delivery u
JOIN season s ON s.year = u.year
WHERE u.diff < 0) b ON (b.year, b.mgnr) = (s.year, m.mgnr)
LEFT JOIN (SELECT h.mgnr, h.business_shares
FROM member_history h
WHERE type = 'auto' AND
date >= '{Year}-06-01' AND
date < '{Year + 1}-06-01') a ON a.mgnr = m.mgnr
WHERE s.year = {Year} AND v.avnr = {AvNr};
UPDATE payment_variant SET test_variant = FALSE WHERE (year, avnr) = ({Year}, {AvNr});