hilmi_coding

Template Summary Approval

Aug 3rd, 2025
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { saveAs } from 'file-saver';
  2. import * as ExcelJS from 'exceljs';
  3.  
  4. const DATA: any = [
  5.     {
  6.         "createDate": "2024-05-28",
  7.         "proposalType": "Total Exposure > IDR 15 Bio",
  8.         "segment": [
  9.             {
  10.                 "segmentId": "7501",
  11.                 "segmentName": "SME 1",
  12.                 "lcType": [
  13.                     {
  14.                         "lcParentId": "SME",
  15.                         "listLC": [
  16.                             {
  17.                                 "lcParent": "SME",
  18.                                 "lcId": "LC1_SME",
  19.                                 "lcName": "LC 1 SME",
  20.                                 "conditionType": [
  21.                                     {
  22.                                         "conditionName": "Approved",
  23.                                         "noa": "0",
  24.                                         "product": []
  25.                                     },
  26.                                     {
  27.                                         "conditionName": "Reject",
  28.                                         "noa": "0",
  29.                                         "product": []
  30.                                     },
  31.                                     {
  32.                                         "conditionName": "Cancel",
  33.                                         "noa": "0",
  34.                                         "product": []
  35.                                     }
  36.                                 ]
  37.                             },
  38.                             {
  39.                                 "lcParent": "SME",
  40.                                 "lcId": "LC2_SME",
  41.                                 "lcName": "LC 2 SME",
  42.                                 "conditionType": [
  43.                                     {
  44.                                         "conditionName": "Approved",
  45.                                         "noa": "1",
  46.                                         "product": [
  47.                                             {
  48.                                                 "kategoriProduct": "Renewal",
  49.                                                 "noa": "1",
  50.                                                 "listProduct": [
  51.                                                     {
  52.                                                         "applicationId": 3314,
  53.                                                         "applicationType": "Renewal",
  54.                                                         "amountType": "Plafond",
  55.                                                         "amount": "5900000000"
  56.                                                     },
  57.                                                     {
  58.                                                         "applicationId": 3314,
  59.                                                         "applicationType": "Renewal",
  60.                                                         "amountType": "Changes",
  61.                                                         "amount": "0"
  62.                                                     }
  63.                                                 ],
  64.                                                 "summaryAmount": [
  65.                                                     {
  66.                                                         "amountType": "Changes",
  67.                                                         "currencyAmount": [
  68.                                                             {
  69.                                                                 "currency": "IDR",
  70.                                                                 "amount": "0"
  71.                                                             }
  72.                                                         ]
  73.                                                     }
  74.                                                 ]
  75.                                             },
  76.                                             {
  77.                                                 "kategoriProduct": "New (NTB)",
  78.                                                 "noa": "2",
  79.                                                 "listProduct": [
  80.                                                     {
  81.                                                         "applicationId": 3590,
  82.                                                         "applicationType": "New",
  83.                                                         "amountType": "Plafond",
  84.                                                         "amount": "22500000000"
  85.                                                     },
  86.                                                     {
  87.                                                         "applicationId": 3590,
  88.                                                         "applicationType": "New",
  89.                                                         "amountType": "Changes",
  90.                                                         "amount": "0"
  91.                                                     },
  92.                                                     {
  93.                                                         "applicationId": 3597,
  94.                                                         "applicationType": "New",
  95.                                                         "amountType": "Plafond",
  96.                                                         "amount": "20000000000"
  97.                                                     },
  98.                                                     {
  99.                                                         "applicationId": 3597,
  100.                                                         "applicationType": "New",
  101.                                                         "amountType": "Changes",
  102.                                                         "amount": "0"
  103.                                                     }
  104.                                                 ],
  105.                                                 "summaryAmount": [
  106.                                                     {
  107.                                                         "amountType": "Changes",
  108.                                                         "currencyAmount": [
  109.                                                             {
  110.                                                                 "currency": "IDR",
  111.                                                                 "amount": "0"
  112.                                                             }
  113.                                                         ]
  114.                                                     }
  115.                                                 ]
  116.                                             }
  117.                                         ]
  118.                                     },
  119.                                     {
  120.                                         "conditionName": "Reject",
  121.                                         "noa": "0",
  122.                                         "product": []
  123.                                     },
  124.                                     {
  125.                                         "conditionName": "Cancel",
  126.                                         "noa": "0",
  127.                                         "product": []
  128.                                     }
  129.                                 ]
  130.                             },
  131.                             {
  132.                                 "lcParent": "SME",
  133.                                 "lcId": "LC3_SME",
  134.                                 "lcName": "LC 3 SME",
  135.                                 "conditionType": [
  136.                                     {
  137.                                         "conditionName": "Approved",
  138.                                         "noa": "0",
  139.                                         "product": [
  140.                                             {
  141.                                                 "kategoriProduct": "Renewal",
  142.                                                 "noa": "2",
  143.                                                 "listProduct": [
  144.                                                     {
  145.                                                         "applicationId": 3603,
  146.                                                         "applicationType": "Renewal",
  147.                                                         "amountType": "Plafond",
  148.                                                         "amount": "13322927300"
  149.                                                     },
  150.                                                     {
  151.                                                         "applicationId": 3603,
  152.                                                         "applicationType": "Renewal",
  153.                                                         "amountType": "Changes",
  154.                                                         "amount": "0"
  155.                                                     },
  156.                                                     {
  157.                                                         "applicationId": 3603,
  158.                                                         "applicationType": "Renewal",
  159.                                                         "amountType": "Plafond",
  160.                                                         "amount": "25000000000"
  161.                                                     },
  162.                                                     {
  163.                                                         "applicationId": 3603,
  164.                                                         "applicationType": "Renewal",
  165.                                                         "amountType": "Changes",
  166.                                                         "amount": "0"
  167.                                                     }
  168.                                                 ],
  169.                                                 "summaryAmount": [
  170.                                                     {
  171.                                                         "amountType": "Changes",
  172.                                                         "currencyAmount": [
  173.                                                             {
  174.                                                                 "currency": "IDR",
  175.                                                                 "amount": "0"
  176.                                                             }
  177.                                                         ]
  178.                                                     }
  179.                                                 ]
  180.                                             }
  181.                                         ]
  182.                                     },
  183.                                     {
  184.                                         "conditionName": "Reject",
  185.                                         "noa": "0",
  186.                                         "product": []
  187.                                     },
  188.                                     {
  189.                                         "conditionName": "Cancel",
  190.                                         "noa": "0",
  191.                                         "product": []
  192.                                     }
  193.                                 ]
  194.                             },
  195.                             {
  196.                                 "lcParent": "SME",
  197.                                 "lcId": "LC4_SME",
  198.                                 "lcName": "LC 4 SME",
  199.                                 "conditionType": [
  200.                                     {
  201.                                         "conditionName": "Approved",
  202.                                         "noa": "0",
  203.                                         "product": []
  204.                                     },
  205.                                     {
  206.                                         "conditionName": "Reject",
  207.                                         "noa": "0",
  208.                                         "product": []
  209.                                     },
  210.                                     {
  211.                                         "conditionName": "Cancel",
  212.                                         "noa": "0",
  213.                                         "product": []
  214.                                     }
  215.                                 ]
  216.                             }
  217.                         ]
  218.                     }
  219.                 ]
  220.             },
  221.             {
  222.                 "segmentId": "7502",
  223.                 "segmentName": "SME 2",
  224.                 "lcType": [
  225.                     {
  226.                         "lcParentId": "SME",
  227.                         "listLC": [
  228.                             {
  229.                                 "lcParent": "SME",
  230.                                 "lcId": "LC1_SME",
  231.                                 "lcName": "LC 1 SME",
  232.                                 "conditionType": [
  233.                                     {
  234.                                         "conditionName": "Approved",
  235.                                         "noa": "0",
  236.                                         "product": []
  237.                                     },
  238.                                     {
  239.                                         "conditionName": "Reject",
  240.                                         "noa": "0",
  241.                                         "product": []
  242.                                     },
  243.                                     {
  244.                                         "conditionName": "Cancel",
  245.                                         "noa": "0",
  246.                                         "product": []
  247.                                     }
  248.                                 ]
  249.                             },
  250.                             {
  251.                                 "lcParent": "SME",
  252.                                 "lcId": "LC2_SME",
  253.                                 "lcName": "LC 2 SME",
  254.                                 "conditionType": [
  255.                                     {
  256.                                         "conditionName": "Approved",
  257.                                         "noa": "0",
  258.                                         "product": []
  259.                                     },
  260.                                     {
  261.                                         "conditionName": "Reject",
  262.                                         "noa": "0",
  263.                                         "product": [
  264.                                             {
  265.                                                 "kategoriProduct": "New (NTB)",
  266.                                                 "noa": "1",
  267.                                                 "listProduct": [
  268.                                                     {
  269.                                                         "applicationId": 3311,
  270.                                                         "applicationType": "New",
  271.                                                         "amountType": "Plafond",
  272.                                                         "amount": "3500000000"
  273.                                                     },
  274.                                                     {
  275.                                                         "applicationId": 3311,
  276.                                                         "applicationType": "New",
  277.                                                         "amountType": "Changes",
  278.                                                         "amount": "3500000000"
  279.                                                     }
  280.                                                 ],
  281.                                                 "summaryAmount": [
  282.                                                     {
  283.                                                         "amountType": "Changes",
  284.                                                         "currencyAmount": [
  285.                                                             {
  286.                                                                 "currency": "IDR",
  287.                                                                 "amount": "3500000000"
  288.                                                             }
  289.                                                         ]
  290.                                                     }
  291.                                                 ]
  292.                                             }
  293.                                         ]
  294.                                     },
  295.                                     {
  296.                                         "conditionName": "Cancel",
  297.                                         "noa": "0",
  298.                                         "product": []
  299.                                     }
  300.                                 ]
  301.                             },
  302.                             {
  303.                                 "lcParent": "SME",
  304.                                 "lcId": "LC3_SME",
  305.                                 "lcName": "LC 3 SME",
  306.                                 "conditionType": [
  307.                                     {
  308.                                         "conditionName": "Approved",
  309.                                         "noa": "0",
  310.                                         "product": []
  311.                                     },
  312.                                     {
  313.                                         "conditionName": "Reject",
  314.                                         "noa": "0",
  315.                                         "product": []
  316.                                     },
  317.                                     {
  318.                                         "conditionName": "Cancel",
  319.                                         "noa": "0",
  320.                                         "product": []
  321.                                     }
  322.                                 ]
  323.                             },
  324.                             {
  325.                                 "lcParent": "SME",
  326.                                 "lcId": "LC4_SME",
  327.                                 "lcName": "LC 4 SME",
  328.                                 "conditionType": [
  329.                                     {
  330.                                         "conditionName": "Approved",
  331.                                         "noa": "0",
  332.                                         "product": []
  333.                                     },
  334.                                     {
  335.                                         "conditionName": "Reject",
  336.                                         "noa": "0",
  337.                                         "product": []
  338.                                     },
  339.                                     {
  340.                                         "conditionName": "Cancel",
  341.                                         "noa": "0",
  342.                                         "product": []
  343.                                     }
  344.                                 ]
  345.                             }
  346.                         ]
  347.                     }
  348.                 ]
  349.             },
  350.             {
  351.                 "segmentId": "7503",
  352.                 "segmentName": "SME 3",
  353.                 "lcType": [
  354.                     {
  355.                         "lcParentId": "SME",
  356.                         "listLC": [
  357.                             {
  358.                                 "lcParent": "SME",
  359.                                 "lcId": "LC1_SME",
  360.                                 "lcName": "LC 1 SME",
  361.                                 "conditionType": [
  362.                                     {
  363.                                         "conditionName": "Approved",
  364.                                         "noa": "0",
  365.                                         "product": []
  366.                                     },
  367.                                     {
  368.                                         "conditionName": "Reject",
  369.                                         "noa": "0",
  370.                                         "product": []
  371.                                     },
  372.                                     {
  373.                                         "conditionName": "Cancel",
  374.                                         "noa": "0",
  375.                                         "product": []
  376.                                     }
  377.                                 ]
  378.                             },
  379.                             {
  380.                                 "lcParent": "SME",
  381.                                 "lcId": "LC2_SME",
  382.                                 "lcName": "LC 2 SME",
  383.                                 "conditionType": [
  384.                                     {
  385.                                         "conditionName": "Approved",
  386.                                         "noa": "1",
  387.                                         "product": [
  388.                                             {
  389.                                                 "kategoriProduct": "Renewal",
  390.                                                 "noa": "3",
  391.                                                 "listProduct": [
  392.                                                     {
  393.                                                         "applicationId": 3243,
  394.                                                         "applicationType": "Renewal",
  395.                                                         "amountType": "Plafond",
  396.                                                         "amount": "16000000000"
  397.                                                     },
  398.                                                     {
  399.                                                         "applicationId": 3243,
  400.                                                         "applicationType": "Renewal",
  401.                                                         "amountType": "Changes",
  402.                                                         "amount": "0"
  403.                                                     },
  404.                                                     {
  405.                                                         "applicationId": 3243,
  406.                                                         "applicationType": "Renewal",
  407.                                                         "amountType": "Plafond",
  408.                                                         "amount": "12000000000"
  409.                                                     },
  410.                                                     {
  411.                                                         "applicationId": 3243,
  412.                                                         "applicationType": "Renewal",
  413.                                                         "amountType": "Changes",
  414.                                                         "amount": "0"
  415.                                                     },
  416.                                                     {
  417.                                                         "applicationId": 3243,
  418.                                                         "applicationType": "Renewal",
  419.                                                         "amountType": "Plafond",
  420.                                                         "amount": "24000000000"
  421.                                                     },
  422.                                                     {
  423.                                                         "applicationId": 3243,
  424.                                                         "applicationType": "Renewal",
  425.                                                         "amountType": "Changes",
  426.                                                         "amount": "0"
  427.                                                     }
  428.                                                 ],
  429.                                                 "summaryAmount": [
  430.                                                     {
  431.                                                         "amountType": "Changes",
  432.                                                         "currencyAmount": [
  433.                                                             {
  434.                                                                 "currency": "IDR",
  435.                                                                 "amount": "0"
  436.                                                             }
  437.                                                         ]
  438.                                                     }
  439.                                                 ]
  440.                                             }
  441.                                         ]
  442.                                     },
  443.                                     {
  444.                                         "conditionName": "Reject",
  445.                                         "noa": "0",
  446.                                         "product": []
  447.                                     },
  448.                                     {
  449.                                         "conditionName": "Cancel",
  450.                                         "noa": "0",
  451.                                         "product": []
  452.                                     }
  453.                                 ]
  454.                             },
  455.                             {
  456.                                 "lcParent": "SME",
  457.                                 "lcId": "LC3_SME",
  458.                                 "lcName": "LC 3 SME",
  459.                                 "conditionType": [
  460.                                     {
  461.                                         "conditionName": "Approved",
  462.                                         "noa": "0",
  463.                                         "product": []
  464.                                     },
  465.                                     {
  466.                                         "conditionName": "Reject",
  467.                                         "noa": "0",
  468.                                         "product": []
  469.                                     },
  470.                                     {
  471.                                         "conditionName": "Cancel",
  472.                                         "noa": "1",
  473.                                         "product": [
  474.                                             {
  475.                                                 "kategoriProduct": "Decrease",
  476.                                                 "noa": "1",
  477.                                                 "listProduct": [
  478.                                                     {
  479.                                                         "applicationId": 3551,
  480.                                                         "applicationType": "Renewal + Decrease",
  481.                                                         "amountType": "Plafond",
  482.                                                         "amount": "20000000000"
  483.                                                     },
  484.                                                     {
  485.                                                         "applicationId": 3551,
  486.                                                         "applicationType": "Renewal + Decrease",
  487.                                                         "amountType": "Changes",
  488.                                                         "amount": "0"
  489.                                                     }
  490.                                                 ],
  491.                                                 "summaryAmount": [
  492.                                                     {
  493.                                                         "amountType": "Changes",
  494.                                                         "currencyAmount": [
  495.                                                             {
  496.                                                                 "currency": "IDR",
  497.                                                                 "amount": "0"
  498.                                                             }
  499.                                                         ]
  500.                                                     }
  501.                                                 ]
  502.                                             },
  503.                                             {
  504.                                                 "kategoriProduct": "Renewal",
  505.                                                 "noa": "1",
  506.                                                 "listProduct": [
  507.                                                     {
  508.                                                         "applicationId": 3551,
  509.                                                         "applicationType": "Renewal",
  510.                                                         "amountType": "Plafond",
  511.                                                         "amount": "14863847100"
  512.                                                     },
  513.                                                     {
  514.                                                         "applicationId": 3551,
  515.                                                         "applicationType": "Renewal",
  516.                                                         "amountType": "Changes",
  517.                                                         "amount": "0"
  518.                                                     }
  519.                                                 ],
  520.                                                 "summaryAmount": [
  521.                                                     {
  522.                                                         "amountType": "Changes",
  523.                                                         "currencyAmount": [
  524.                                                             {
  525.                                                                 "currency": "IDR",
  526.                                                                 "amount": "0"
  527.                                                             }
  528.                                                         ]
  529.                                                     }
  530.                                                 ]
  531.                                             }
  532.                                         ]
  533.                                     }
  534.                                 ]
  535.                             },
  536.                             {
  537.                                 "lcParent": "SME",
  538.                                 "lcId": "LC4_SME",
  539.                                 "lcName": "LC 4 SME",
  540.                                 "conditionType": [
  541.                                     {
  542.                                         "conditionName": "Approved",
  543.                                         "noa": "0",
  544.                                         "product": []
  545.                                     },
  546.                                     {
  547.                                         "conditionName": "Reject",
  548.                                         "noa": "0",
  549.                                         "product": []
  550.                                     },
  551.                                     {
  552.                                         "conditionName": "Cancel",
  553.                                         "noa": "0",
  554.                                         "product": []
  555.                                     }
  556.                                 ]
  557.                             }
  558.                         ]
  559.                     }
  560.                 ]
  561.             }
  562.         ]
  563.     },
  564.     // {
  565.     //     "createDate": "2024-05-28",
  566.     //     "proposalType": "Total Exposure > IDR 15 Bio",
  567.     //     "lcType": [
  568.     //         {
  569.     //             "lcId": "LC2_CORP",
  570.     //             "lcParent": "CORPORATE",
  571.     //             "lcName": "LC 2 Corporate",
  572.     //             "segment": [
  573.     //                 {
  574.     //                     "segmentId": "9903",
  575.     //                     "segmentName": "Corporate Banking",
  576.     //                     "conditionType": [
  577.     //                         {
  578.     //                             "conditionName": "Approved",
  579.     //                             "noa": "1",
  580.     //                             "product": [
  581.     //                                 {
  582.     //                                     "kategoriProduct": "Additional (Existing)",
  583.     //                                     "noa": "1",
  584.     //                                     "listProduct": [
  585.     //                                         {
  586.     //                                             "applicationId": 1827,
  587.     //                                             "applicationType": "Additional / Top Up",
  588.     //                                             "amountType": "Plafond",
  589.     //                                             "amount": "1806250.00"
  590.     //                                         },
  591.     //                                         {
  592.     //                                             "applicationId": 1827,
  593.     //                                             "applicationType": "Additional / Top Up",
  594.     //                                             "amountType": "Changes",
  595.     //                                             "amount": "0.00"
  596.     //                                         }
  597.     //                                     ],
  598.     //                                     "summaryAmount": [
  599.     //                                         {
  600.     //                                             "amountType": "Changes",
  601.     //                                             "currencyAmount": [
  602.     //                                                 {
  603.     //                                                     "currency": "USD",
  604.     //                                                     "amount": "0"
  605.     //                                                 }
  606.     //                                             ]
  607.     //                                         }
  608.     //                                     ]
  609.     //                                 }
  610.     //                             ]
  611.     //                         },
  612.     //                         {
  613.     //                             "conditionName": "Reject",
  614.     //                             "noa": "0",
  615.     //                             "product": []
  616.     //                         },
  617.     //                         {
  618.     //                             "conditionName": "Cancel",
  619.     //                             "noa": "0",
  620.     //                             "product": []
  621.     //                         }
  622.     //                     ]
  623.     //                 }
  624.     //             ]
  625.     //         },
  626.     //         {
  627.     //             "lcId": "LC2_SME",
  628.     //             "lcParent": "SME",
  629.     //             "lcName": "LC 2 SME",
  630.     //             "segment": [
  631.     //                 {
  632.     //                     "segmentId": "7503",
  633.     //                     "segmentName": "SME 3",
  634.     //                     "conditionType": [
  635.     //                         {
  636.     //                             "conditionName": "Approved",
  637.     //                             "noa": "1",
  638.     //                             "product": [
  639.     //                                 {
  640.     //                                     "kategoriProduct": "Renewal",
  641.     //                                     "noa": "3",
  642.     //                                     "listProduct": [
  643.     //                                         {
  644.     //                                             "applicationId": 3243,
  645.     //                                             "applicationType": "Renewal",
  646.     //                                             "amountType": "Plafond",
  647.     //                                             "amount": "16000000000"
  648.     //                                         },
  649.     //                                         {
  650.     //                                             "applicationId": 3243,
  651.     //                                             "applicationType": "Renewal",
  652.     //                                             "amountType": "Changes",
  653.     //                                             "amount": "0"
  654.     //                                         },
  655.     //                                         {
  656.     //                                             "applicationId": 3243,
  657.     //                                             "applicationType": "Renewal",
  658.     //                                             "amountType": "Plafond",
  659.     //                                             "amount": "12000000000"
  660.     //                                         },
  661.     //                                         {
  662.     //                                             "applicationId": 3243,
  663.     //                                             "applicationType": "Renewal",
  664.     //                                             "amountType": "Changes",
  665.     //                                             "amount": "0"
  666.     //                                         },
  667.     //                                         {
  668.     //                                             "applicationId": 3243,
  669.     //                                             "applicationType": "Renewal",
  670.     //                                             "amountType": "Plafond",
  671.     //                                             "amount": "24000000000"
  672.     //                                         },
  673.     //                                         {
  674.     //                                             "applicationId": 3243,
  675.     //                                             "applicationType": "Renewal",
  676.     //                                             "amountType": "Changes",
  677.     //                                             "amount": "0"
  678.     //                                         }
  679.     //                                     ],
  680.     //                                     "summaryAmount": [
  681.     //                                         {
  682.     //                                             "amountType": "Changes",
  683.     //                                             "currencyAmount": [
  684.     //                                                 {
  685.     //                                                     "currency": "IDR",
  686.     //                                                     "amount": "0"
  687.     //                                                 }
  688.     //                                             ]
  689.     //                                         }
  690.     //                                     ]
  691.     //                                 }
  692.     //                             ]
  693.     //                         },
  694.     //                         {
  695.     //                             "conditionName": "Reject",
  696.     //                             "noa": "0",
  697.     //                             "product": []
  698.     //                         },
  699.     //                         {
  700.     //                             "conditionName": "Cancel",
  701.     //                             "noa": "0",
  702.     //                             "product": []
  703.     //                         }
  704.     //                     ]
  705.     //                 },
  706.     //                 {
  707.     //                     "segmentId": "7502",
  708.     //                     "segmentName": "SME 2",
  709.     //                     "conditionType": [
  710.     //                         {
  711.     //                             "conditionName": "Approved",
  712.     //                             "noa": "0",
  713.     //                             "product": []
  714.     //                         },
  715.     //                         {
  716.     //                             "conditionName": "Reject",
  717.     //                             "noa": "0",
  718.     //                             "product": [
  719.     //                                 {
  720.     //                                     "kategoriProduct": "New (NTB)",
  721.     //                                     "noa": "1",
  722.     //                                     "listProduct": [
  723.     //                                         {
  724.     //                                             "applicationId": 3311,
  725.     //                                             "applicationType": "New",
  726.     //                                             "amountType": "Plafond",
  727.     //                                             "amount": "3500000000"
  728.     //                                         },
  729.     //                                         {
  730.     //                                             "applicationId": 3311,
  731.     //                                             "applicationType": "New",
  732.     //                                             "amountType": "Changes",
  733.     //                                             "amount": "3500000000"
  734.     //                                         }
  735.     //                                     ],
  736.     //                                     "summaryAmount": [
  737.     //                                         {
  738.     //                                             "amountType": "Changes",
  739.     //                                             "currencyAmount": [
  740.     //                                                 {
  741.     //                                                     "currency": "IDR",
  742.     //                                                     "amount": "3500000000"
  743.     //                                                 }
  744.     //                                             ]
  745.     //                                         }
  746.     //                                     ]
  747.     //                                 }
  748.     //                             ]
  749.     //                         },
  750.     //                         {
  751.     //                             "conditionName": "Cancel",
  752.     //                             "noa": "0",
  753.     //                             "product": []
  754.     //                         }
  755.     //                     ]
  756.     //                 },
  757.     //                 {
  758.     //                     "segmentId": "7501",
  759.     //                     "segmentName": "SME 1",
  760.     //                     "conditionType": [
  761.     //                         {
  762.     //                             "conditionName": "Approved",
  763.     //                             "noa": "1",
  764.     //                             "product": [
  765.     //                                 {
  766.     //                                     "kategoriProduct": "Renewal",
  767.     //                                     "noa": "1",
  768.     //                                     "listProduct": [
  769.     //                                         {
  770.     //                                             "applicationId": 3314,
  771.     //                                             "applicationType": "Renewal",
  772.     //                                             "amountType": "Plafond",
  773.     //                                             "amount": "5900000000"
  774.     //                                         },
  775.     //                                         {
  776.     //                                             "applicationId": 3314,
  777.     //                                             "applicationType": "Renewal",
  778.     //                                             "amountType": "Changes",
  779.     //                                             "amount": "0"
  780.     //                                         }
  781.     //                                     ],
  782.     //                                     "summaryAmount": [
  783.     //                                         {
  784.     //                                             "amountType": "Changes",
  785.     //                                             "currencyAmount": [
  786.     //                                                 {
  787.     //                                                     "currency": "IDR",
  788.     //                                                     "amount": "0"
  789.     //                                                 }
  790.     //                                             ]
  791.     //                                         }
  792.     //                                     ]
  793.     //                                 },
  794.     //                                 {
  795.     //                                     "kategoriProduct": "New (NTB)",
  796.     //                                     "noa": "2",
  797.     //                                     "listProduct": [
  798.     //                                         {
  799.     //                                             "applicationId": 3590,
  800.     //                                             "applicationType": "New",
  801.     //                                             "amountType": "Plafond",
  802.     //                                             "amount": "22500000000"
  803.     //                                         },
  804.     //                                         {
  805.     //                                             "applicationId": 3590,
  806.     //                                             "applicationType": "New",
  807.     //                                             "amountType": "Changes",
  808.     //                                             "amount": "0"
  809.     //                                         },
  810.     //                                         {
  811.     //                                             "applicationId": 3597,
  812.     //                                             "applicationType": "New",
  813.     //                                             "amountType": "Plafond",
  814.     //                                             "amount": "20000000000"
  815.     //                                         },
  816.     //                                         {
  817.     //                                             "applicationId": 3597,
  818.     //                                             "applicationType": "New",
  819.     //                                             "amountType": "Changes",
  820.     //                                             "amount": "0"
  821.     //                                         }
  822.     //                                     ],
  823.     //                                     "summaryAmount": [
  824.     //                                         {
  825.     //                                             "amountType": "Changes",
  826.     //                                             "currencyAmount": [
  827.     //                                                 {
  828.     //                                                     "currency": "IDR",
  829.     //                                                     "amount": "0"
  830.     //                                                 }
  831.     //                                             ]
  832.     //                                         }
  833.     //                                     ]
  834.     //                                 }
  835.     //                             ]
  836.     //                         },
  837.     //                         {
  838.     //                             "conditionName": "Reject",
  839.     //                             "noa": "0",
  840.     //                             "product": []
  841.     //                         },
  842.     //                         {
  843.     //                             "conditionName": "Cancel",
  844.     //                             "noa": "0",
  845.     //                             "product": []
  846.     //                         }
  847.     //                     ]
  848.     //                 }
  849.     //             ]
  850.     //         },
  851.     //         {
  852.     //             "lcId": "LC3_SME",
  853.     //             "lcParent": "SME",
  854.     //             "lcName": "LC 3 SME",
  855.     //             "segment": [
  856.     //                 {
  857.     //                     "segmentId": "7503",
  858.     //                     "segmentName": "SME 3",
  859.     //                     "conditionType": [
  860.     //                         {
  861.     //                             "conditionName": "Approved",
  862.     //                             "noa": "0",
  863.     //                             "product": []
  864.     //                         },
  865.     //                         {
  866.     //                             "conditionName": "Reject",
  867.     //                             "noa": "0",
  868.     //                             "product": []
  869.     //                         },
  870.     //                         {
  871.     //                             "conditionName": "Cancel",
  872.     //                             "noa": "1",
  873.     //                             "product": [
  874.     //                                 {
  875.     //                                     "kategoriProduct": "Decrease",
  876.     //                                     "noa": "1",
  877.     //                                     "listProduct": [
  878.     //                                         {
  879.     //                                             "applicationId": 3551,
  880.     //                                             "applicationType": "Renewal + Decrease",
  881.     //                                             "amountType": "Plafond",
  882.     //                                             "amount": "20000000000"
  883.     //                                         },
  884.     //                                         {
  885.     //                                             "applicationId": 3551,
  886.     //                                             "applicationType": "Renewal + Decrease",
  887.     //                                             "amountType": "Changes",
  888.     //                                             "amount": "0"
  889.     //                                         }
  890.     //                                     ],
  891.     //                                     "summaryAmount": [
  892.     //                                         {
  893.     //                                             "amountType": "Changes",
  894.     //                                             "currencyAmount": [
  895.     //                                                 {
  896.     //                                                     "currency": "IDR",
  897.     //                                                     "amount": "0"
  898.     //                                                 }
  899.     //                                             ]
  900.     //                                         }
  901.     //                                     ]
  902.     //                                 },
  903.     //                                 {
  904.     //                                     "kategoriProduct": "Renewal",
  905.     //                                     "noa": "1",
  906.     //                                     "listProduct": [
  907.     //                                         {
  908.     //                                             "applicationId": 3551,
  909.     //                                             "applicationType": "Renewal",
  910.     //                                             "amountType": "Plafond",
  911.     //                                             "amount": "14863847100"
  912.     //                                         },
  913.     //                                         {
  914.     //                                             "applicationId": 3551,
  915.     //                                             "applicationType": "Renewal",
  916.     //                                             "amountType": "Changes",
  917.     //                                             "amount": "0"
  918.     //                                         }
  919.     //                                     ],
  920.     //                                     "summaryAmount": [
  921.     //                                         {
  922.     //                                             "amountType": "Changes",
  923.     //                                             "currencyAmount": [
  924.     //                                                 {
  925.     //                                                     "currency": "IDR",
  926.     //                                                     "amount": "0"
  927.     //                                                 }
  928.     //                                             ]
  929.     //                                         }
  930.     //                                     ]
  931.     //                                 }
  932.     //                             ]
  933.     //                         }
  934.     //                     ]
  935.     //                 },
  936.     //                 {
  937.     //                     "segmentId": "7501",
  938.     //                     "segmentName": "SME 1",
  939.     //                     "conditionType": [
  940.     //                         {
  941.     //                             "conditionName": "Approved",
  942.     //                             "noa": "0",
  943.     //                             "product": [
  944.     //                                 {
  945.     //                                     "kategoriProduct": "Renewal",
  946.     //                                     "noa": "2",
  947.     //                                     "listProduct": [
  948.     //                                         {
  949.     //                                             "applicationId": 3603,
  950.     //                                             "applicationType": "Renewal",
  951.     //                                             "amountType": "Plafond",
  952.     //                                             "amount": "13322927300"
  953.     //                                         },
  954.     //                                         {
  955.     //                                             "applicationId": 3603,
  956.     //                                             "applicationType": "Renewal",
  957.     //                                             "amountType": "Changes",
  958.     //                                             "amount": "0"
  959.     //                                         },
  960.     //                                         {
  961.     //                                             "applicationId": 3603,
  962.     //                                             "applicationType": "Renewal",
  963.     //                                             "amountType": "Plafond",
  964.     //                                             "amount": "25000000000"
  965.     //                                         },
  966.     //                                         {
  967.     //                                             "applicationId": 3603,
  968.     //                                             "applicationType": "Renewal",
  969.     //                                             "amountType": "Changes",
  970.     //                                             "amount": "0"
  971.     //                                         }
  972.     //                                     ],
  973.     //                                     "summaryAmount": [
  974.     //                                         {
  975.     //                                             "amountType": "Changes",
  976.     //                                             "currencyAmount": [
  977.     //                                                 {
  978.     //                                                     "currency": "IDR",
  979.     //                                                     "amount": "0"
  980.     //                                                 }
  981.     //                                             ]
  982.     //                                         }
  983.     //                                     ]
  984.     //                                 }
  985.     //                             ]
  986.     //                         },
  987.     //                         {
  988.     //                             "conditionName": "Reject",
  989.     //                             "noa": "0",
  990.     //                             "product": []
  991.     //                         },
  992.     //                         {
  993.     //                             "conditionName": "Cancel",
  994.     //                             "noa": "0",
  995.     //                             "product": []
  996.     //                         }
  997.     //                     ]
  998.     //                 }
  999.     //             ]
  1000.     //         }
  1001.     //     ]
  1002.     // }
  1003. ]
  1004.  
  1005. export const exportSummaryApprovalCompare = () => {
  1006.     // Create a new Excel workbook
  1007.     const workbook = new ExcelJS.Workbook();
  1008.     const ws = workbook.addWorksheet('Sheet 1');
  1009.  
  1010.     // Create the template
  1011.     createTemplate(ws, DATA);
  1012.  
  1013.     // Map data to template
  1014.     mapDataToTemplate(ws, DATA);
  1015.  
  1016.     // Save the Excel file
  1017.     workbook.xlsx.writeBuffer().then((buffer) => {
  1018.         const blob = new Blob([buffer], {
  1019.             type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  1020.         });
  1021.         saveAs(blob, `LC_Summary_Simplified_${new Date().toISOString().split('T')[0]}.xlsx`);
  1022.     });
  1023. };
  1024.  
  1025. const createTemplate = (ws: ExcelJS.Worksheet, data: any): void => {
  1026.     // Add headers
  1027.     ws.getCell('A1').value = 'Date Range';
  1028.     ws.getCell('A2').value = 'Proposal Type';
  1029.     ws.getCell('A3').value = 'Amount Type';
  1030.  
  1031.     // Header values
  1032.     ws.getCell('B1').value = '2025-07-10 - 2025-07-15';
  1033.     ws.getCell('B2').value = 'Total Exposure > IDR 15 Bio';
  1034.     ws.getCell('B3').value = 'Plafond';
  1035.  
  1036.     // Create dynamic column headers based on data
  1037.     createDynamicHeaders(ws, data);
  1038. };
  1039.  
  1040. const createDynamicHeaders = (ws: ExcelJS.Worksheet, data: any): void => {
  1041.     let startRow = 5; // Start after the basic info rows
  1042.     let currentCol = 1; // Column A
  1043.  
  1044.     // Set main headers - merge Conditions header vertically (spans 3 rows now)
  1045.     ws.mergeCells(startRow, currentCol, startRow + 2, currentCol);
  1046.     const conditionsCell = ws.getCell(startRow, currentCol);
  1047.     conditionsCell.value = 'Conditions';
  1048.     conditionsCell.fill = {
  1049.         type: 'pattern',
  1050.         pattern: 'solid',
  1051.         fgColor: { argb: 'FFE0E0E0' }
  1052.     };
  1053.     conditionsCell.font = { bold: true };
  1054.     conditionsCell.alignment = { horizontal: 'center', vertical: 'middle' };
  1055.     conditionsCell.border = {
  1056.         top: { style: 'thin' },
  1057.         left: { style: 'thin' },
  1058.         bottom: { style: 'thin' },
  1059.         right: { style: 'thin' }
  1060.     };
  1061.     currentCol++;
  1062.  
  1063.     // Get unique LC types and segments from data
  1064.     const lcTypes = new Set<string>();
  1065.     const segments = new Set<string>();
  1066.  
  1067.     data.forEach((item: any) => {
  1068.         if (item.segment) {
  1069.             item.segment.forEach((seg: any) => {
  1070.                 segments.add(seg.segmentName);
  1071.                 if (seg.lcType) {
  1072.                     seg.lcType.forEach((lc: any) => {
  1073.                         if (lc.listLC) {
  1074.                             lc.listLC.forEach((lcItem: any) => {
  1075.                                 lcTypes.add(lcItem.lcName);
  1076.                             });
  1077.                         }
  1078.                     });
  1079.                 }
  1080.             });
  1081.         }
  1082.         if (item.lcType) {
  1083.             item.lcType.forEach((lc: any) => {
  1084.                 lcTypes.add(lc.lcName);
  1085.                 if (lc.segment) {
  1086.                     lc.segment.forEach((seg: any) => {
  1087.                         segments.add(seg.segmentName);
  1088.                     });
  1089.                 }
  1090.             });
  1091.         }
  1092.     });
  1093.  
  1094.     const lcArray = Array.from(lcTypes).sort();
  1095.     const segArray = Array.from(segments).sort();
  1096.  
  1097.     // Calculate total columns for LC1 SME header
  1098.     const smeColumnsCount = segArray.length * 3; // Each SME has 3 sub-columns
  1099.     const totalColumnsCount = 3; // TOTAL has 3 sub-columns
  1100.     const lc1SmeColumnsCount = smeColumnsCount + totalColumnsCount;
  1101.  
  1102.     // Create LC1 SME top-level header (spans all SME segments + TOTAL)
  1103.     ws.mergeCells(startRow, currentCol, startRow, currentCol + lc1SmeColumnsCount - 1);
  1104.     const lc1SmeCell = ws.getCell(startRow, currentCol);
  1105.     lc1SmeCell.value = 'LC1 SME';
  1106.     lc1SmeCell.fill = {
  1107.         type: 'pattern',
  1108.         pattern: 'solid',
  1109.         fgColor: { argb: 'FFE0E0E0' }
  1110.     };
  1111.     lc1SmeCell.font = { bold: true };
  1112.     lc1SmeCell.alignment = { horizontal: 'center', vertical: 'middle' };
  1113.     lc1SmeCell.border = {
  1114.         top: { style: 'thin' },
  1115.         left: { style: 'thin' },
  1116.         bottom: { style: 'thin' },
  1117.         right: { style: 'thin' }
  1118.     };
  1119.  
  1120.     // Create SME segment headers (second level)
  1121.     segArray.forEach(seg => {
  1122.         ws.mergeCells(startRow + 1, currentCol, startRow + 1, currentCol + 2);
  1123.         const segCell = ws.getCell(startRow + 1, currentCol);
  1124.         segCell.value = seg;
  1125.         segCell.fill = {
  1126.             type: 'pattern',
  1127.             pattern: 'solid',
  1128.             fgColor: { argb: 'FFE0E0E0' }
  1129.         };
  1130.         segCell.font = { bold: true };
  1131.         segCell.alignment = { horizontal: 'center', vertical: 'middle' };
  1132.         segCell.border = {
  1133.             top: { style: 'thin' },
  1134.             left: { style: 'thin' },
  1135.             bottom: { style: 'thin' },
  1136.             right: { style: 'thin' }
  1137.         };
  1138.        
  1139.         // Add sub-headers for this segment
  1140.         const subColumns = ['NOA', 'Amount (IDR)', 'Amount (USD)'];
  1141.         subColumns.forEach((subCol, index) => {
  1142.             const subCell = ws.getCell(startRow + 2, currentCol + index);
  1143.             subCell.value = subCol;
  1144.             subCell.fill = {
  1145.                 type: 'pattern',
  1146.                 pattern: 'solid',
  1147.                 fgColor: { argb: 'FFF0F0F0' }
  1148.             };
  1149.             subCell.font = { bold: true };
  1150.             subCell.alignment = { horizontal: 'center', vertical: 'middle' };
  1151.             subCell.border = {
  1152.                 top: { style: 'thin' },
  1153.                 left: { style: 'thin' },
  1154.                 bottom: { style: 'thin' },
  1155.                 right: { style: 'thin' }
  1156.             };
  1157.         });
  1158.        
  1159.         currentCol += 3;
  1160.     });
  1161.  
  1162.     // Add TOTAL header (second level)
  1163.     ws.mergeCells(startRow + 1, currentCol, startRow + 1, currentCol + 2);
  1164.     const totalCell = ws.getCell(startRow + 1, currentCol);
  1165.     totalCell.value = 'TOTAL';
  1166.     totalCell.fill = {
  1167.         type: 'pattern',
  1168.         pattern: 'solid',
  1169.         fgColor: { argb: 'FFE0E0E0' }
  1170.     };
  1171.     totalCell.font = { bold: true };
  1172.     totalCell.alignment = { horizontal: 'center', vertical: 'middle' };
  1173.     totalCell.border = {
  1174.         top: { style: 'thin' },
  1175.         left: { style: 'thin' },
  1176.         bottom: { style: 'thin' },
  1177.         right: { style: 'thin' }
  1178.     };
  1179.    
  1180.     // Add sub-headers for TOTAL
  1181.     const totalSubColumns = ['NOA', 'Amount (IDR)', 'Amount (USD)'];
  1182.     totalSubColumns.forEach((subCol, index) => {
  1183.         const subCell = ws.getCell(startRow + 2, currentCol + index);
  1184.         subCell.value = subCol;
  1185.         subCell.fill = {
  1186.             type: 'pattern',
  1187.             pattern: 'solid',
  1188.             fgColor: { argb: 'FFF0F0F0' }
  1189.         };
  1190.         subCell.font = { bold: true };
  1191.         subCell.alignment = { horizontal: 'center', vertical: 'middle' };
  1192.         subCell.border = {
  1193.             top: { style: 'thin' },
  1194.             left: { style: 'thin' },
  1195.             bottom: { style: 'thin' },
  1196.             right: { style: 'thin' }
  1197.         };
  1198.     });
  1199. };
  1200.  
  1201. const styleHeaders = (ws: ExcelJS.Worksheet, startRow: number, endCol: number): void => {
  1202.     // Style main headers
  1203.     for (let col = 1; col <= endCol; col++) {
  1204.         const cell = ws.getCell(startRow, col);
  1205.         cell.fill = {
  1206.             type: 'pattern',
  1207.             pattern: 'solid',
  1208.             fgColor: { argb: 'FFE0E0E0' }
  1209.         };
  1210.         cell.font = { bold: true };
  1211.         cell.alignment = { horizontal: 'center', vertical: 'middle' };
  1212.         cell.border = {
  1213.             top: { style: 'thin' },
  1214.             left: { style: 'thin' },
  1215.             bottom: { style: 'thin' },
  1216.             right: { style: 'thin' }
  1217.         };
  1218.     }
  1219.  
  1220.     // Style sub headers
  1221.     for (let col = 1; col <= endCol; col++) {
  1222.         const cell = ws.getCell(startRow + 1, col);
  1223.         cell.fill = {
  1224.             type: 'pattern',
  1225.             pattern: 'solid',
  1226.             fgColor: { argb: 'FFF0F0F0' }
  1227.         };
  1228.         cell.font = { bold: true };
  1229.         cell.alignment = { horizontal: 'center', vertical: 'middle' };
  1230.         cell.border = {
  1231.             top: { style: 'thin' },
  1232.             left: { style: 'thin' },
  1233.             bottom: { style: 'thin' },
  1234.             right: { style: 'thin' }
  1235.         };
  1236.     }
  1237. };
  1238.  
  1239. const mapDataToTemplate = (ws: ExcelJS.Worksheet, data: any): void => {
  1240.     const startRow = 8; // Start after 3-row headers (5, 6, 7)
  1241.     let currentRow = startRow;
  1242.  
  1243.     const conditions = [
  1244.         {
  1245.             name: 'Approved',
  1246.             categories: [
  1247.                 'New',
  1248.                 'Additional',
  1249.                 'Renewal',
  1250.                 'Restructure',
  1251.                 'Decrease',
  1252.                 'Other'
  1253.             ]
  1254.         },
  1255.         {
  1256.             name: 'Reject',
  1257.             categories: [
  1258.                 'New',
  1259.                 'Additional',
  1260.                 'Renewal',
  1261.                 'Restructure',
  1262.                 'Decrease',
  1263.                 'Other'
  1264.             ]
  1265.         },
  1266.         {
  1267.             name: 'Cancel',
  1268.             categories: []
  1269.         },
  1270.         {
  1271.             name: 'Total',
  1272.             categories: []
  1273.         },
  1274.         {
  1275.             name: '% Total Approve',
  1276.             categories: []
  1277.         },
  1278.         {
  1279.             name: '% Total Reject',
  1280.             categories: []
  1281.         },
  1282.         {
  1283.             name: '% Total Cancel',
  1284.             categories: []
  1285.         }
  1286.     ];
  1287.  
  1288.     conditions.forEach(condition => {
  1289.         // Write main condition
  1290.         ws.getCell(currentRow, 1).value = condition.name;
  1291.         styleConditionCell(ws, currentRow, 1);
  1292.         currentRow++;
  1293.  
  1294.         // Write subcategories
  1295.         condition.categories.forEach(category => {
  1296.             ws.getCell(currentRow, 1).value = `  - ${category}`;
  1297.             styleSubConditionCell(ws, currentRow, 1);
  1298.             currentRow++;
  1299.         });
  1300.     });
  1301.  
  1302.     // Fill data based on the structure
  1303.     fillDataIntoTemplate(ws, data, startRow);
  1304. };
  1305.  
  1306. const styleConditionCell = (ws: ExcelJS.Worksheet, row: number, col: number): void => {
  1307.     const cell = ws.getCell(row, col);
  1308.     cell.font = { bold: true };
  1309.     cell.fill = {
  1310.         type: 'pattern',
  1311.         pattern: 'solid',
  1312.         fgColor: { argb: 'FFE6F3FF' }
  1313.     };
  1314.     cell.border = {
  1315.         top: { style: 'thin' },
  1316.         left: { style: 'thin' },
  1317.         bottom: { style: 'thin' },
  1318.         right: { style: 'thin' }
  1319.     };
  1320. };
  1321.  
  1322. const styleSubConditionCell = (ws: ExcelJS.Worksheet, row: number, col: number): void => {
  1323.     const cell = ws.getCell(row, col);
  1324.     cell.border = {
  1325.         top: { style: 'thin' },
  1326.         left: { style: 'thin' },
  1327.         bottom: { style: 'thin' },
  1328.         right: { style: 'thin' }
  1329.     };
  1330. };
  1331.  
  1332. const fillDataIntoTemplate = (ws: ExcelJS.Worksheet, data: any, startRow: number): void => {
  1333.     // This function would populate the actual data into the template
  1334.     // For now, we'll add placeholder logic
  1335.     console.log('Filling data into template...', data);
  1336.    
  1337.     // Add borders to all data cells
  1338.     const maxRow = ws.rowCount || startRow + 20;
  1339.     const maxCol = ws.columnCount || 20;
  1340.    
  1341.     for (let row = startRow; row <= maxRow; row++) {
  1342.         for (let col = 2; col <= maxCol; col++) {
  1343.             const cell = ws.getCell(row, col);
  1344.             cell.border = {
  1345.                 top: { style: 'thin' },
  1346.                 left: { style: 'thin' },
  1347.                 bottom: { style: 'thin' },
  1348.                 right: { style: 'thin' }
  1349.             };
  1350.             // Add placeholder values
  1351.             if (!cell.value) {
  1352.                 cell.value = 0;
  1353.             }
  1354.         }
  1355.     }
  1356. };
Advertisement
Add Comment
Please, Sign In to add comment