|
@@ -175,6 +175,8 @@ var Ration = {
|
|
|
data.updateData.ruleText = std.chapter.ruleText;
|
|
|
}
|
|
|
data.updateData.rationAssList = projectObj.project.ration_ass.CreateNewAss(std);
|
|
|
+ // calculate ration Quantity
|
|
|
+ this.CalculateQuantity(updateData);
|
|
|
newRation = data.updateData;
|
|
|
}
|
|
|
});
|
|
@@ -282,6 +284,28 @@ var Ration = {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ ration.prototype.FilterNumberFromUnit = function (unit) {
|
|
|
+ let reg = new RegExp('^[0-9]+');
|
|
|
+ if (reg.test(unit)) {
|
|
|
+ return parseInt(unit.match(reg)[0]);
|
|
|
+ } else {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ ration.prototype.CalculateQuantity = function (ration) {
|
|
|
+ // calculate ration Quantity
|
|
|
+ if (optionsOprObj.getOption(optionsOprObj.optionsTypes.GENERALOPTS, 'rationQuanACToBillsQuan')) {
|
|
|
+ let billsNode = this.project.Bills.tree.findNode(ration[this.project.masterField.ration]);
|
|
|
+ let billsQuantity = billsNode.data.quantity ? billsNode.data.quantity : 0;
|
|
|
+ if (optionsOprObj.getOption(optionsOprObj.optionsTypes.GENERALOPTS, 'rationQuanACToRationUnit')) {
|
|
|
+ ration.quantity = (billsQuantity / this.FilterNumberFromUnit(ration.unit)).toDecimal(4);
|
|
|
+ } else {
|
|
|
+ ration.quantity = billsQuantity.toDecimal(4);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
ration.prototype.replaceRation = function (ration, std) {
|
|
|
this.project.beginUpdate('replaceRation');
|
|
|
|
|
@@ -306,6 +330,8 @@ var Ration = {
|
|
|
ration.ruleText = std.chapter.ruleText;
|
|
|
}
|
|
|
ration.rationAssList = projectObj.project.ration_ass.CreateNewAss(std);
|
|
|
+ // calculate ration Quantity
|
|
|
+ this.CalculateQuantity(ration);
|
|
|
updateData.push({updateType: 'ut_update', updateData: ration});
|
|
|
this.project.push(this.getSourceType(), updateData);
|
|
|
|