tplus-pos
Version:
pos module
98 lines (83 loc) • 2.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Format = undefined;
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require("babel-runtime/helpers/createClass");
var _createClass3 = _interopRequireDefault(_createClass2);
var _tplusPoslogin = require("tplus-poslogin");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* 公共格式化
*/
var Format = exports.Format = function () {
function Format() {
(0, _classCallCheck3.default)(this, Format);
// 单价小数位数
this.priceDecimalDigits = (0, _tplusPoslogin.PosInitData)("PricePrecision");
// 数量小数位数
this.quantityDecimalDigits = (0, _tplusPoslogin.PosInitData)("QuantityPrecision");
this.amountDecimalDigits = 2;
}
(0, _createClass3.default)(Format, [{
key: "isNumber",
value: function isNumber(obj) {
if (NaN != Number(obj)) {
return true;
} else {
return false;
}
}
/**
* 格式化数量
* @param {*数量} value
*/
}, {
key: "FormatQuantity",
value: function FormatQuantity(value) {
if (this.isNumber(value)) {
return value.Round(this.quantityDecimalDigits);
}
return value;
}
/**
* 格式化单价
* @param {*单价} value
*/
}, {
key: "FormatPrice",
value: function FormatPrice(value) {
if (this.isNumber(value)) {
return value.Round(this.priceDecimalDigits);
}
return value;
}
/**
* 格式化金额
* @param {*金额} value
*/
}, {
key: "FormatAmount",
value: function FormatAmount(value) {
if (this.isNumber(value)) {
return value.Round(this.amountDecimalDigits);
}
return value;
}
}, {
key: "Format",
value: function Format(value, precision) {
if (this.isNumber(value)) {
return value.Round(precision);
}
return value;
}
}]);
return Format;
}(); /**
* Created by majianb on 2019/4/10.
* 数量金额单价格式化算法
*/
//# sourceMappingURL=Format.js.map