UNPKG

tplus-pos

Version:

pos module

140 lines (113 loc) 4.91 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.CheckControlMinPriceProcessor = undefined; var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); var _createClass2 = require('babel-runtime/helpers/createClass'); var _createClass3 = _interopRequireDefault(_createClass2); var _symbol = require('babel-runtime/core-js/symbol'); var _symbol2 = _interopRequireDefault(_symbol); var _tplusPoslogin = require('tplus-poslogin'); require('../../../../commom/Challenger'); var _UnitTypeProcessor = require('../../../unit/UnitTypeProcessor'); var _Enum = require('../../../../commom/Enum'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var lowestPriceMethod = (0, _symbol2.default)('LowestPrice'); var checkLowestPriceMethod = (0, _symbol2.default)('CheckLowestPrice'); /** * 校验零售价是最否满足最低零售价 */ var CheckControlMinPriceProcessor = exports.CheckControlMinPriceProcessor = function () { function CheckControlMinPriceProcessor() { (0, _classCallCheck3.default)(this, CheckControlMinPriceProcessor); } (0, _createClass3.default)(CheckControlMinPriceProcessor, null, [{ key: 'execute', /** * 校验零售价是最否满足最低零售价 * @param {*} retailDetail 当前明细 * @param {*} updateByHand 是否手工更新 */ value: function execute(retailDetail, updateByHand) { // 成交价低于最低售价控制 var isControlMinPrice = (0, _tplusPoslogin.PosInitData)("IsControlMinPrice"); if (isControlMinPrice != "1") { return true; } if (retailDetail && retailDetail.Quantity <= 0) { return true; } var isOnlyControlChangeByHand = (0, _tplusPoslogin.PosInitData)("IsOnlyControlChangeByHand"); if (isOnlyControlChangeByHand && isOnlyControlChangeByHand == "1") { // 仅手工改价时控制最低售价 if (!retailDetail.IsManualChangePrice) { // 非手工改价的场合 return true; } } // if(isOnlyControlChangeByHand=="1" && !updateByHand) // { // // 当选项勾选【仅手工改价时控制最低售价】, // // 且不是手工修改单价的场合 // // 不处理 // return true; // } var result = this[checkLowestPriceMethod](retailDetail); if (!result) { JSON.setCellValue(retailDetail, "isNotPassLowestPrice", true); } return result; } }, { key: checkLowestPriceMethod, value: function value(retailDetail) { // 报价是否含税 var isPriceWithTax = (0, _tplusPoslogin.PosInitData)("isPriceWithTax"); var comparePrice = retailDetail.Price; if (isPriceWithTax) { // 报价含税的场合,取含税单价 comparePrice = retailDetail.TaxPrice; } // 最低售价 var lowestPrice = this[lowestPriceMethod](retailDetail); if (lowestPrice && comparePrice < lowestPrice) { return false; } return true; } /** * 获取当前计量单位对应的零售价 * @param {*} retailDetail */ }, { key: lowestPriceMethod, value: function value(retailDetail) { var unitLowestPrice = null; var unitType = _UnitTypeProcessor.UnitTypeProcessor.execute(retailDetail.Unit); if (_Enum.UnitType.Float == unitType) { var baseLowestPrice = JSON.getCellValue(retailDetail, "BaseLowestPrice"); if (baseLowestPrice) { var unitExchangeRate = JSON.getCellValue(retailDetail, "UnitExchangeRate"); // 主计量 var idBaseUnit = retailDetail.Inventory.Idunit; if (retailDetail.Unit.ID == idBaseUnit) { unitExchangeRate = 1; } unitLowestPrice = Math.Multiply(Number(baseLowestPrice), unitExchangeRate); } } if (Number(unitLowestPrice)) { return unitLowestPrice; } unitLowestPrice = JSON.getCellValue(retailDetail, "LowestPrice"); if (Number(unitLowestPrice)) { return unitLowestPrice; } return unitLowestPrice; } }]); return CheckControlMinPriceProcessor; }(); //# sourceMappingURL=CheckControlMinPriceProcessor.js.map