From 86c8c00efb8cc01a3eca0a1bc898bb0bb01abca9 Mon Sep 17 00:00:00 2001
From: Adhidarma Hadiwinoto <me@adhisimon.org>
Date: Mon, 13 Jan 2020 15:35:26 +0700
Subject: [PATCH] TOTALTAGIHAN untuk FIF

---
 index.js | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/index.js b/index.js
index b580ded..b97c493 100644
--- a/index.js
+++ b/index.js
@@ -142,7 +142,7 @@ function splitPostpaidDetail(str) {
 }
 
 function calculateBaseBillAmount(detailSplitted, customKeywords) {
-    const keywords = customKeywords || ['TAGIHAN', 'DENDA', 'RPPREMI', 'BIAYA'];
+    const keywords = customKeywords || ['TAGIHAN', 'DENDA', 'RPPREMI', 'BIAYA', 'TOTALTAGIHAN'];
 
     let retval = 0;
     let detailCount = (detailSplitted || []).length;
@@ -150,7 +150,8 @@ function calculateBaseBillAmount(detailSplitted, customKeywords) {
     for (let i = 0; i < detailCount; i += 1) {
         const item = detailSplitted[i];
         if (keywords.indexOf(item.keyword.toUpperCase()) >= 0) {
-            retval += Number(item.value) || 0;
+            const value = (item.value || '').trim().replace(/^rp */i, '').replace(/\./g, '');
+            retval += Number(value) || 0;
         }
     }
 
-- 
1.9.0