UNPKG

tplus-pos

Version:

pos module

72 lines (64 loc) 1.86 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CalculateTaxAmountByAmountsetting = CalculateTaxAmountByAmountsetting; var _Format = require("./Format"); require("../commom/Challenger"); /** * 按照金额配置计算实收金额 * @param {*} taxAmount * @param {*} amountSetting * @param {*} amountSettingEnum * @auther 马坚 */ function CalculateTaxAmountByAmountsetting(taxAmount, amountSetting, amountSettingEnum) { $T.debugger(); var returnValue = taxAmount; // 是否为负数 var isNegative = false; if (!taxAmount) { return returnValue; } taxAmount = Number(taxAmount); if (taxAmount < 0) { isNegative = true; } taxAmount = Math.abs(taxAmount); var _format = new _Format.Format(); if (amountSetting === amountSettingEnum.Code_01) { // 实款实收 returnValue = taxAmount; } if (amountSetting === amountSettingEnum.Code_02) { // 分四舍五入 returnValue = _format.Format(taxAmount, 1); } if (amountSetting === amountSettingEnum.Code_03) { // 角四舍五入 returnValue = _format.Format(taxAmount, 0); } if (amountSetting === amountSettingEnum.Code_04) { // 角舍去 returnValue = Math.floor(taxAmount); } if (amountSetting === amountSettingEnum.Code_05) { // 分舍去 var temp1 = Math.Multiply(taxAmount, 10); returnValue = Math.Divide(Math.floor(temp1), 10); } if (amountSetting === amountSettingEnum.Code_06) { // 角进位 returnValue = Math.ceil(taxAmount); } if (amountSetting === amountSettingEnum.Code_07) { // 分进位 var _temp = Math.Multiply(taxAmount, 10); returnValue = Math.Divide(Math.ceil(_temp), 10); } if (isNegative) { returnValue = -1 * Number(returnValue); } return returnValue; } //# sourceMappingURL=CalculateTaxAmountByAmountsetting.js.map