UNPKG

tplus-pos

Version:

pos module

119 lines (100 loc) 4.84 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.WipeChangeProcessorBlock = undefined; var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); var _createClass2 = require('babel-runtime/helpers/createClass'); var _createClass3 = _interopRequireDefault(_createClass2); require('../../commom/Challenger'); var _REAlgorithmAdapter = require('../../commom/REAlgorithmAdapter'); var _REAlgorithmAdapter2 = _interopRequireDefault(_REAlgorithmAdapter); var _SumNumberProcessor = require('../retail/summary/SumNumberProcessor'); var _SplitAmountProcessor = require('./SplitAmountProcessor'); var _tplusComponentsTouch = require('tplus-components-touch'); var _tplusPoslogin = require('tplus-poslogin'); var _Enum = require('../../commom/Enum'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * 抹零、整单金额都走这个业务逻辑 * 根据抹零金额进行明细行的抹零金额进行分配 * 1、先根据零售明细金额进行排序 * 2、再根据金额比率进行抹零金额的分配 * 3、再次触发每行的金额改变算法计算行数据 * 4、校验折扣是否满足要求 */ var WipeChangeProcessorBlock = exports.WipeChangeProcessorBlock = function () { function WipeChangeProcessorBlock() { (0, _classCallCheck3.default)(this, WipeChangeProcessorBlock); } (0, _createClass3.default)(WipeChangeProcessorBlock, null, [{ key: 'execute', value: function execute(dto, wipeChange) { $T.debugger(); var oldWipeChange = dto.WipeChange; if (oldWipeChange) { oldWipeChange = parseFloat(oldWipeChange); } else { oldWipeChange = 0; } wipeChange = parseFloat(wipeChange); var result = dto.TotalTaxAmount + oldWipeChange - wipeChange; if (!(result >= 0 && dto.TotalTaxAmount >= 0 || result <= 0 && dto.TotalTaxAmount <= 0) || dto.IdbusiType == _Enum.busiTypeID.Code_81 && result < 0 && dto.TotalTaxAmount == 0) { // 抹零前后,金额正负方向不一致的场合 _tplusComponentsTouch.Message.warn("抹零金额不能超应收金额"); return false; } if (dto.DistributionMode.Id == _Enum.DistributionMode.Code_02) { // 线上收款金额 var onlinePaymentAmount = 0; if (dto.OnlinePaymentAmount) { onlinePaymentAmount = dto.OnlinePaymentAmount; } var _result = dto.TotalTaxAmount + oldWipeChange - wipeChange - onlinePaymentAmount; if (!(_result >= 0 && dto.TotalTaxAmount >= 0 || _result <= 0 && dto.TotalTaxAmount <= 0) || dto.IdbusiType == _Enum.busiTypeID.Code_81 && _result < 0 && dto.TotalTaxAmount == 0) { // 抹零前后,金额正负方向不一致的场合 _tplusComponentsTouch.Message.warn("抹零金额+线上收款金额不能超应收金额"); return false; } } // 找零金额不可超过 var posChangeUpperAmount = (0, _tplusPoslogin.PosInitData)("posChangeUpperAmount"); if (posChangeUpperAmount) { if (Math.abs(wipeChange) > Math.abs(Number(posChangeUpperAmount))) { _tplusComponentsTouch.Message.warn("抹零金额不能超最大找零金额"); return false; } } // 恢复抹零前的数据 this.restore(dto); dto.WipeChange = wipeChange; _SplitAmountProcessor.SplitAmountProcessor.execute(dto, dto.RetailDetails, wipeChange, 'WipeChange', 'AmountTaxChange'); _SumNumberProcessor.SumNumberProcessor.execute(dto); } /** *恢复抹零前的数据 * * @static * @param {*} dto * @memberof WipeChangeProcessorBlock */ }, { key: 'restore', value: function restore(dto) { if (dto.RetailDetails) { // 恢复之前抹零前的数据 dto.RetailDetails.forEach(function (detail) { // 恢复之前的含税金额 var wipeChange = 0; if (detail.WipeChange) { wipeChange = Number(detail.WipeChange); } detail.TaxAmount = Math.Add(detail.TaxAmount, wipeChange); }); } } }]); return WipeChangeProcessorBlock; }(); /**格式化函数 */ //# sourceMappingURL=WipeChangeProcessorBlock.js.map