我试图计算SSC
,它是通过将basicSalary
乘以0.07%
计算出来的,在totalEarnings
、totalDeductions
和netSalary
中,它通过对字段进行计算工作得很好,但在SSC
中,将basicSalary
乘以0.07%
会产生错误expression expected
,这是不是意味着我只能使用字段?
const mongoose = require("mongoose");
const salariesSchema = mongoose.Schema({
basicSalary: { type: Number, default: 0, required: true },
accomodation: { type: Number, default: 0 },
transportation: { type: Number, default: 0 },
bonus: { type: Number, default: 0 },
SSC: { type: Number, default: function(){
return this.basicSalary * 0.07%
} },
incomeTax: { type: Number, default: 0 },
medicalInsurance: { type: Number, default: 0 },
loan: { type: Number, default: 0, default: null },
totalEarnings: {
type: Number,
default: function () {
return (
this.basicSalary + this.accomodation + this.transportation + this.bonus
);
},
},
totalDeductions: {
type: Number,
defualt: function () {
return this.SSC - this.incomeTax - this.medicalInsurance - this.loan;
},
},
netSalary: {
type: Number,
default: function () {
return this.totalEarnings - this.totalDeductions;
},
},
});
module.exports = mongoose.model("salarie", salariesSchema);
1条答案
按热度按时间os8fio9y1#
如果要计算7%的值,应写出: