1this.BX = this.BX || {}; 2(function (exports,main_core) { 3 'use strict'; 4 5 var _currency = new WeakMap(); 6 7 var _format = new WeakMap(); 8 9 var CurrencyItem = /*#__PURE__*/function () { 10 function CurrencyItem(currency, format) { 11 babelHelpers.classCallCheck(this, CurrencyItem); 12 13 _currency.set(this, { 14 writable: true, 15 value: '' 16 }); 17 18 _format.set(this, { 19 writable: true, 20 value: {} 21 }); 22 23 babelHelpers.classPrivateFieldSet(this, _currency, currency); 24 babelHelpers.classPrivateFieldSet(this, _format, format); 25 } 26 27 babelHelpers.createClass(CurrencyItem, [{ 28 key: "getCurrency", 29 value: function getCurrency() { 30 return babelHelpers.classPrivateFieldGet(this, _currency); 31 } 32 }, { 33 key: "getFormat", 34 value: function getFormat() { 35 return babelHelpers.classPrivateFieldGet(this, _format); 36 } 37 }, { 38 key: "setFormat", 39 value: function setFormat(format) { 40 babelHelpers.classPrivateFieldSet(this, _format, format); 41 } 42 }]); 43 return CurrencyItem; 44 }(); 45 46 var CurrencyCore = /*#__PURE__*/function () { 47 function CurrencyCore() { 48 babelHelpers.classCallCheck(this, CurrencyCore); 49 } 50 51 babelHelpers.createClass(CurrencyCore, null, [{ 52 key: "getCurrencyList", 53 value: function getCurrencyList() { 54 return this.currencies; 55 } 56 }, { 57 key: "setCurrencyFormat", 58 value: function setCurrencyFormat(currency, format, replace) { 59 if (!main_core.Type.isStringFilled(currency) || !main_core.Type.isPlainObject(format)) { 60 return; 61 } 62 63 var index = this.getCurrencyIndex(currency); 64 65 if (index > -1 && !replace) { 66 return; 67 } 68 69 var innerFormat = babelHelpers.objectSpread({}, this.defaultFormat, format); 70 71 if (index === -1) { 72 this.currencies.push(new CurrencyItem(currency, innerFormat)); 73 } else { 74 this.currencies[index].setFormat(innerFormat); 75 } 76 } 77 }, { 78 key: "setCurrencies", 79 value: function setCurrencies(currencies, replace) { 80 if (main_core.Type.isArray(currencies)) { 81 for (var i = 0; i < currencies.length; i++) { 82 if (!main_core.Type.isPlainObject(currencies[i]) || !main_core.Type.isStringFilled(currencies[i].CURRENCY) || !main_core.Type.isPlainObject(currencies[i].FORMAT)) { 83 continue; 84 } 85 86 this.setCurrencyFormat(currencies[i].CURRENCY, currencies[i].FORMAT, replace); 87 } 88 } 89 } 90 }, { 91 key: "getCurrencyFormat", 92 value: function getCurrencyFormat(currency) { 93 var index = this.getCurrencyIndex(currency); 94 return index > -1 ? this.getCurrencyList()[index].getFormat() : false; 95 } 96 }, { 97 key: "getCurrencyIndex", 98 value: function getCurrencyIndex(currency) { 99 var currencyList = this.getCurrencyList(); 100 101 for (var i = 0; i < currencyList.length; i++) { 102 if (currencyList[i].getCurrency() === currency) { 103 return i; 104 } 105 } 106 107 return -1; 108 } 109 }, { 110 key: "clearCurrency", 111 value: function clearCurrency(currency) { 112 var index = this.getCurrencyIndex(currency); 113 114 if (index > -1) { 115 this.currencies = BX.util.deleteFromArray(this.currencies, index); 116 } 117 } 118 }, { 119 key: "clean", 120 value: function clean() { 121 this.currencies = []; 122 } 123 }, { 124 key: "currencyFormat", 125 value: function currencyFormat(price, currency, useTemplate) { 126 var result = ''; 127 var format = this.getCurrencyFormat(currency); 128 129 if (main_core.Type.isObject(format)) { 130 format.CURRENT_DECIMALS = format.DECIMALS; 131 132 if (format.HIDE_ZERO === 'Y' && price == parseInt(price, 10)) { 133 format.CURRENT_DECIMALS = 0; 134 } 135 136 result = BX.util.number_format(price, format.CURRENT_DECIMALS, format.DEC_POINT, format.THOUSANDS_SEP); 137 138 if (useTemplate) { 139 result = format.FORMAT_STRING.replace(/(^|[^&])#/, '$1' + result); 140 } 141 } 142 143 return result; 144 } 145 }, { 146 key: "loadCurrencyFormat", 147 value: function loadCurrencyFormat(currency) { 148 var _this = this; 149 150 return new Promise(function (resolve, reject) { 151 var index = _this.getCurrencyIndex(currency); 152 153 if (index > -1) { 154 resolve(_this.getCurrencyList()[index].getFormat()); 155 } else { 156 BX.ajax.runAction("currency.format.get", { 157 data: { 158 currencyId: currency 159 } 160 }).then(function (response) { 161 var format = response.data; 162 163 _this.setCurrencyFormat(currency, format); 164 165 resolve(format); 166 }).catch(function (response) { 167 reject(response.errors); 168 }); 169 } 170 }); 171 } 172 }]); 173 return CurrencyCore; 174 }(); 175 /** @deprecated use import { CurrencyCore } from 'currency.core' */ 176 177 babelHelpers.defineProperty(CurrencyCore, "currencies", []); 178 babelHelpers.defineProperty(CurrencyCore, "defaultFormat", { 179 'FORMAT_STRING': '#', 180 'DEC_POINT': '.', 181 'THOUSANDS_SEP': ' ', 182 'DECIMALS': 2, 183 'HIDE_ZERO': 'N' 184 }); 185 main_core.Reflection.namespace('BX.Currency').Core = CurrencyCore; 186 187 exports.CurrencyCore = CurrencyCore; 188 189}((this.BX.Currency = this.BX.Currency || {}),BX)); 190//# sourceMappingURL=currency-core.bundle.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.