summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2023-06-15 15:07:24 +0700
committerstephanchrst <stephanchrst@gmail.com>2023-06-15 15:07:24 +0700
commitd32accf86a2baffcf7ce90554d1f8868ab518cf4 (patch)
treef321570f28647aba7710892750d291ca880fb902 /indoteknik_custom/models
parent64507a0c199721fee5e3fc8c808adec5a3ee6a5d (diff)
change logic of sales monitoring
Diffstat (limited to 'indoteknik_custom/models')
-rwxr-xr-xindoteknik_custom/models/sale_monitoring.py16
-rwxr-xr-xindoteknik_custom/models/sale_monitoring_detail.py16
2 files changed, 12 insertions, 20 deletions
diff --git a/indoteknik_custom/models/sale_monitoring.py b/indoteknik_custom/models/sale_monitoring.py
index ea1e490c..e79ff9ab 100755
--- a/indoteknik_custom/models/sale_monitoring.py
+++ b/indoteknik_custom/models/sale_monitoring.py
@@ -39,16 +39,12 @@ class SaleMonitoring(models.Model):
SUM(smd.qty_so_invoiced) AS qty_so_invoiced,
sum(smd.qty_reserved) as qty_reserved,
CASE
- WHEN SUM(qty_so) = SUM(qty_reserved) then 'SIAP KIRIM'
- WHEN SUM(qty_so) = SUM(qty_so_delivered) then 'Delivered'
- WHEN SUM(qty_so) = SUM(qty_so_invoiced) then 'Done'
- WHEN SUM(qty_reserved) < SUM(qty_so) and SUM(qty_reserved) > 0 THEN 'Belum PO full'
- WHEN SUM(qty_reserved) = SUM(qty_so) THEN 'Belum PO sama sekali'
- WHEN SUM(qty_po_received) < SUM(qty_so) AND SUM(qty_po_received) <= 0 THEN 'Belum Received sama sekali'
- WHEN SUM(qty_po_received) < SUM(qty_so) THEN 'Belum Received full'
- WHEN SUM(qty_to_delivered) = SUM(qty_so) THEN 'SIAP KIRIM'
- WHEN SUM(qty_to_delivered) < SUM(qty_so) and SUM(qty_to_delivered) > 0 THEN 'KIRIM SISANYA'
- ELSE 'Belum Invoiced'
+ when sum(qty_so_invoiced) = sum(qty_so) then 'Invoiced'
+ when sum(qty_so_delivered) = sum(qty_so) then 'Delivered'
+ when sum(qty_reserved) >= sum(qty_so) then 'Siap kirim'
+ when sum(qty_po) + sum(qty_reserved) - sum(qty_po_received) < sum(qty_so) then 'Belum/Kurang PO'
+ when sum(qty_po_received) = 0 then 'Belum terima'
+ when sum(qty_po_received) < sum(qty_po) then 'Terima sebagian'
END AS status,
get_po_number(smd.sale_order_id) as po_number
FROM sale_monitoring_detail smd
diff --git a/indoteknik_custom/models/sale_monitoring_detail.py b/indoteknik_custom/models/sale_monitoring_detail.py
index 908ccb68..2bcda50c 100755
--- a/indoteknik_custom/models/sale_monitoring_detail.py
+++ b/indoteknik_custom/models/sale_monitoring_detail.py
@@ -30,16 +30,12 @@ class SaleMonitoringDetail(models.Model):
SELECT
*,
CASE
- WHEN qty_so = qty_reserved then 'SIAP KIRIM'
- WHEN qty_so = qty_so_delivered then 'Delivered'
- WHEN qty_so = qty_so_invoiced then 'Done'
- WHEN qty_reserved < qty_so and qty_reserved > 0 THEN 'Belum PO full'
- WHEN qty_reserved = qty_so THEN 'Belum PO sama sekali'
- WHEN qty_po_received < qty_so and qty_po_received <= 0 THEN 'Belum Received sama sekali'
- WHEN qty_po_received < qty_so THEN 'Belum Received full'
- WHEN qty_to_delivered = qty_so THEN 'SIAP KIRIM'
- WHEN qty_to_delivered < qty_so and qty_to_delivered > 0 THEN 'KIRIM SISANYA'
- ELSE 'Belum Invoiced'
+ when qty_so_invoiced = qty_so then 'Invoiced'
+ when qty_so_delivered = qty_so then 'Delivered'
+ when qty_reserved >= qty_so then 'Siap kirim'
+ when qty_po + qty_reserved - qty_po_received < qty_so then 'Belum/Kurang PO'
+ when qty_po_received = 0 then 'Belum terima'
+ when qty_po_received < qty_po then 'Terima sebagian'
END AS status
FROM
(