From d234274fafcf4e20f6bea38aab883bc81a3b339b Mon Sep 17 00:00:00 2001
From: Adhidarma Hadiwinoto <me@adhisimon.org>
Date: Fri, 2 Oct 2020 11:48:37 +0700
Subject: [PATCH] getBillCount sekarang pakai detailSplitted

---
 index.js | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/index.js b/index.js
index dbc566f..a651bde 100644
--- a/index.js
+++ b/index.js
@@ -234,10 +234,19 @@ function calculateBaseBillAmount(detailSplitted, customKeywords, productKeyval,
     return totalTagihanValue - (adminFeeValue * billCountOrDefault);
 }
 
-
-function getBillCount(msg) {
-    const matches = (msg || '').match(/JMLBLN:(\d+)BLN/);
-    return (matches && Number(matches[1])) || null;
+/**
+ * get bill count from splitted detail
+ * @date 2020-10-02
+ * @param {Object} detailSplitted
+ * @param {string} [customKeyword]
+ * @returns {number}
+ */
+function getBillCount(detailSplitted, customKeyword) {
+    return Number(
+        (customKeyword && detailSplitted[customKeyword])
+        || detailSplitted['JMLBLN']
+        || '0'
+    );
 }
 
 exports.getRcFromMessage = getRcFromMessage;
-- 
1.9.0