mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-06-09 15:07:49 +00:00
add adjustment depresiasi calculation and percentage depresiasi
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
-- Recalculate laying_transfers.economic_cutoff_date dari rule 19 minggu (lama) ke 25 minggu (baru,
|
||||
-- sejalan dengan depreciation_start_age_day = 175). Semua transfer historis yang punya
|
||||
-- source_project_flock_kandang_id akan di-update agar economic_cutoff_date = source.chick_in_date + 175 hari.
|
||||
|
||||
BEGIN;
|
||||
|
||||
UPDATE laying_transfers lt
|
||||
SET economic_cutoff_date = sub.cutoff_date,
|
||||
updated_at = NOW()
|
||||
FROM (
|
||||
SELECT
|
||||
lt2.id AS transfer_id,
|
||||
(MIN(pc.chick_in_date)::date + INTERVAL '175 days')::date AS cutoff_date
|
||||
FROM laying_transfers lt2
|
||||
JOIN project_chickins pc ON pc.project_flock_kandang_id = lt2.source_project_flock_kandang_id
|
||||
WHERE lt2.deleted_at IS NULL
|
||||
AND lt2.source_project_flock_kandang_id IS NOT NULL
|
||||
AND pc.deleted_at IS NULL
|
||||
GROUP BY lt2.id
|
||||
) sub
|
||||
WHERE lt.id = sub.transfer_id
|
||||
AND lt.deleted_at IS NULL;
|
||||
|
||||
COMMIT;
|
||||
Reference in New Issue
Block a user