summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFIN-IT_AndriFP <andrifebriyadiputra@gmail.com>2025-12-09 15:47:21 +0700
committerFIN-IT_AndriFP <andrifebriyadiputra@gmail.com>2025-12-09 15:47:21 +0700
commitdb3243fc53d45c355bd9ad75ca4f58bf0e0acbee (patch)
treeb20b6972f70bbc0a52a7d88eb7c521ecf0a443a6
parent9351e3cf2297d992f407a91a0b1d183997a43f81 (diff)
(andri) status po to mr berdasarkan target tiap category product
-rw-r--r--calculate_leadtime_po_to_mr.ktr210
1 files changed, 199 insertions, 11 deletions
diff --git a/calculate_leadtime_po_to_mr.ktr b/calculate_leadtime_po_to_mr.ktr
index 5067a75..d5c0904 100644
--- a/calculate_leadtime_po_to_mr.ktr
+++ b/calculate_leadtime_po_to_mr.ktr
@@ -486,6 +486,57 @@
</attribute>
</attributes>
</connection>
+ <connection>
+ <name>dw bi indoteknik (localhost)</name>
+ <server>localhost</server>
+ <type>POSTGRESQL</type>
+ <access>Native</access>
+ <database>dw_bi_indoteknik</database>
+ <port>5432</port>
+ <username>postgres</username>
+ <password>Encrypted 2be98afc86aa7f2e4cb79ce10bec3fd89</password>
+ <servername/>
+ <data_tablespace/>
+ <index_tablespace/>
+ <attributes>
+ <attribute>
+ <code>FORCE_IDENTIFIERS_TO_LOWERCASE</code>
+ <attribute>N</attribute>
+ </attribute>
+ <attribute>
+ <code>FORCE_IDENTIFIERS_TO_UPPERCASE</code>
+ <attribute>N</attribute>
+ </attribute>
+ <attribute>
+ <code>IS_CLUSTERED</code>
+ <attribute>N</attribute>
+ </attribute>
+ <attribute>
+ <code>PORT_NUMBER</code>
+ <attribute>5432</attribute>
+ </attribute>
+ <attribute>
+ <code>PRESERVE_RESERVED_WORD_CASE</code>
+ <attribute>Y</attribute>
+ </attribute>
+ <attribute>
+ <code>QUOTE_ALL_FIELDS</code>
+ <attribute>N</attribute>
+ </attribute>
+ <attribute>
+ <code>SUPPORTS_BOOLEAN_DATA_TYPE</code>
+ <attribute>Y</attribute>
+ </attribute>
+ <attribute>
+ <code>SUPPORTS_TIMESTAMP_DATA_TYPE</code>
+ <attribute>N</attribute>
+ </attribute>
+ <attribute>
+ <code>USE_POOLING</code>
+ <attribute>N</attribute>
+ </attribute>
+ </attributes>
+ </connection>
<order>
<hop>
<from>Table input</from>
@@ -693,16 +744,58 @@
<jsScript>
<jsScript_type>0</jsScript_type>
<jsScript_name>Script 1</jsScript_name>
- <jsScript_script>//Script here
-var po_to_arrival_status = 'not achieve';
-if (new_po_to_arrival &lt;= 48)
-{
- po_to_arrival_status = 'achieve'
+ <jsScript_script>var target_limit = 59; // Set Default Target
+
+var cat = parent_category;
+if (cat == null) {
+ cat = "";
}
-else{
- po_to_arrival_status = 'not achieve'
+
+switch (cat) {
+ case "Cairan Berbahan Kimia":
+ case "Komponen &amp; Aksesoris":
+ case "Mesin Industrial":
+ target_limit = 46;
+ break;
+
+ case "Pengaman, Kesehatan &amp; Keamanan":
+ case "Peralatan Horeca &amp; Food Service":
+ target_limit = 66;
+ break;
+
+ case "Mesin Pembersih &amp; Janitorial":
+ target_limit = 99;
+ break;
+ case "Mesin Pertanian &amp; Perkebunan":
+ target_limit = 56;
+ break;
+ case "Peralatan Kantor &amp; Stationery":
+ target_limit = 95;
+ break;
+ case "Peralatan Listrik &amp; Elektronik":
+ target_limit = 71;
+ break;
+ case "Perkakas Tangan, Listrik &amp; Pneumatic":
+ target_limit = 33;
+ break;
+ case "Perlengkapan Logistik &amp; Gudang":
+ target_limit = 62;
+ break;
+ case "Perlengkapan Pengukuran &amp; Pengujian":
+ target_limit = 41;
+ break;
+
+ // --- DEFAULT () ---
+ default:
+ target_limit = 59;
}
-</jsScript_script>
+
+var po_to_arrival_status = 'not achieve';
+if (new_po_to_arrival != null) {
+ if (Math.floor(new_po_to_arrival) &lt; target_limit) {
+ po_to_arrival_status = 'achieve';
+ }
+}</jsScript_script>
</jsScript>
</jsScripts>
<fields>
@@ -786,18 +879,27 @@ else{
<fields>
<field>
<name>po_confirm_date</name>
+ <rename/>
</field>
<field>
<name>received_good_date</name>
+ <rename/>
</field>
<field>
<name>purchase_line_id</name>
+ <rename/>
</field>
<field>
<name>purchase_id</name>
+ <rename/>
</field>
<field>
<name>received_id</name>
+ <rename/>
+ </field>
+ <field>
+ <name>parent_category</name>
+ <rename/>
</field>
<select_unspecified>N</select_unspecified>
</fields>
@@ -829,21 +931,31 @@ else{
<fields>
<field>
<name>po_confirm_date</name>
+ <rename/>
</field>
<field>
<name>received_good_date</name>
+ <rename/>
</field>
<field>
<name>purchase_line_id</name>
+ <rename/>
</field>
<field>
<name>purchase_id</name>
+ <rename/>
</field>
<field>
<name>new_po_to_arrival</name>
+ <rename/>
</field>
<field>
<name>received_id</name>
+ <rename/>
+ </field>
+ <field>
+ <name>parent_category</name>
+ <rename/>
</field>
<select_unspecified>N</select_unspecified>
</fields>
@@ -1096,7 +1208,7 @@ else{
<schema_name/>
</partitioning>
<connection>dw bi indoteknik (localhost)</connection>
- <sql>select po_confirm_date, received_good_date, purchase_line_id, purchase_id, received_id
+ <sql>select po_confirm_date, received_good_date, purchase_line_id, purchase_id, received_id, parent_category
from mv_leadtime_po_to_received
--where purchase_id = 24864 and purchase_line_id = 140704 and received_id in (76715)</sql>
<limit>0</limit>
@@ -1107,7 +1219,7 @@ from mv_leadtime_po_to_received
<cached_row_meta_active>N</cached_row_meta_active>
<row-meta>
<value-meta>
- <type>Timestamp</type>
+ <type>Date</type>
<storagetype>normal</storagetype>
<name>po_confirm_date</name>
<length>6</length>
@@ -1130,7 +1242,7 @@ from mv_leadtime_po_to_received
<lenient_string_to_number>N</lenient_string_to_number>
</value-meta>
<value-meta>
- <type>Timestamp</type>
+ <type>Date</type>
<storagetype>normal</storagetype>
<name>received_good_date</name>
<length>6</length>
@@ -1221,6 +1333,29 @@ from mv_leadtime_po_to_received
<date_format_timezone>Asia/Bangkok</date_format_timezone>
<lenient_string_to_number>N</lenient_string_to_number>
</value-meta>
+ <value-meta>
+ <type>String</type>
+ <storagetype>normal</storagetype>
+ <name>parent_category</name>
+ <length>2147483647</length>
+ <precision>-1</precision>
+ <origin>Table input</origin>
+ <comments>parent_category</comments>
+ <conversion_Mask/>
+ <decimal_symbol>.</decimal_symbol>
+ <grouping_symbol>,</grouping_symbol>
+ <currency_symbol/>
+ <trim_type>none</trim_type>
+ <case_insensitive>N</case_insensitive>
+ <collator_disabled>Y</collator_disabled>
+ <collator_strength>0</collator_strength>
+ <sort_descending>N</sort_descending>
+ <output_padding>N</output_padding>
+ <date_format_lenient>N</date_format_lenient>
+ <date_format_locale>en_US</date_format_locale>
+ <date_format_timezone>Asia/Bangkok</date_format_timezone>
+ <lenient_string_to_number>N</lenient_string_to_number>
+ </value-meta>
</row-meta>
<attributes/>
<cluster_schema/>
@@ -1430,6 +1565,59 @@ FROM filtered_hours;</sql>
<draw>Y</draw>
</GUI>
</step>
+ <step>
+ <name>Modified JavaScript value 2</name>
+ <type>ScriptValueMod</type>
+ <description/>
+ <distribute>Y</distribute>
+ <custom_distribution/>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <compatible>N</compatible>
+ <optimizationLevel>9</optimizationLevel>
+ <jsScripts>
+ <jsScript>
+ <jsScript_type>0</jsScript_type>
+ <jsScript_name>Script 1</jsScript_name>
+ <jsScript_script>//Script here
+var po_to_arrival_status = 'not achieve';
+if (new_po_to_arrival &lt;= 48)
+{
+ po_to_arrival_status = 'achieve'
+}
+else{
+ po_to_arrival_status = 'not achieve'
+}
+</jsScript_script>
+ </jsScript>
+ </jsScripts>
+ <fields>
+ <field>
+ <name>po_to_arrival_status</name>
+ <rename>po_to_arrival_status</rename>
+ <type>String</type>
+ <length>-1</length>
+ <precision>-1</precision>
+ <replace>N</replace>
+ </field>
+ </fields>
+ <attributes/>
+ <cluster_schema/>
+ <remotesteps>
+ <input>
+ </input>
+ <output>
+ </output>
+ </remotesteps>
+ <GUI>
+ <xloc>960</xloc>
+ <yloc>80</yloc>
+ <draw>Y</draw>
+ </GUI>
+ </step>
<step_error_handling>
</step_error_handling>
<slave-step-copy-partition-distribution>