File manager - Edit - /home/c14075/dragmet-ural.ru/www/bitrix/js/catalog/product-calculator/dist/product.calculator.bundle.min.js
Back
this.BX=this.BX||{};(function(e,t,i){"use strict";var a=function e(){babelHelpers.classCallCheck(this,e)};babelHelpers.defineProperty(a,"UNDEFINED",0);babelHelpers.defineProperty(a,"MONETARY",1);babelHelpers.defineProperty(a,"PERCENTAGE",2);function s(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,a)}return i}function u(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?s(Object(i),!0).forEach((function(t){babelHelpers.defineProperty(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):s(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function n(e,t){r(e,t);t.add(e)}function r(e,t){if(t.has(e)){throw new TypeError("Cannot initialize the same private elements twice on an object")}}function l(e,t,i){c(e,t);return i}function c(e,t){if(e!==t){throw new TypeError("Private static access of wrong provenance")}}function o(e,t,i){if(!t.has(e)){throw new TypeError("attempted to get private field on non-instance")}return i}var d={QUANTITY:1,PRICE:0,PRICE_EXCLUSIVE:0,PRICE_NETTO:0,PRICE_BRUTTO:0,CUSTOMIZED:"N",DISCOUNT_TYPE_ID:a.UNDEFINED,DISCOUNT_RATE:0,DISCOUNT_SUM:0,DISCOUNT_ROW:0,TAX_INCLUDED:"N",TAX_RATE:0,TAX_SUM:0,SUM:0};var h=new WeakSet;var f=new WeakSet;var P=new WeakSet;var T=new WeakSet;var g=function(){function e(i,a){babelHelpers.classCallCheck(this,e);n(this,T);n(this,P);n(this,f);n(this,h);this.fields=u({},d);if(t.Type.isPlainObject(i)){this.fields=u(u({},this.fields),i)}this.calculator=a}babelHelpers.createClass(e,[{key:"getFields",value:function e(){return t.Runtime.clone(this.fields)}},{key:"getField",value:function e(t,i){return this.fields.hasOwnProperty(t)?this.fields[t]:i}},{key:"setField",value:function e(t,i){i=o(this,T,E).call(this,t,i);this.fields[t]=i}},{key:"getBasePrice",value:function e(){return this.getField("BASE_PRICE",0)}},{key:"getPrice",value:function e(){return this.getField("PRICE",0)}},{key:"getPriceExclusive",value:function e(){return this.getField("PRICE_EXCLUSIVE",0)}},{key:"getPriceNetto",value:function e(){return this.getField("PRICE_NETTO",0)}},{key:"getPriceBrutto",value:function e(){return this.getField("PRICE_BRUTTO",0)}},{key:"getQuantity",value:function e(){return this.getField("QUANTITY",1)}},{key:"getDiscountType",value:function e(){return this.getField("DISCOUNT_TYPE_ID",a.UNDEFINED)}},{key:"isDiscountUndefined",value:function e(){return this.getDiscountType()===a.UNDEFINED}},{key:"isDiscountPercentage",value:function e(){return this.getDiscountType()===a.PERCENTAGE}},{key:"isDiscountMonetary",value:function e(){return this.getDiscountType()===a.MONETARY}},{key:"isDiscountHandmade",value:function e(){return this.isDiscountPercentage()||this.isDiscountMonetary()}},{key:"getDiscountRate",value:function e(){return this.getField("DISCOUNT_RATE",0)}},{key:"getDiscountSum",value:function e(){return this.getField("DISCOUNT_SUM",0)}},{key:"getDiscountRow",value:function e(){return this.getField("DISCOUNT_ROW",0)}},{key:"isEmptyDiscount",value:function e(){if(this.isDiscountPercentage()){return this.getDiscountRate()===0}if(this.isDiscountMonetary()){return this.getDiscountSum()===0}return this.isDiscountUndefined()}},{key:"getTaxIncluded",value:function e(){return this.getField("TAX_INCLUDED","N")}},{key:"isTaxIncluded",value:function e(){return this.getTaxIncluded()==="Y"}},{key:"getTaxRate",value:function e(){return this.getField("TAX_RATE",0)}},{key:"getTaxSum",value:function e(){return this.getField("TAX_SUM",0)}},{key:"getSum",value:function e(){return this.getField("SUM",0)}}]);return e}();function p(){return this.calculator.getPricePrecision()}function v(){return this.calculator.getCommonPrecision()}function y(){return this.calculator.getQuantityPrecision()}function E(e,i){var s=["PRICE","PRICE_EXCLUSIVE","PRICE_NETTO","PRICE_BRUTTO","DISCOUNT_SUM","DISCOUNT_ROW","TAX_SUM","SUM"];if(e==="DISCOUNT_TYPE_ID"){i=i===a.PERCENTAGE||i===a.MONETARY?i:a.UNDEFINED}else if(e==="QUANTITY"){i=l(g,g,D).call(g,i,o(this,P,y).call(this))}else if(e==="CUSTOMIZED"||e==="TAX_INCLUDED"){i=i==="Y"?"Y":"N"}else if(e==="TAX_RATE"){if(t.Type.isNil(i)){return null}i=l(g,g,D).call(g,i,o(this,f,v).call(this))}else if(e==="DISCOUNT_RATE"){i=l(g,g,D).call(g,i,o(this,f,v).call(this))}else if(s.includes(e)){i=l(g,g,D).call(g,i,o(this,h,p).call(this))}return i}function D(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:i.ProductCalculator.DEFAULT_PRECISION;var a=Math.pow(10,t);return Math.round(e*a)/a}var R=function(){function e(t){babelHelpers.classCallCheck(this,e);babelHelpers.defineProperty(this,"calculator",null);this.calculator=t}babelHelpers.createClass(e,[{key:"getFieldStorage",value:function e(){return new g(this.calculator.getFields(),this.calculator)}},{key:"getPricePrecision",value:function e(){return this.calculator.getPricePrecision()}},{key:"getCommonPrecision",value:function e(){return this.calculator.getCommonPrecision()}},{key:"getQuantityPrecision",value:function e(){return this.calculator.getQuantityPrecision()}},{key:"calculateBasePrice",value:function e(t){if(t<0){throw new Error("Price must be equal or greater than zero.")}var i=this.getFieldStorage();i.setField("BASE_PRICE",t);if(i.isTaxIncluded()){i.setField("PRICE_BRUTTO",t)}else{i.setField("PRICE_NETTO",t)}this.updatePrice(i);this.activateCustomized(i);return i.getFields()}},{key:"calculatePrice",value:function e(t){return this.calculateBasePrice(t)}},{key:"calculateQuantity",value:function e(t){if(t<0){throw new Error("Quantity must be equal or greater than zero.")}var i=this.getFieldStorage();i.setField("QUANTITY",t);this.updateRowDiscount(i);this.updateTax(i);this.updateSum(i);return i.getFields()}},{key:"calculateDiscount",value:function e(t){var i=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;if(!i){i=this.getFieldStorage()}if(t===0){this.clearResultPrices(i)}else if(i.isDiscountPercentage()){i.setField("DISCOUNT_RATE",t);this.updateResultPrices(i);i.setField("DISCOUNT_SUM",i.getPriceNetto()-i.getPriceExclusive())}else if(i.isDiscountMonetary()){i.setField("DISCOUNT_SUM",t);this.updateResultPrices(i);i.setField("DISCOUNT_RATE",this.calculateDiscountRate(i.getPriceNetto(),i.getPriceExclusive()))}this.updateRowDiscount(i);this.updateTax(i);this.updateSum(i);this.activateCustomized(i);return i.getFields()}},{key:"calculateDiscountType",value:function e(t){var i=this.getFieldStorage();i.setField("DISCOUNT_TYPE_ID",t);this.updateResultPrices(i);this.updateDiscount(i);this.updateRowDiscount(i);this.updateTax(i);this.updateSum(i);this.activateCustomized(i);return i.getFields()}},{key:"calculateRowDiscount",value:function e(t){var i=this.getFieldStorage();i.setField("DISCOUNT_ROW",t);if(t!==0&&i.getQuantity()===0){i.setField("QUANTITY",1)}i.setField("DISCOUNT_TYPE_ID",a.MONETARY);if(t===0||i.getQuantity()===0){i.setField("DISCOUNT_SUM",0)}else{i.setField("DISCOUNT_SUM",i.getDiscountRow()/i.getQuantity())}this.updateResultPrices(i);this.updateDiscount(i);this.updateRowDiscount(i);this.updateTax(i);this.updateSum(i);this.activateCustomized(i);return i.getFields()}},{key:"calculateTax",value:function e(t){var i=this.getFieldStorage();i.setField("TAX_RATE",t);this.updateBasePrices(i);this.updateResultPrices(i);if(i.isTaxIncluded()){this.updateDiscount(i);this.updateRowDiscount(i)}this.updateTax(i);this.updateSum(i);this.activateCustomized(i);return i.getFields()}},{key:"calculateTaxIncluded",value:function e(t){var i=this.getFieldStorage();if(i.getTaxIncluded()!==t){i.setField("TAX_INCLUDED",t);if(i.isTaxIncluded()){i.setField("PRICE_BRUTTO",i.getPriceNetto())}else{i.setField("PRICE_NETTO",i.getPriceBrutto())}}this.updatePrice(i);this.activateCustomized(i);return i.getFields()}},{key:"calculateRowSum",value:function e(t){var i=this.getFieldStorage();i.setField("SUM",t);if(i.getQuantity()===0){i.setField("QUANTITY",1)}var s=i.getPriceNetto()-i.getSum()/(i.getQuantity()*(1+i.getTaxRate()/100));i.setField("DISCOUNT_SUM",s);i.setField("DISCOUNT_TYPE_ID",a.MONETARY);if(i.isEmptyDiscount()){this.clearResultPrices(i)}else if(i.isDiscountHandmade()){this.updateResultPrices(i)}this.updateDiscount(i);this.updateRowDiscount(i);this.updateTax(i);this.activateCustomized(i);return i.getFields()}},{key:"updatePrice",value:function e(t){this.updateBasePrices(t);if(t.isEmptyDiscount()){this.clearResultPrices(t)}else if(t.isDiscountHandmade()){this.updateResultPrices(t)}this.updateDiscount(t);this.updateRowDiscount(t);this.updateTax(t);this.updateSum(t)}},{key:"clearResultPrices",value:function e(t){t.setField("PRICE_EXCLUSIVE",t.getPriceNetto());t.setField("PRICE",t.getPriceBrutto());t.setField("DISCOUNT_RATE",0);t.setField("DISCOUNT_SUM",0)}},{key:"calculatePriceWithoutDiscount",value:function e(t,i,s){var u=0;switch(s){case a.PERCENTAGE:u=t-t*i/100;break;case a.MONETARY:u=t-i;break}return u}},{key:"updateBasePrices",value:function e(t){if(t.isTaxIncluded()){t.setField("PRICE_NETTO",this.calculatePriceWithoutTax(t.getPriceBrutto(),t.getTaxRate()))}else{t.setField("PRICE_BRUTTO",this.calculatePriceWithTax(t.getPriceNetto(),t.getTaxRate()))}}},{key:"updateResultPrices",value:function e(t){var i;if(t.isDiscountPercentage()){i=this.calculatePriceWithoutDiscount(t.getPriceNetto(),t.getDiscountRate(),a.PERCENTAGE)}else if(t.isDiscountMonetary()){i=this.calculatePriceWithoutDiscount(t.getPriceNetto(),t.getDiscountSum(),a.MONETARY)}else{i=t.getPriceExclusive()}t.setField("PRICE_EXCLUSIVE",i);t.setField("PRICE",this.calculatePriceWithTax(i,t.getTaxRate()))}},{key:"activateCustomized",value:function e(t){t.setField("CUSTOMIZED","Y")}},{key:"updateDiscount",value:function e(t){if(t.isEmptyDiscount()){this.clearResultPrices(t)}else if(t.isDiscountPercentage()){t.setField("DISCOUNT_SUM",t.getPriceNetto()-t.getPriceExclusive())}else if(t.isDiscountMonetary()){t.setField("DISCOUNT_RATE",this.calculateDiscountRate(t.getPriceNetto(),t.getPriceNetto()-t.getDiscountSum()))}}},{key:"updateRowDiscount",value:function e(t){t.setField("DISCOUNT_ROW",t.getDiscountSum()*t.getQuantity())}},{key:"updateTax",value:function e(t){var i;if(t.isTaxIncluded()){i=t.getPrice()*t.getQuantity()*(1-1/(1+t.getTaxRate()/100))}else{i=t.getPriceExclusive()*t.getQuantity()*(t.getTaxRate()/100)}t.setField("TAX_SUM",i)}},{key:"updateSum",value:function e(t){var i;if(t.isTaxIncluded()){i=t.getPrice()*t.getQuantity()}else{i=this.calculatePriceWithTax(t.getPriceExclusive()*t.getQuantity(),t.getTaxRate())}t.setField("SUM",i)}},{key:"calculateDiscountRate",value:function e(t,i){if(t===0){return 0}if(i===0){return t>0?100:-100}return(t-i)/t*100}},{key:"calculatePriceWithoutTax",value:function e(t,i){return t/(1+i/100)}},{key:"calculatePriceWithTax",value:function e(t,i){return t+t*i/100}}]);return e}();function C(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,a)}return i}function S(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?C(Object(i),!0).forEach((function(t){babelHelpers.defineProperty(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):C(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function b(e,t){F(e,t);t.add(e)}function I(e,t,i){F(e,t);t.set(e,i)}function F(e,t){if(t.has(e)){throw new TypeError("Cannot initialize the same private elements twice on an object")}}function O(e,t,i){if(!t.has(e)){throw new TypeError("attempted to get private field on non-instance")}return i}var N=new WeakMap;var k=new WeakMap;var U=new WeakMap;var _=new WeakSet;var w=function(){function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var i=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};babelHelpers.classCallCheck(this,e);b(this,_);I(this,N,{writable:true,value:{}});I(this,k,{writable:true,value:{}});I(this,U,{writable:true,value:{}});this.setFields(t);this.setSettings(i);this.setCalculationStrategy(new R(this))}babelHelpers.createClass(e,[{key:"setField",value:function e(t,i){babelHelpers.classPrivateFieldGet(this,N)[t]=i;return this}},{key:"setCalculationStrategy",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};babelHelpers.classPrivateFieldSet(this,k,t);return this}},{key:"setFields",value:function e(t){for(var i in t){if(t.hasOwnProperty(i)){this.setField(i,t[i])}}return this}},{key:"getFields",value:function e(){return S({},babelHelpers.classPrivateFieldGet(this,N))}},{key:"setSettings",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};babelHelpers.classPrivateFieldSet(this,U,S({},t));return this}},{key:"getSettings",value:function e(){return S({},babelHelpers.classPrivateFieldGet(this,U))}},{key:"getPricePrecision",value:function t(){return O(this,_,m).call(this,"pricePrecision",e.DEFAULT_PRECISION)}},{key:"getCommonPrecision",value:function t(){return O(this,_,m).call(this,"commonPrecision",e.DEFAULT_PRECISION)}},{key:"getQuantityPrecision",value:function t(){return O(this,_,m).call(this,"quantityPrecision",e.DEFAULT_PRECISION)}},{key:"calculateBasePrice",value:function e(t){return babelHelpers.classPrivateFieldGet(this,k).calculateBasePrice(t)}},{key:"calculatePrice",value:function e(t){return babelHelpers.classPrivateFieldGet(this,k).calculatePrice(t)}},{key:"calculateQuantity",value:function e(t){return babelHelpers.classPrivateFieldGet(this,k).calculateQuantity(t)}},{key:"calculateDiscount",value:function e(t){return babelHelpers.classPrivateFieldGet(this,k).calculateDiscount(t)}},{key:"calculateDiscountType",value:function e(t){return babelHelpers.classPrivateFieldGet(this,k).calculateDiscountType(t)}},{key:"calculateRowDiscount",value:function e(t){return babelHelpers.classPrivateFieldGet(this,k).calculateRowDiscount(t)}},{key:"calculateTax",value:function e(t){return babelHelpers.classPrivateFieldGet(this,k).calculateTax(t)}},{key:"calculateTaxIncluded",value:function e(t){return babelHelpers.classPrivateFieldGet(this,k).calculateTaxIncluded(t)}},{key:"calculateRowSum",value:function e(t){return babelHelpers.classPrivateFieldGet(this,k).calculateRowSum(t)}}]);return e}();function m(e,t){return babelHelpers.classPrivateFieldGet(this,U).hasOwnProperty(e)?babelHelpers.classPrivateFieldGet(this,U)[e]:t}babelHelpers.defineProperty(w,"DEFAULT_PRECISION",2);var x=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}babelHelpers.createClass(t,[{key:"calculatePriceWithoutTax",value:function e(t,i){return t}},{key:"updateResultPrices",value:function e(t){var i;if(t.isDiscountPercentage()){i=this.calculatePriceWithoutDiscount(t.getPriceNetto(),t.getDiscountRate(),a.PERCENTAGE)}else if(t.isDiscountMonetary()){i=this.calculatePriceWithoutDiscount(t.getPriceNetto(),t.getDiscountSum(),a.MONETARY)}else{i=t.getPriceExclusive()}t.setField("PRICE_EXCLUSIVE",i);if(t.isTaxIncluded()){t.setField("PRICE",i)}else{t.setField("PRICE",this.calculatePriceWithTax(i,t.getTaxRate()))}}}]);return t}(R);e.DiscountType=a;e.ProductCalculator=w;e.TaxForSumStrategy=x;e.TaxForPriceStrategy=R})(this.BX.Catalog=this.BX.Catalog||{},BX,BX.Catalog); //# sourceMappingURL=product.calculator.bundle.map.js
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.24 |
proxy
|
phpinfo
|
Settings