diff --git a/index.js b/index.js index 1a88f6c..030ca52 100644 --- a/index.js +++ b/index.js @@ -235,6 +235,19 @@ function calculateBaseBillAmount(detailSplitted, customKeywords, productKeyval, } /** + * get bill count using number of occurence of spliter + * @date 2020-10-02 + * @param {Object} detailSplitted + * @param {string} customKeyword + * @returns {number} + */ +function getBillCountUsingCounter(detailSplitted, customKeyword) { + if (!detailSplitted) return 0; + + return ((customKeyword && detailSplitted[customKeyword]) || '').split(',').length; +} + +/** * get bill count from splitted detail * @date 2020-10-02 * @param {Object} detailSplitted @@ -264,3 +277,4 @@ exports.getDetailFromMessage = getDetailFromMessage; exports.splitPostpaidDetail = splitPostpaidDetail; exports.calculateBaseBillAmount = calculateBaseBillAmount; exports.getBillCount = getBillCount; +exports.getBillCountUsingCounter = getBillCountUsingCounter; \ No newline at end of file