BilItemModel.prototype=new MathModel;BilItemModel.Type="BILItm";
BilItemModel.factory=function(c){var a=new BilItemModel;c&&(a.Info=MathModelReference.factory(c.ModelKey),a.ItemCode.setProperties(c.ItemCode),a.RequestComment.setProperties(c.RequestComment),a.ReqRef.setProperties(c.ReqRef),a.Description.setProperties(c.Description),a.Unit.setProperties(c.Unit),a.Quantity.setProperties(c.Quantity),a.CostPrice.setProperties(c.CostPrice),a.CeilingPrice.setProperties(c.CeilingPrice),a.SalesPrice.setProperties(c.SalesPrice),a.CostPriceTotal.setProperties(c.CostPriceTotal),
a.CeilingPriceTotal.setProperties(c.CeilingPriceTotal),a.SalesPriceTotal.setProperties(c.SalesPriceTotal),c.NextModelKey&&(a.NextModelInfo=MathModelReference.factory(c.NextModelKey)));$.modelStorage.add(a);return a};
function BilItemModel(c){this.init(c);this.RequestComment=MathModelProperty.stringPropertyFactory();this.ItemCode=MathModelProperty.stringPropertyFactory();this.ReqRef=MathModelProperty.stringPropertyFactory();this.Description=MathModelProperty.stringPropertyFactory();this.Unit=MathModelProperty.stringPropertyFactory();this.Quantity=MathModelProperty.decimalPropertyFactory(MathModelProperty.FormatTypes.DecimalIntermedium);this.CostPrice=MathModelProperty.decimalPropertyFactory(MathModelProperty.FormatTypes.DecimalIntermedium);
this.CeilingPrice=MathModelProperty.decimalPropertyFactory(MathModelProperty.FormatTypes.DecimalIntermedium);this.SalesPrice=MathModelProperty.decimalPropertyFactory(MathModelProperty.FormatTypes.DecimalIntermedium);this.CostPriceTotal=MathModelProperty.decimalPropertyFactory();this.CeilingPriceTotal=MathModelProperty.decimalPropertyFactory();this.SalesPriceTotal=MathModelProperty.decimalPropertyFactory();BilItemModel.prototype._loadProperty=function(a,d){a===MathModel.Variables.Quantity?this.Quantity.load(d):
a===MathModel.Variables.CostPrice?this.CostPrice.load(d):a===MathModel.Variables.CostPriceTotal?this.CostPriceTotal.load(d):a===MathModel.Variables.CeilingPrice?this.CeilingPrice.load(d):a===MathModel.Variables.CeilingPriceTotal?this.CeilingPriceTotal.load(d):a===MathModel.Variables.SalesPrice?this.SalesPrice.load(d):a===MathModel.Variables.SalesPriceTotal?this.SalesPriceTotal.load(d):a==MathModel.Variables.ItemCode?this.ItemCode.load(d):a==MathModel.Variables.ReqRef?this.ReqRef.load(d):a==MathModel.Variables.Description?
this.Description.load(d):a==MathModel.Variables.Unit?this.Unit.load(d):a==MathModel.Variables.RequestComment&&this.RequestComment.load(d)};BilItemModel.prototype.calculateCostPriceTotal=function(){var a=this.Quantity.get(BigDecimal.ZERO),d=this.CostPrice.get(BigDecimal.ZERO);return $.multiplyDecimals(a,d)};BilItemModel.prototype.calculateCeilingPriceTotal=function(){var a=this.Quantity.get(BigDecimal.ZERO),d=this.CeilingPrice.get(BigDecimal.ZERO);return $.multiplyDecimals(a,d)};BilItemModel.prototype.calculateSalesPriceTotal=
function(){var a=this.Quantity.get(BigDecimal.ZERO),d=this.SalesPrice.get(BigDecimal.ZERO);return $.multiplyDecimals(a,d)};BilItemModel.prototype.updateCostPriceTotal=function(){var a=this.CostPriceTotal.get(),d=this.calculateCostPriceTotal(),b=void 0;this.CostPriceTotal.set(d);d?b=a?d.subtract(a):d:a&&(b=a.negate());return b};BilItemModel.prototype.updateCeilingPriceTotal=function(){var a=this.CeilingPriceTotal.get(),d=this.calculateCeilingPriceTotal(),b=void 0;this.CeilingPriceTotal.set(d);d?b=
a?d.subtract(a):d:a&&(b=a.negate());return b};BilItemModel.prototype.updateSalesPriceTotal=function(){var a=this.SalesPriceTotal.get(),d=this.calculateSalesPriceTotal(),b=void 0;this.SalesPriceTotal.set(d);d?b=a?d.subtract(a):d:a&&(b=a.negate());return b};BilItemModel.prototype.createTotalValues=function(){return TotalValuesModel.factory({CstPT:this.CostPriceTotal.get(BigDecimal.ZERO),ClnPT:this.CeilingPriceTotal.get(BigDecimal.ZERO),SlsPT:this.SalesPriceTotal.get(BigDecimal.ZERO)})};BilItemModel.prototype.updateValues=
function(a){a&&(this.Info=MathModelReference.factory(a.ModelKey),this.ItemCode.set(a.ItemCode.Value),this.ReqRef.set(a.ReqRef.Value),this.Description.set(a.Description.Value),this.Unit.set(a.Unit.Value),this.Quantity.set(a.Quantity.Value),this.CostPrice.set(a.CostPrice.Value),this.CeilingPrice.set(a.CeilingPrice.Value),this.SalesPrice.set(a.SalesPrice.Value),this.CostPriceTotal.set(a.CostPriceTotal.Value),this.CeilingPriceTotal.set(a.CeilingPriceTotal.Value),this.SalesPriceTotal.set(a.SalesPriceTotal.Value),
this.RequestComment.ElementId=a.RequestComment.ElementId,this.RequestComment.set(a.RequestComment.Value))}}BilChapterModel.prototype=new MathModel;BilChapterModel.Type="BILChp";
BilChapterModel.factory=function(c){var a=new BilChapterModel;c&&(a.Info=MathModelReference.factory(c.ModelKey),a.ItemCode.setProperties(c.ItemCode),a.Description.setProperties(c.Description),a.CostPriceTotal.setProperties(c.CostPriceTotal),a.CeilingPriceTotal.setProperties(c.CeilingPriceTotal),a.SalesPriceTotal.setProperties(c.SalesPriceTotal),c.NextModelKey&&(a.NextModelInfo=MathModelReference.factory(c.NextModelKey)));$.modelStorage.add(a);return a};
function BilChapterModel(c){this.init(c);this.ItemCode=MathModelProperty.stringPropertyFactory();this.Description=MathModelProperty.stringPropertyFactory();this.CostPriceTotal=MathModelProperty.decimalPropertyFactory();this.CeilingPriceTotal=MathModelProperty.decimalPropertyFactory();this.SalesPriceTotal=MathModelProperty.decimalPropertyFactory();BilChapterModel.prototype._loadProperty=function(a,d){a===MathModel.Variables.CostPriceTotal?this.CostPriceTotal.load(d):a===MathModel.Variables.CeilingPriceTotal?
this.CeilingPriceTotal.load(d):a===MathModel.Variables.SalesPriceTotal?this.SalesPriceTotal.load(d):a==MathModel.Variables.ItemCode?this.ItemCode.load(d):a==MathModel.Variables.Description&&this.Description.load(d)};BilChapterModel.prototype.updateCostPriceTotal=function(a){var d=this.CostPriceTotal.get(),b=BigDecimal.ZERO;if(d){var e=$.sumDecimals(d,a),b=e?a:d.negate();this.CostPriceTotal.set(e)}return b};BilChapterModel.prototype.updateCeilingPriceTotal=function(a){var d=this.CeilingPriceTotal.get(),
b=BigDecimal.ZERO;if(d){var e=$.sumDecimals(d,a),b=e?a:d.negate();this.CeilingPriceTotal.set(e)}return b};BilChapterModel.prototype.updateSalesPriceTotal=function(a){var d=this.SalesPriceTotal.get(),b=BigDecimal.ZERO;if(d){var e=$.sumDecimals(d,a),b=e?a:d.negate();this.SalesPriceTotal.set(e)}return b};BilChapterModel.prototype.add=function(a){var d=new TotalValuesModel;d.CostPriceTotal=this.updateCostPriceTotal(a.CostPriceTotal);d.CeilingPriceTotal=this.updateCeilingPriceTotal(a.CeilingPriceTotal);
d.SalesPriceTotal=this.updateSalesPriceTotal(a.SalesPriceTotal);return d};BilChapterModel.prototype.subtract=function(a){this.updateCostPriceTotal(a.CostPriceTotal.negate());this.updateCeilingPriceTotal(a.CeilingPriceTotal.negate());this.updateSalesPriceTotal(a.SalesPriceTotal.negate())};BilChapterModel.prototype.createTotalValues=function(){return TotalValuesModel.factory({CstPT:this.CostPriceTotal.get(BigDecimal.ZERO),ClnPT:this.CeilingPriceTotal.get(BigDecimal.ZERO),SlsPT:this.SalesPriceTotal.get(BigDecimal.ZERO)})};
BilChapterModel.prototype.updateValues=function(a){a&&(this.Info=MathModelReference.factory(a.ModelKey),this.ItemCode.set(a.ItemCode.Value),this.Description.set(a.Description.Value),this.CostPriceTotal.set(a.CostPriceTotal.Value),this.CeilingPriceTotal.set(a.CeilingPriceTotal.Value),this.SalesPriceTotal.set(a.SalesPriceTotal.Value))}}BilTotalModel.prototype=new MathModel;BilTotalModel.Type="BILTtl";
function BilTotalModel(c){this.init(c);this.CostPriceTotal=MathModelProperty.decimalPropertyFactory();this.CeilingPriceTotal=MathModelProperty.decimalPropertyFactory();this.SalesPriceTotal=MathModelProperty.decimalPropertyFactory();BilTotalModel.prototype._loadProperty=function(a,d){a===MathModel.Variables.CostPriceTotal?this.CostPriceTotal.load(d):a===MathModel.Variables.CeilingPriceTotal?this.CeilingPriceTotal.load(d):a===MathModel.Variables.SalesPriceTotal&&this.SalesPriceTotal.load(d)};BilTotalModel.prototype.updateCostPriceTotal=
function(a,d){var b=this.CostPriceTotal.get(),e=BigDecimal.ZERO;if(b){var f=$.sumDecimals(b,a),e=f?a:b.negate();this.CostPriceTotal.set(f)}else d&&(e=a,this.CostPriceTotal.set(a));return e};BilTotalModel.prototype.updateCeilingPriceTotal=function(a,d){var b=this.CeilingPriceTotal.get(),e=BigDecimal.ZERO;if(b){var f=$.sumDecimals(b,a),e=f?a:b.negate();this.CeilingPriceTotal.set(f)}else d&&(e=a,this.CeilingPriceTotal.set(a));return e};BilTotalModel.prototype.updateSalesPriceTotal=function(a,d){var b=
this.SalesPriceTotal.get(),e=BigDecimal.ZERO;if(b){var f=$.sumDecimals(b,a),e=f?a:b.negate();this.SalesPriceTotal.set(f)}else d&&(e=a,this.SalesPriceTotal.set(a));return e};BilTotalModel.prototype.add=function(a){var d=new TotalValuesModel;d.CostPriceTotal=this.updateCostPriceTotal(a.CostPriceTotal);d.CeilingPriceTotal=this.updateCeilingPriceTotal(a.CeilingPriceTotal);d.SalesPriceTotal=this.updateSalesPriceTotal(a.SalesPriceTotal);return d};BilTotalModel.prototype.addTotalValues=function(a){var d=
new TotalValuesModel;d.CostPriceTotal=this.updateCostPriceTotal(a.CostPriceTotal,!0);d.CeilingPriceTotal=this.updateCeilingPriceTotal(a.CeilingPriceTotal,!0);d.SalesPriceTotal=this.updateSalesPriceTotal(a.SalesPriceTotal,!0);return d};BilTotalModel.prototype.subtract=function(a){this.updateCostPriceTotal(a.CostPriceTotal.negate());this.updateCeilingPriceTotal(a.CeilingPriceTotal.negate());this.updateSalesPriceTotal(a.SalesPriceTotal.negate())}}BioQuestionModel.prototype=new MathModel;
BioQuestionModel.Type="BioQ";BioQuestionModel.factory=function(c){var a=new BioQuestionModel;c&&(a.TotalValues=TotalValuesModel.factory(c.TotalValues),a.Info=MathModelReference.factory(c.ModelKey),a.NextModelInfo=MathModelReference.factory(c.NextModelKey));$.modelStorage.add(a);return a};
BioQuestionModel.removeLots=function(c){var a=$.modelStorage.getByType(BioQuestionModel.Type);if(a)for(var d in a){var b=a[d],e=b.TotalValues.LotCode.get();e!==MathAction.Constants.ALL_LOT_KEY&&-1<$.inArray(e,c)&&b.TotalValues.LotCode.set(MathAction.Constants.ALL_LOT_KEY)}};
function BioQuestionModel(c){this.init(c);this.TotalValues=new TotalValuesModel;BioQuestionModel.prototype.updateCostPriceTotal=function(a){this.TotalValues.updateCostPriceTotal(a)};BioQuestionModel.prototype.updateCeilingPriceTotal=function(a){this.TotalValues.updateCeilingPriceTotal(a)};BioQuestionModel.prototype.updateSalesPriceTotal=function(a){this.TotalValues.updateSalesPriceTotal(a)};BioQuestionModel.prototype.addItemValues=function(a){this.TotalValues.add(a)};BioQuestionModel.prototype.removeItemValues=
function(a){this.TotalValues.subtract(a)}}BioSectionModel.prototype=new MathModel;BioSectionModel.Type="BioS";BioSectionModel.factory=function(c){var a=new BioSectionModel;if(c){a.LotCode.set(c.Lot);if(c.TotalValues)for(var d=0,b=c.TotalValues.length;d<b;d++){var e=TotalValuesModel.factory(c.TotalValues[d]);a.TotalValues[e.LotCode.get()]=e}a.Info=MathModelReference.factory(c.ModelKey);a.NextModelInfo=MathModelReference.factory(c.NextModelKey)}$.modelStorage.add(a);return a};
BioSectionModel.addLot=function(c){var a=$.modelStorage.getByType(BioSectionModel.Type);if(a)for(var d in a)TotalValuesModel.addLot(a[d].TotalValues,c)};BioSectionModel.removeLots=function(c){var a=$.modelStorage.getByType(BioSectionModel.Type);if(a)for(var d in a){var b=a[d],e=b.LotCode.get();TotalValuesModel.removeLots(b.TotalValues,c);e!==MathAction.Constants.ALL_LOT_KEY&&-1<$.inArray(e,c)&&b.LotCode.set(MathAction.Constants.ALL_LOT_KEY)}};
function BioSectionModel(c){this.init(c);this.LotCode=MathModelProperty.stringPropertyFactory();this.TotalValues={};BioSectionModel.prototype.changeLotValues=function(a){var d=this.LotCode.get(),b=this.TotalValues[a];d!==MathAction.Constants.ALL_LOT_KEY&&(d=this.TotalValues[d],d.add(b));a!==MathAction.Constants.ALL_LOT_KEY&&(d=this.TotalValues[a],d.subtract(b))};BioSectionModel.prototype.changeTotalValues=function(a,d){var b={},e=this.TotalValues,f=e[MathAction.Constants.ALL_LOT_KEY];if(d===MathAction.Constants.ALL_LOT_KEY)for(var c in e){if(c!==
MathAction.Constants.ALL_LOT_KEY){var k=e[c],h=k.clone();h.setNegative();k.clearValues();b[c]=h}}else if(a===MathAction.Constants.ALL_LOT_KEY)for(c in e)k=e[c],h=void 0,c===d?(h=f.diff(k),h.LotCode.set(d),k.CostPriceTotal=f.CostPriceTotal,k.CeilingPriceTotal=f.CeilingPriceTotal,k.SalesPriceTotal=f.SalesPriceTotal):c!==MathAction.Constants.ALL_LOT_KEY&&(h=k.clone(),h.setNegative(),k.clearValues()),h&&(b[c]=h);else c=e[a],e=e[d],h=c.clone(),h.setNegative(),b[a]=h,c.clearValues(),e.add(f),h=e.clone(),
b[d]=h;return b};BioSectionModel.prototype.changeToLot=function(a){var d=this.LotCode.get(),b=this.TotalValues,e=b[MathAction.Constants.ALL_LOT_KEY];this.LotCode.set(a);if(a===MathAction.Constants.ALL_LOT_KEY)for(var c in b)c!==MathAction.Constants.ALL_LOT_KEY&&b[c].clearValues();else if(d===MathAction.Constants.ALL_LOT_KEY)for(c in b)d=b[c],c===a?(d.CostPriceTotal=e.CostPriceTotal,d.CeilingPriceTotal=e.CeilingPriceTotal,d.SalesPriceTotal=e.SalesPriceTotal):c!==MathAction.Constants.ALL_LOT_KEY&&d.clearValues();
else b[d].clearValues(),b[a].add(e)};BioSectionModel.prototype.updateLotValues=function(a,d){var b;b=d.LotCode.get();b!==MathAction.Constants.ALL_LOT_KEY&&(b=this.TotalValues[b],b.add(d));a!==MathAction.Constants.ALL_LOT_KEY&&(b=this.TotalValues[a],b.subtract(d))};BioSectionModel.prototype.updateCostPriceTotal=function(a,d){var b;void 0!=this.TotalValues&&(b=this.TotalValues[d],b.updateCostPriceTotal(a),d!=MathAction.Constants.ALL_LOT_KEY&&(b=this.TotalValues[MathAction.Constants.ALL_LOT_KEY],b.updateCostPriceTotal(a)))};
BioSectionModel.prototype.updateCeilingPriceTotal=function(a,d){var b;void 0!=this.TotalValues&&(b=this.TotalValues[d],b.updateCeilingPriceTotal(a),d!=MathAction.Constants.ALL_LOT_KEY&&(b=this.TotalValues[MathAction.Constants.ALL_LOT_KEY],b.updateCeilingPriceTotal(a)))};BioSectionModel.prototype.updateSalesPriceTotal=function(a,d){var b;void 0!=this.TotalValues&&(b=this.TotalValues[d],b.updateSalesPriceTotal(a),d!=MathAction.Constants.ALL_LOT_KEY&&(b=this.TotalValues[MathAction.Constants.ALL_LOT_KEY],
b.updateSalesPriceTotal(a)))};BioSectionModel.prototype.addItemValues=function(a){var d,b=a.LotCode.get();void 0!=this.TotalValues&&(d=this.TotalValues[b],d.add(a),b!=MathAction.Constants.ALL_LOT_KEY&&(d=this.TotalValues[MathAction.Constants.ALL_LOT_KEY],d.add(a)))};BioSectionModel.prototype.addItemTotalValues=function(a){TotalValuesModel.addTotals(this.TotalValues,a)};BioSectionModel.prototype.removeItemValues=function(a){var d,b=a.LotCode.get();void 0!=this.TotalValues&&(d=this.TotalValues[b],d.subtract(a),
b!=MathAction.Constants.ALL_LOT_KEY&&(d=this.TotalValues[MathAction.Constants.ALL_LOT_KEY],d.subtract(a)))};BioSectionModel.prototype.removeItemTotalValues=function(a){TotalValuesModel.subtractTotals(this.TotalValues,a)}}BiocModel.prototype=new MathModel;BiocModel.Type="Bioc";
BiocModel.factory=function(c){var a=new BiocModel;if(c){if(c.TotalValues)for(var d=0,b=c.TotalValues.length;d<b;d++){var e=TotalValuesModel.factory(c.TotalValues[d]);a.TotalValues[e.LotCode.get()]=e}a.Info=MathModelReference.factory(c.ModelKey);a.NextModelInfo=MathModelReference.factory(c.NextModelKey)}$.modelStorage.add(a);return a};BiocModel.addLot=function(c){var a=$.modelStorage.getByType(BiocModel.Type);if(a)for(var d in a)TotalValuesModel.addLot(a[d].TotalValues,c);BioSectionModel.addLot(c)};
BiocModel.removeLots=function(c){var a=$.modelStorage.getByType(BiocModel.Type);if(a)for(var d in a)TotalValuesModel.removeLots(a[d].TotalValues,c);BioSectionModel.removeLots(c);BioQuestionModel.removeLots(c)};
function BiocModel(c){this.init(c);this.TotalValues={};BiocModel.prototype.updateCostPriceTotal=function(a,d){var b;void 0!=this.TotalValues&&(b=this.TotalValues[d],b.updateCostPriceTotal(a),d!=MathAction.Constants.ALL_LOT_KEY&&(b=this.TotalValues[MathAction.Constants.ALL_LOT_KEY],b.updateCostPriceTotal(a)))};BiocModel.prototype.updateCeilingPriceTotal=function(a,d){var b;void 0!=this.TotalValues&&(b=this.TotalValues[d],b.updateCeilingPriceTotal(a),d!=MathAction.Constants.ALL_LOT_KEY&&(b=this.TotalValues[MathAction.Constants.ALL_LOT_KEY],
b.updateCeilingPriceTotal(a)))};BiocModel.prototype.updateSalesPriceTotal=function(a,d){var b;void 0!=this.TotalValues&&(b=this.TotalValues[d],b.updateSalesPriceTotal(a),d!=MathAction.Constants.ALL_LOT_KEY&&(b=this.TotalValues[MathAction.Constants.ALL_LOT_KEY],b.updateSalesPriceTotal(a)))};BiocModel.prototype.updateLotValues=function(a,d){var b;b=d.LotCode.get();b!==MathAction.Constants.ALL_LOT_KEY&&(b=this.TotalValues[b],b.add(d));a!==MathAction.Constants.ALL_LOT_KEY&&(b=this.TotalValues[a],b.subtract(d))};
BiocModel.prototype.addItemValues=function(a){var d,b=a.LotCode.get();void 0!=this.TotalValues&&(d=this.TotalValues[b],d.add(a),b!=MathAction.Constants.ALL_LOT_KEY&&(d=this.TotalValues[MathAction.Constants.ALL_LOT_KEY],d.add(a)))};BiocModel.prototype.removeItemValues=function(a){var d,b=a.LotCode.get();void 0!=this.TotalValues&&(d=this.TotalValues[b],d.subtract(a),b!=MathAction.Constants.ALL_LOT_KEY&&(d=this.TotalValues[MathAction.Constants.ALL_LOT_KEY],d.subtract(a)))};BiocModel.prototype.removeItemTotalValues=
function(a){TotalValuesModel.subtractTotals(this.TotalValues,a)};BiocModel.prototype.addItemTotalValues=function(a){TotalValuesModel.addTotals(this.TotalValues,a)}}RequestDataModel.prototype=new MathModel;RequestDataModel.Type="ReqDt";
RequestDataModel.factory=function(c){var a=new RequestDataModel;if(c){if(c.TotalValues)for(var d=0,b=c.TotalValues.length;d<b;d++){var e=TotalValuesModel.factory(c.TotalValues[d]);a.TotalValues[e.LotCode.get()]=e}a.Info=MathModelReference.factory(c.ModelKey);a.NextModelInfo=MathModelReference.factory(c.NextModelKey)}$.modelStorage.add(a);return a};
RequestDataModel.addLot=function(c){var a=$.modelStorage.getByType(RequestDataModel.Type);if(a)for(var d in a)TotalValuesModel.addLot(a[d].TotalValues,c);BiocModel.addLot(c)};RequestDataModel.removeLots=function(c){var a=$.modelStorage.getByType(RequestDataModel.Type);if(a)for(var d in a)TotalValuesModel.removeLots(a[d].TotalValues,c);BiocModel.removeLots(c)};
function RequestDataModel(c){this.init(c);this.TotalValues={};RequestDataModel.prototype.updateCostPriceTotal=function(a,d){var b;void 0!=this.TotalValues&&(b=this.TotalValues[d],b.updateCostPriceTotal(a),d!=MathAction.Constants.ALL_LOT_KEY&&(b=this.TotalValues[MathAction.Constants.ALL_LOT_KEY],b.updateCostPriceTotal(a)))};RequestDataModel.prototype.updateCeilingPriceTotal=function(a,d){var b;void 0!=this.TotalValues&&(b=this.TotalValues[d],b.updateCeilingPriceTotal(a),d!=MathAction.Constants.ALL_LOT_KEY&&
(b=this.TotalValues[MathAction.Constants.ALL_LOT_KEY],b.updateCeilingPriceTotal(a)))};RequestDataModel.prototype.updateSalesPriceTotal=function(a,d){var b;void 0!=this.TotalValues&&(b=this.TotalValues[d],b.updateSalesPriceTotal(a),d!=MathAction.Constants.ALL_LOT_KEY&&(b=this.TotalValues[MathAction.Constants.ALL_LOT_KEY],b.updateSalesPriceTotal(a)))};RequestDataModel.prototype.updateLotValues=function(a,d){var b;b=d.LotCode.get();b!==MathAction.Constants.ALL_LOT_KEY&&(b=this.TotalValues[b],b.add(d));
a!==MathAction.Constants.ALL_LOT_KEY&&(b=this.TotalValues[a],b.subtract(d))};RequestDataModel.prototype.addItemValues=function(a){var d,b=a.LotCode.get();void 0!=this.TotalValues&&(d=this.TotalValues[b],d.add(a),b!=MathAction.Constants.ALL_LOT_KEY&&(d=this.TotalValues[MathAction.Constants.ALL_LOT_KEY],d.add(a)))};RequestDataModel.prototype.removeItemValues=function(a){var d,b=a.LotCode.get();void 0!=this.TotalValues&&(d=this.TotalValues[b],d.subtract(a),b!=MathAction.Constants.ALL_LOT_KEY&&(d=this.TotalValues[MathAction.Constants.ALL_LOT_KEY],
d.subtract(a)))};RequestDataModel.prototype.removeItemTotalValues=function(a){TotalValuesModel.subtractTotals(this.TotalValues,a)};RequestDataModel.prototype.addItemTotalValues=function(a){TotalValuesModel.addTotals(this.TotalValues,a)}}ProcedureRequestModel.prototype=new MathModel;ProcedureRequestModel.Type="PrReq";
ProcedureRequestModel.factory=function(c){var a=new ProcedureRequestModel;if(c&&(a.Info=MathModelReference.factory(c.ModelKey),a.NextModelInfo=MathModelReference.factory(c.NextModelKey),a.BasePrice.setProperties(c.BasePrice),a.BasePriceVAT.setProperties(c.BasePriceVAT),a.DefineBasePrice.setProperties(c.DefineBasePrice),a.MinimumPrice.setProperties(c.MinimumPrice),a.DefineMinimumPrice.setProperties(c.DefineMinimumPrice),a.DefineLots.setProperties(c.DefineLots),a.DefineLotsPrices.setProperties(c.DefineLotsPrices),
a.UsePriceListValues.setProperties(c.UsePriceListValues),a.LotsBasePrice.setProperties(c.LotsBasePrice),a.LotsBasePriceVAT.setProperties(c.LotsBasePriceVAT),a.LotsMinimumPrice.setProperties(c.LotsMinimumPrice),c.Lots))for(var d=0,b=c.Lots.length;d<b;d++){var e=LotModel.factory(c.Lots[d]);a.Lots.Value[e.Info.ModelId]=e}$.modelStorage.add(a);return a};
function ProcedureRequestModel(c){function a(a,b){var e=a.UsePriceListValues.get(!1),c=a.DefineLots.get(!1),g=a.DefineLotsPrices.get(!1);e&&clearViewModelsByName("LotValues");if(c&&g&&a.Lots){var c=BigDecimal.ZERO,k;for(k in a.Lots.get())if(g=a.Lots.get(k))if(e){var h=b.TotalValues[k],c=c.add(h.CeilingPriceTotal);g.BasePrice.set(h.CeilingPriceTotal);g.BasePrice.makeReadOnly()}else c=c.add(g.BasePrice.get(BigDecimal.ZERO)),g.BasePrice.removeReadOnly();a.LotsBasePrice.set(c)}}this.init(c);this.BasePrice=
MathModelProperty.decimalPropertyFactory();this.BasePriceVAT=MathModelProperty.decimalPropertyFactory();this.DefineBasePrice=MathModelProperty.booleanPropertyFactory(MathModelProperty.FormatTypes.BooleanRadio);this.MinimumPrice=MathModelProperty.decimalPropertyFactory();this.DefineMinimumPrice=MathModelProperty.booleanPropertyFactory(MathModelProperty.FormatTypes.BooleanRadio);this.DefineLots=MathModelProperty.booleanPropertyFactory(MathModelProperty.FormatTypes.BooleanRadio);this.DefineLotsPrices=
MathModelProperty.booleanPropertyFactory(MathModelProperty.FormatTypes.BooleanRadio);this.UsePriceListValues=MathModelProperty.booleanPropertyFactory();this.LotsBasePrice=MathModelProperty.decimalPropertyFactory();this.LotsBasePriceVAT=MathModelProperty.decimalPropertyFactory();this.LotsMinimumPrice=MathModelProperty.decimalPropertyFactory();this.Lots=MathModelProperty.listPropertyFactory();ProcedureRequestModel.prototype.addLotModel=function(a){var b=a.Info.ModelId;this.Lots.get()[b]=a};ProcedureRequestModel.prototype.removeLots=
function(a){for(var b=0,e=a.length;b<e;b++){var c=a[b],g=this.Lots.get(c),k=BigDecimal.ZERO.subtract(g.BasePriceVAT.get(BigDecimal.ZERO)),h=BigDecimal.ZERO.subtract(g.BasePrice.get(BigDecimal.ZERO)),g=BigDecimal.ZERO.subtract(g.MinimumPrice.get(BigDecimal.ZERO));this.updateBasePriceVAT(k);this.updateBasePrice(h);this.updateMinimumPrice(g);this.Lots.get()[c]=void 0}};ProcedureRequestModel.prototype.updateBasePrice=function(a){var b=this.DefineBasePrice.get(!1),e=this.DefineLotsPrices.get(!1),c;c=this.LotsBasePrice.get(BigDecimal.ZERO);
c=c.add(a);this.LotsBasePrice.set(c);b&&e&&(c=this.BasePrice.get(BigDecimal.ZERO),c=c.add(a),this.BasePrice.set(c))};ProcedureRequestModel.prototype.updateBasePriceVAT=function(a){var b=this.DefineBasePrice.get(!1),e=this.DefineLotsPrices.get(!1),c;c=this.LotsBasePriceVAT.get(BigDecimal.ZERO);this.LotsBasePriceVAT.set(c+a);b&&e&&(c=this.BasePriceVAT.get(BigDecimal.ZERO),a=c.add(a),this.BasePriceVAT.set(a))};ProcedureRequestModel.prototype.updateMinimumPrice=function(a){var b=this.DefineMinimumPrice.get(!1),
e=this.DefineLotsPrices.get(!1),c;c=this.LotsMinimumPrice.get(BigDecimal.ZERO);c=c.add(a);this.LotsMinimumPrice.set(c);b&&e&&(c=this.MinimumPrice.get(BigDecimal.ZERO),c=c.add(a),this.MinimumPrice.set(c))};ProcedureRequestModel.prototype.updateLotBasePrice=function(a,b){if(this.UsePriceListValues.get(!1)){var e=this.BasePrice.get(BigDecimal.ZERO).add(a),c=this.DefineBasePrice.get(!1),g=this.DefineLots.get(!1),k=this.DefineLotsPrices.get(!1);g&&k&&b!==MathAction.Constants.ALL_LOT_KEY&&(g=this.Lots.get(b),
void 0!=g&&(g.updateBasePrice(a),this.LotsBasePrice.set(e)));c&&this.BasePrice.set(e)}};ProcedureRequestModel.prototype.updateDefineBasePrice=function(){this.DefineBasePrice.get(!1);this.DefineLotsPrices.get(!1);defLots=this.DefineLots.get(!1)};ProcedureRequestModel.prototype.updateDefineMinimumPrice=function(){var a=this.DefineMinimumPrice.get(!1),b=this.DefineLotsPrices.get(!1);a&&b&&(a=this.LotsMinimumPrice.get(BigDecimal.ZERO),this.MinimumPrice.set(a))};ProcedureRequestModel.prototype.updateDefineLots=
function(){var a=this.DefineLots.get(!1),b=this.DefineLotsPrices.get(!1);a&&b?(this.BasePrice.makeReadOnly(),this.BasePrice.removeModelBind(),this.BasePrice.set(BigDecimal.ZERO),this.BasePriceVAT.makeReadOnly(),this.BasePriceVAT.removeModelBind(),this.MinimumPrice.makeReadOnly(),this.MinimumPrice.removeModelBind()):(this.BasePrice.removeReadOnly(),this.BasePrice.addModelBind(),this.BasePriceVAT.removeReadOnly(),this.BasePriceVAT.addModelBind(),this.MinimumPrice.removeReadOnly(),this.MinimumPrice.addModelBind())};
ProcedureRequestModel.prototype.updateDefineLotsPrices=function(){var d=this.UsePriceListValues.get(!1),b=this.DefineLotsPrices.get(!1),e=$.modelStorage.getChildModel(RequestDataModel.Type,this.Info.ModelKey);if(b){a(this,e);this.BasePrice.set(this.LotsBasePrice.get(BigDecimal.ZERO));this.BasePrice.makeReadOnly();this.BasePrice.removeModelBind();d=this.DefineLots.get(!1);b=this.DefineLotsPrices.get(!1);if(d&&b&&this.Lots){for(var c in this.Lots.get())if(d=this.Lots.get(c))d.BasePriceVAT.set(BigDecimal.ZERO),
d.BasePriceVAT.removeReadOnly();this.LotsBasePriceVAT.set(BigDecimal.ZERO)}this.BasePriceVAT.set(this.LotsBasePriceVAT.get(BigDecimal.ZERO));this.BasePriceVAT.makeReadOnly();this.BasePriceVAT.removeModelBind();c=this.DefineLots.get(!1);d=this.DefineLotsPrices.get(!1);if(c&&d&&this.Lots){for(var g in this.Lots.get())if(c=this.Lots.get(g))c.MinimumPrice.set(BigDecimal.ZERO),c.MinimumPrice.removeReadOnly();this.LotsMinimumPrice.set(BigDecimal.ZERO)}this.MinimumPrice.set(BigDecimal.ZERO);this.MinimumPrice.makeReadOnly();
this.MinimumPrice.removeModelBind()}else d||(this.BasePrice.set(BigDecimal.ZERO),this.BasePrice.removeReadOnly(),this.BasePrice.addModelBind()),this.BasePriceVAT.set(BigDecimal.ZERO),this.BasePriceVAT.removeReadOnly(),this.BasePriceVAT.addModelBind(),this.MinimumPrice.set(BigDecimal.ZERO),this.MinimumPrice.removeReadOnly(),this.MinimumPrice.addModelBind()};ProcedureRequestModel.prototype.updateUsePriceListValues=function(){var d=$.modelStorage.getChildModel(RequestDataModel.Type,this.Info.ModelKey);
if(d){a(this,d);var b=this.UsePriceListValues.get(!1),e=this.DefineLotsPrices.get(!1);if(b)this.BasePrice.set(d.TotalValues[MathAction.Constants.ALL_LOT_KEY].CeilingPriceTotal),this.BasePrice.makeReadOnly(),this.BasePrice.removeModelBind();else if(e){var b=BigDecimal.ZERO,c;for(c in this.Lots.get())this.Lots.get(c)&&(b=b.add(d.TotalValues[c].CeilingPriceTotal));this.BasePrice.set(b)}else this.BasePrice.removeReadOnly(),this.BasePrice.addModelBind()}};ProcedureRequestModel.prototype.updateLotValues=
function(a,b){this.DefineBasePrice.get(!1);var e=this.DefineLots.get(!1),c=this.DefineLotsPrices.get(!1),g=this.UsePriceListValues.get(!1),k=b.LotCode.get();g&&e&&c&&(e=b.CeilingPriceTotal,a!==MathAction.Constants.ALL_LOT_KEY&&this.Lots.get(a).addBasePrice(e.negate()),k!==MathAction.Constants.ALL_LOT_KEY&&this.Lots.get(k).addBasePrice(e))};ProcedureRequestModel.prototype.updateLotTotalValues=function(a){var b=this.DefineBasePrice.get(!1),e=this.DefineLots.get(!1),c=this.DefineLotsPrices.get(!1);if(this.UsePriceListValues.get(!1))for(var g in a){var k=
a[g].CeilingPriceTotal;if(g===MathAction.Constants.ALL_LOT_KEY&&b)this.updateBasePrice(k);else if(e&&c){var h=this.Lots.get(g);void 0!=h&&h.addBasePrice(k)}}};ProcedureRequestModel.prototype.addItemValues=function(a){var b=this.UsePriceListValues.get(!1),e=a.LotCode.get();a=a.CeilingPriceTotal;b&&(e!==MathAction.Constants.ALL_LOT_KEY?this.updateLotBasePrice(a,e):this.updateBasePrice(a))};ProcedureRequestModel.prototype.removeItemValues=function(a){var b=this.UsePriceListValues.get(!1),e=a.LotCode.get();
a=a.CeilingPriceTotal.negate();b&&(e!==MathAction.Constants.ALL_LOT_KEY?this.updateLotBasePrice(a,e):this.updateBasePrice(a))};ProcedureRequestModel.prototype.removeItemTotalValues=function(a){if(this.UsePriceListValues.get(!1))for(var b in a){var e=a[b];void 0!=e&&(e=e.CeilingPriceTotal.negate(),this.updateLotBasePrice(e,b))}};ProcedureRequestModel.prototype.updateValues=function(a){if(a&&(this.BasePrice.set($.bigDecimalFromJSON(a.BasePrice.Value)),this.LotsBasePrice.set($.bigDecimalFromJSON(a.LotsBasePrice.Value)),
a.Lots))for(var b=0,e=a.Lots.length;b<e;b++){var c=a.Lots[b],g=this.Lots.get(c.Key);g&&g.BasePrice.set($.bigDecimalFromJSON(c.BasePrice.Value))}}}
function TotalValuesModel(c){this.LotCode=MathModelProperty.stringPropertyFactory();this.SalesPriceTotal=this.CeilingPriceTotal=this.CostPriceTotal=BigDecimal.ZERO;TotalValuesModel.prototype.add=function(a){this.CostPriceTotal=this.CostPriceTotal.add(a.CostPriceTotal);this.CeilingPriceTotal=this.CeilingPriceTotal.add(a.CeilingPriceTotal);this.SalesPriceTotal=this.SalesPriceTotal.add(a.SalesPriceTotal)};TotalValuesModel.prototype.subtract=function(a){this.CostPriceTotal=this.CostPriceTotal&&this.CostPriceTotal.subtract(a.CostPriceTotal);
this.CeilingPriceTotal=this.CeilingPriceTotal&&this.CeilingPriceTotal.subtract(a.CeilingPriceTotal);this.SalesPriceTotal=this.SalesPriceTotal&&this.SalesPriceTotal.subtract(a.SalesPriceTotal)};TotalValuesModel.prototype.updateCostPriceTotal=function(a){this.CostPriceTotal=this.CostPriceTotal.add(a)};TotalValuesModel.prototype.updateCeilingPriceTotal=function(a){this.CeilingPriceTotal=this.CeilingPriceTotal.add(a)};TotalValuesModel.prototype.updateSalesPriceTotal=function(a){this.SalesPriceTotal=this.SalesPriceTotal.add(a)};
TotalValuesModel.prototype.clearValues=function(){this.SalesPriceTotal=this.CeilingPriceTotal=this.CostPriceTotal=BigDecimal.ZERO};TotalValuesModel.prototype.diff=function(a){var d;d=this.clone();d.subtract(a);return d};TotalValuesModel.prototype.clone=function(){var a=new TotalValuesModel;a.LotCode.set(this.LotCode.get());a.CostPriceTotal=this.CostPriceTotal;a.CeilingPriceTotal=this.CeilingPriceTotal;a.SalesPriceTotal=this.SalesPriceTotal;return a};TotalValuesModel.prototype.setNegative=function(){this.CostPriceTotal=
this.CostPriceTotal.negate();this.CeilingPriceTotal=this.CeilingPriceTotal.negate();this.SalesPriceTotal=this.SalesPriceTotal.negate()}}TotalValuesModel.factory=function(c){var a=new TotalValuesModel;c&&(a.LotCode.set(c.Lot),a.CostPriceTotal=$.bigDecimalFromJSON(c.CstPT),a.CeilingPriceTotal=$.bigDecimalFromJSON(c.ClnPT),a.SalesPriceTotal=$.bigDecimalFromJSON(c.SlsPT));return a};TotalValuesModel.addLot=function(c,a){var d=new TotalValuesModel;d.LotCode.set(a);c[a]=d};
TotalValuesModel.removeLots=function(c,a){for(var d=0,b=a.length;d<b;d++)delete c[a[d]]};TotalValuesModel.addTotals=function(c,a){if(void 0===c)throw"Argument null exception : totalValues";if(void 0===a)throw"Argument null exception : valuesToAdd";for(var d in a){var b=a[d],e=c[d];void 0!=e&&e.add(b)}};
TotalValuesModel.subtractTotals=function(c,a){if(void 0===c)throw"Argument null exception : totalValues";if(void 0===a)throw"Argument null exception : valuesToRemove";for(var d in a){var b=a[d],e=c[d];void 0!=e&&e.subtract(b)}};LotModel.prototype=new MathModel;LotModel.Type="Lot";
LotModel.factory=function(c){var a=new LotModel;c&&(a.Id=c.Id,a.BasePrice.setProperties(c.BasePrice),a.BasePriceVAT.setProperties(c.BasePriceVAT),a.MinimumPrice.setProperties(c.MinimumPrice),a.Key.set(c.Key),a.Info=MathModelReference.factory(c.ModelKey),a.NextModelInfo=MathModelReference.factory(c.NextModelKey));$.modelStorage.add(a);return a};LotModel.getLotKeyFromElement=function(c){c=c.val();return""===c||void 0===c?MathAction.Constants.ALL_LOT_KEY:c.replace(/\./g,"_")};
function LotModel(c){this.init(c);this.Id=0;this.BasePrice=MathModelProperty.decimalPropertyFactory();this.BasePriceVAT=MathModelProperty.decimalPropertyFactory();this.MinimumPrice=MathModelProperty.decimalPropertyFactory();this.Key=MathModelProperty.stringPropertyFactory();LotModel.prototype.addBasePrice=function(a){a=this.BasePrice.get(BigDecimal.ZERO).add(a);this.BasePrice.set(a)};LotModel.prototype.updateBasePrice=function(a){this.addBasePrice(a);this.updateBasePriceViewModel()};LotModel.prototype.updateBasePriceViewModel=
function(){updateViewModel("LotValues",null,"DictionaryLotBasePriceValues",this.Id,null!=this.BasePrice.get()?this.BasePrice.get().toString():null)};LotModel.prototype.addBasePriceVAT=function(a){a=this.BasePriceVAT.get(BigDecimal.ZERO).add(a);this.BasePriceVAT.set(a)};LotModel.prototype.updateBasePriceVAT=function(a){this.addBasePrice(a);this.updateBasePriceVATViewModel()};LotModel.prototype.updateBasePriceVATViewModel=function(){updateViewModel("LotValues",null,"DictionaryLotBasePriceVATValues",
this.Id,this.BasePriceVAT.get(BigDecimal.ZERO).toString())};LotModel.prototype.addMinimumPrice=function(a){a=this.MinimumPrice.get(BigDecimal.ZERO).add(a);this.MinimumPrice.set(a)};LotModel.prototype.updateMinimumPrice=function(a){this.addMinimumPrice(a);this.updateMinimumPriceViewModel()};LotModel.prototype.updateMinimumPriceViewModel=function(){updateViewModel("LotValues",null,"DictionaryLotMinimumPriceValues",this.Id,this.MinimumPrice.get(BigDecimal.ZERO).toString())}}BilItemAction.prototype=new MathAction;
function BilItemAction(c){function a(a,b,d){var c=b.updateCostPriceTotal();c&&b.Propagate&&(a=a.createNextAction(MathAction.Types.Update,b))&&(a.MethodKey=MathModel.Variables.CostPriceTotal,a.put(MathModel.Variables.CostPriceTotal,c),d.enqueue(a))}function d(a,b,d){var c=b.updateCeilingPriceTotal();c&&b.Propagate&&(a=a.createNextAction(MathAction.Types.Update,b))&&(a.MethodKey=MathModel.Variables.CeilingPriceTotal,a.put(MathModel.Variables.CeilingPriceTotal,c),d.enqueue(a))}function b(a,b,d){var c=
b.updateSalesPriceTotal();c&&b.Propagate&&(a=a.createNextAction(MathAction.Types.Update,b))&&(a.MethodKey=MathModel.Variables.SalesPriceTotal,a.put(MathModel.Variables.SalesPriceTotal,c),d.enqueue(a))}this.init(c);BilItemAction.prototype.itemCodeChanged=function(a,b){a.ItemCode.load(this.ViewElement)};BilItemAction.prototype.reqRefChanged=function(a,b){a.ReqRef.load(this.ViewElement)};BilItemAction.prototype.descriptionChanged=function(a,b){a.Description.load(this.ViewElement)};BilItemAction.prototype.unitChanged=
function(a,b){a.Unit.load(this.ViewElement)};BilItemAction.prototype.quantityChanged=function(e,c){e.Quantity.load(this.ViewElement);a(this,e,c);d(this,e,c);b(this,e,c)};BilItemAction.prototype.costPriceChanged=function(b,d){b.CostPrice.load(this.ViewElement);a(this,b,d)};BilItemAction.prototype.ceilingPriceChanged=function(a,b){a.CeilingPrice.load(this.ViewElement);d(this,a,b)};BilItemAction.prototype.salesPriceChanged=function(a,d){a.SalesPrice.load(this.ViewElement);b(this,a,d)};BilItemAction.prototype.addItem=
function(a,b){var d=a.createTotalValues(),c=this.createNextAction(MathAction.Types.Add,a);c.MethodKey=MathModel.Variables.ItemValues;c.put(MathModel.Variables.ItemValues,d);b.enqueue(c)};BilItemAction.prototype.removeItem=function(a,b){var d=a.createTotalValues(),c=this.createNextAction(MathAction.Types.Remove,a);c.MethodKey=MathModel.Variables.ItemValues;c.put(MathModel.Variables.ItemValues,d);b.enqueue(c);a.Propagate=!1};BilItemAction.prototype.updateModel=function(a,b){var d=this.get(MathModel.Variables.JsonModel),
c=this.createNextAction(MathAction.Types.Add,a),h;h=a.createTotalValues();a.updateValues(d);d=a.createTotalValues().diff(h);c&&(c.MethodKey=MathModel.Variables.ItemValues,c.put(MathModel.Variables.ItemValues,d),b.enqueue(c))};BilItemAction.prototype.createNextAction=function(a,b){var d=b.NextModelInfo;if(d&&d.Type===BilChapterModel.Type)return new BilChapterAction({Type:a,ModelRef:d});if(d&&d.Type===BilTotalModel.Type)return new BilTotalAction({Type:a,ModelRef:d})};BilItemAction.prototype.getAddAction=
function(){return this.addItem};BilItemAction.prototype.getUpdateAction=function(){if(this.MethodKey===MathModel.Variables.Model)return this.updateModel};BilItemAction.prototype.getChangeAction=function(){var a=this.MethodKey;if(a===MathModel.Variables.Quantity)return this.quantityChanged;if(a===MathModel.Variables.CostPrice)return this.costPriceChanged;if(a===MathModel.Variables.CeilingPrice)return this.ceilingPriceChanged;if(a===MathModel.Variables.SalesPrice)return this.salesPriceChanged;if(a==
MathModel.Variables.ItemCode)return this.itemCodeChanged;if(a==MathModel.Variables.ReqRef)return this.reqRefChanged;if(a==MathModel.Variables.Description)return this.descriptionChanged;if(a==MathModel.Variables.Unit)return this.unitChanged};BilItemAction.prototype.getRemoveAction=function(){return this.removeItem}}BilChapterAction.prototype=new MathAction;
function BilChapterAction(c){this.init(c);BilChapterAction.prototype.itemCodeChanged=function(a,d){a.ItemCode.load(this.ViewElement)};BilChapterAction.prototype.descriptionChanged=function(a,d){a.Description.load(this.ViewElement)};BilChapterAction.prototype.updateCostPriceTotal=function(a,d){var b=this.get(MathModel.Variables.CostPriceTotal),e=this.createNextAction(MathAction.Types.Update,a);if(b=a.updateCostPriceTotal(b))e.MethodKey=MathModel.Variables.CostPriceTotal,e.put(MathModel.Variables.CostPriceTotal,
b),d.enqueue(e)};BilChapterAction.prototype.updateCeilingPriceTotal=function(a,d){var b=this.get(MathModel.Variables.CeilingPriceTotal),e=this.createNextAction(MathAction.Types.Update,a);if(b=a.updateCeilingPriceTotal(b))e.MethodKey=MathModel.Variables.CeilingPriceTotal,e.put(MathModel.Variables.CeilingPriceTotal,b),d.enqueue(e)};BilChapterAction.prototype.updateSalesPriceTotal=function(a,d){var b=this.get(MathModel.Variables.SalesPriceTotal),e=this.createNextAction(MathAction.Types.Update,a);if(b=
a.updateSalesPriceTotal(b))e.MethodKey=MathModel.Variables.SalesPriceTotal,e.put(MathModel.Variables.SalesPriceTotal,b),d.enqueue(e)};BilChapterAction.prototype.addItemValues=function(a,d){var b=this.get(MathModel.Variables.ItemValues),e=this.createNextAction(MathAction.Types.Add,a),b=a.add(b);e.MethodKey=MathModel.Variables.ItemValues;e.put(MathModel.Variables.ItemValues,b);d.enqueue(e)};BilChapterAction.prototype.removeItem=function(a,d){var b=a.createTotalValues(),e=this.createNextAction(MathAction.Types.Remove,
a);e.MethodKey=MathModel.Variables.ItemValues;e.put(MathModel.Variables.ItemValues,b);d.enqueue(e)};BilChapterAction.prototype.removeItemValues=function(a,d){var b=this.get(MathModel.Variables.ItemValues),e=this.createNextAction(MathAction.Types.Remove,a);e.MethodKey=MathModel.Variables.ItemValues;e.put(MathModel.Variables.ItemValues,b);a.subtract(b);d.enqueue(e)};BilChapterAction.prototype.updateModel=function(a,d){var b=this.get(MathModel.Variables.JsonModel),e=this.createNextAction(MathAction.Types.Add,
a),c;c=a.createTotalValues();a.updateValues(b);b=a.createTotalValues().diff(c);e&&(e.MethodKey=MathModel.Variables.ItemValues,e.put(MathModel.Variables.ItemValues,b),d.enqueue(e))};BilChapterAction.prototype.createNextAction=function(a,d){var b=d.NextModelInfo;if(b&&b.Type===BilChapterModel.Type)return new BilChapterAction({Type:a,ModelRef:b});if(b&&b.Type===BilTotalModel.Type)return new BilTotalAction({Type:a,ModelRef:b})};BilChapterAction.prototype.getAddAction=function(){if(this.MethodKey===MathModel.Variables.ItemValues)return this.addItemValues};
BilChapterAction.prototype.getChangeAction=function(){var a=this.MethodKey;if(a==MathModel.Variables.ItemCode)return this.itemCodeChanged;if(a==MathModel.Variables.Description)return this.descriptionChanged};BilChapterAction.prototype.getUpdateAction=function(){var a=this.MethodKey;if(a===MathModel.Variables.CostPriceTotals)return this.updateCostPriceTotal;if(a===MathModel.Variables.CeilingPriceTotal)return this.updateCeilingPriceTotal;if(a===MathModel.Variables.SalesPriceTotal)return this.updateSalesPriceTotal;
if(a===MathModel.Variables.Model)return this.updateModel};BilChapterAction.prototype.getRemoveAction=function(){return this.MethodKey===MathModel.Variables.ItemValues?this.removeItemValues:this.removeItem}}BilTotalAction.prototype=new MathAction;
function BilTotalAction(c){this.init(c);BilTotalAction.prototype.updateCostPriceTotal=function(a,d){var b=this.get(MathModel.Variables.CostPriceTotal),e=this.createNextAction(MathAction.Types.Update,a);if(b=a.updateCostPriceTotal(b))e.MethodKey=MathModel.Variables.CostPriceTotal,e.put(MathModel.Variables.CostPriceTotal,b),d.enqueue(e)};BilTotalAction.prototype.updateCeilingPriceTotal=function(a,d){var b=this.get(MathModel.Variables.CeilingPriceTotal),e=this.createNextAction(MathAction.Types.Update,
a);if(b=a.updateCeilingPriceTotal(b))e.MethodKey=MathModel.Variables.CeilingPriceTotal,e.put(MathModel.Variables.CeilingPriceTotal,b),d.enqueue(e)};BilTotalAction.prototype.updateSalesPriceTotal=function(a,d){var b=this.get(MathModel.Variables.SalesPriceTotal),e=this.createNextAction(MathAction.Types.Update,a);if(b=a.updateSalesPriceTotal(b))e.MethodKey=MathModel.Variables.SalesPriceTotal,e.put(MathModel.Variables.SalesPriceTotal,b),d.enqueue(e)};BilTotalAction.prototype.addItemValues=function(a,
d){var b=this.get(MathModel.Variables.ItemValues),e=this.createNextAction(MathAction.Types.Add,a),b=a.add(b);e.MethodKey=MathModel.Variables.ItemValues;e.put(MathModel.Variables.ItemValues,b);d.enqueue(e)};BilTotalAction.prototype.addItemTotalValues=function(a,d){var b=this.get(MathModel.Variables.ItemValues),e=this.createNextAction(MathAction.Types.Add,a),b=a.addTotalValues(b);e.MethodKey=MathModel.Variables.ItemValues;e.put(MathModel.Variables.ItemValues,b);d.enqueue(e)};BilTotalAction.prototype.removeItemValues=
function(a,d){var b=this.get(MathModel.Variables.ItemValues),e=this.createNextAction(MathAction.Types.Remove,a);e.MethodKey=MathModel.Variables.ItemValues;e.put(MathModel.Variables.ItemValues,b);a.subtract(b);d.enqueue(e)};BilTotalAction.prototype.createNextAction=function(a,d){var b=d.NextModelInfo;if(b&&b.Type===BioQuestionModel.Type)return new BioQuestionAction({Type:a,ModelRef:b})};BilTotalAction.prototype.getAddAction=function(){var a=this.MethodKey;if(a===MathModel.Variables.ItemValues)return this.addItemValues;
if(a===MathModel.Variables.ItemTotalValues)return this.addItemTotalValues};BilTotalAction.prototype.getUpdateAction=function(){var a=this.MethodKey;if(a===MathModel.Variables.CostPriceTotal)return this.updateCostPriceTotal;if(a===MathModel.Variables.CeilingPriceTotal)return this.updateCeilingPriceTotal;if(a===MathModel.Variables.SalesPriceTotal)return this.updateSalesPriceTotal};BilTotalAction.prototype.getRemoveAction=function(){if(this.MethodKey===MathModel.Variables.ItemValues)return this.removeItemValues}}
BioQuestionAction.prototype=new MathAction;
function BioQuestionAction(c){this.init(c);BioQuestionAction.prototype.lotCodeChanged=function(a,d){var b=a.TotalValues.LotCode.get(),e=this.createNextAction(MathAction.Types.Update,a),c=LotModel.getLotKeyFromElement(this.ViewElement);a.TotalValues.LotCode.set(c);e.MethodKey=MathModel.Variables.ItemValues;e.put(MathModel.Variables.LotCode,b);e.put(MathModel.Variables.ItemValues,a.TotalValues);d.enqueue(e)};BioQuestionAction.prototype.updateCostPriceTotal=function(a,d){var b=this.get(MathModel.Variables.CostPriceTotal),
e=this.createNextAction(MathAction.Types.Update,a);e.MethodKey=MathModel.Variables.CostPriceTotal;e.put(MathModel.Variables.CostPriceTotal,b);e.put(MathModel.Variables.LotCode,a.TotalValues.LotCode.get());a.updateCostPriceTotal(b);d.enqueue(e)};BioQuestionAction.prototype.updateCeilingPriceTotal=function(a,d){var b=this.get(MathModel.Variables.CeilingPriceTotal),e=this.createNextAction(MathAction.Types.Update,a);e.MethodKey=MathModel.Variables.CeilingPriceTotal;e.put(MathModel.Variables.CeilingPriceTotal,
b);e.put(MathModel.Variables.LotCode,a.TotalValues.LotCode.get());a.updateCeilingPriceTotal(b);d.enqueue(e)};BioQuestionAction.prototype.updateSalesPriceTotal=function(a,d){var b=this.get(MathModel.Variables.SalesPriceTotal),e=this.createNextAction(MathAction.Types.Update,a);e.MethodKey=MathModel.Variables.SalesPriceTotal;e.put(MathModel.Variables.SalesPriceTotal,b);e.put(MathModel.Variables.LotCode,a.TotalValues.LotCode.get());a.updateSalesPriceTotal(b);d.enqueue(e)};BioQuestionAction.prototype.addItem=
function(a,d){var b=a.TotalValues,e=this.createNextAction(MathAction.Types.Add,a);e.MethodKey=MathModel.Variables.ItemValues;e.put(MathModel.Variables.ItemValues,b);d.enqueue(e)};BioQuestionAction.prototype.addItemValues=function(a,d){var b=this.get(MathModel.Variables.ItemValues),e=this.createNextAction(MathAction.Types.Add,a);b.LotCode.set(a.TotalValues.LotCode.get());e.MethodKey=MathModel.Variables.ItemValues;e.put(MathModel.Variables.ItemValues,b);a.addItemValues(b);d.enqueue(e)};BioQuestionAction.prototype.removeItem=
function(a,d){var b=a.TotalValues,e=this.createNextAction(MathAction.Types.Remove,a);e.MethodKey=MathModel.Variables.ItemValues;e.put(MathModel.Variables.ItemValues,b);d.enqueue(e)};BioQuestionAction.prototype.removeItemValues=function(a,d){var b=this.get(MathModel.Variables.ItemValues),e=this.createNextAction(MathAction.Types.Remove,a);b.LotCode.set(a.TotalValues.LotCode.get());e.MethodKey=MathModel.Variables.ItemValues;e.put(MathModel.Variables.ItemValues,b);a.removeItemValues(b);d.enqueue(e)};
BioQuestionAction.prototype.updateModel=function(a,d){var b=this.createNextAction(MathAction.Types.Add,a),e=this.get(MathModel.Variables.JsonModel),c;c=a.TotalValues;if(e=totalsDiff=TotalValuesModel.factory(e.TotalValues).diff(c))b.MethodKey=MathModel.Variables.ItemValues,b.put(MathModel.Variables.ItemValues,e),d.enqueue(b)};BioQuestionAction.prototype.createNextAction=function(a,d){var b=d.NextModelInfo;if(b&&b.Type===BioSectionModel.Type)return new BioSectionAction({Type:a,ModelRef:b});if(b&&b.Type===
BiocModel.Type)return new BiocAction({Type:a,ModelRef:b})};BioQuestionAction.prototype.getAddAction=function(){return this.MethodKey===MathModel.Variables.ItemValues?this.addItemValues:this.addItem};BioQuestionAction.prototype.getChangeAction=function(){if(this.MethodKey===MathModel.Variables.LotCode)return this.lotCodeChanged};BioQuestionAction.prototype.getUpdateAction=function(){var a=this.MethodKey;if(a===MathModel.Variables.CostPriceTotal)return this.updateCostPriceTotal;if(a===MathModel.Variables.CeilingPriceTotal)return this.updateCeilingPriceTotal;
if(a===MathModel.Variables.SalesPriceTotal)return this.updateSalesPriceTotal;if(a===MathModel.Variables.Model)return this.updateModel};BioQuestionAction.prototype.getRemoveAction=function(){return this.MethodKey===MathModel.Variables.ItemValues?this.removeItemValues:this.removeItem}}BioSectionAction.prototype=new MathAction;
function BioSectionAction(c){function a(d,b){if(b.Sections)for(var e in b.Sections){var c=b.Sections[e];c.NextModelInfo&&c.NextModelInfo.ModelKey===d&&(c.changeToLot(b.LotCode),a(c.Info.ModelKey,b))}if(b.Questions)for(var g in b.Questions)c=b.Questions[g],c.NextModelInfo&&c.NextModelInfo.ModelKey===d&&c.TotalValues.LotCode.set(b.LotCode)}this.init(c);BioSectionAction.prototype.lotCodeChanged=function(d,b){var e=d.LotCode.get(),c=LotModel.getLotKeyFromElement(this.ViewElement),g=this.createNextAction(MathAction.Types.Update,
d);d.LotCode.set(c);e=d.changeTotalValues(e,c);c={LotCode:d.LotCode.get(),Sections:$.modelStorage.getByType(BioSectionModel.Type),Questions:$.modelStorage.getByType(BioQuestionModel.Type)};(c.Sections||c.Questions)&&a(d.Info.ModelKey,c);g.MethodKey=MathModel.Variables.ItemTotalValues;g.put(MathModel.Variables.ItemTotalValues,e);b.enqueue(g)};BioSectionAction.prototype.updateCostPriceTotal=function(a,b){var e=this.get(MathModel.Variables.CostPriceTotal),c=this.get(MathModel.Variables.LotCode),g=this.createNextAction(MathAction.Types.Update,
a);g.MethodKey=MathModel.Variables.CostPriceTotal;g.put(MathModel.Variables.CostPriceTotal,e);g.put(MathModel.Variables.LotCode,c);a.updateCostPriceTotal(e,c);b.enqueue(g)};BioSectionAction.prototype.updateCeilingPriceTotal=function(a,b){var e=this.get(MathModel.Variables.CeilingPriceTotal),c=this.get(MathModel.Variables.LotCode),g=this.createNextAction(MathAction.Types.Update,a);g.MethodKey=MathModel.Variables.CeilingPriceTotal;g.put(MathModel.Variables.CeilingPriceTotal,e);g.put(MathModel.Variables.LotCode,
c);a.updateCeilingPriceTotal(e,c);b.enqueue(g)};BioSectionAction.prototype.updateSalesPriceTotal=function(a,b){var e=this.get(MathModel.Variables.SalesPriceTotal),c=this.get(MathModel.Variables.LotCode),g=this.createNextAction(MathAction.Types.Update,a);g.MethodKey=MathModel.Variables.SalesPriceTotal;g.put(MathModel.Variables.SalesPriceTotal,e);g.put(MathModel.Variables.LotCode,c);a.updateSalesPriceTotal(e,c);b.enqueue(g)};BioSectionAction.prototype.updateTotalValue=function(a,b){var e=this.get(MathModel.Variables.ItemValues),
c=this.get(MathModel.Variables.LotCode),g=this.createNextAction(MathAction.Types.Update,a);g.MethodKey=MathModel.Variables.ItemValues;g.put(MathModel.Variables.LotCode,c);g.put(MathModel.Variables.ItemValues,e);a.updateLotValues(c,e);b.enqueue(g)};BioSectionAction.prototype.updateTotalValues=function(a,b){var e=this.get(MathModel.Variables.ItemTotalValues),c=this.createNextAction(MathAction.Types.Update,a);c.MethodKey=MathModel.Variables.ItemTotalValues;c.put(MathModel.Variables.ItemTotalValues,e);
a.addItemTotalValues(e);b.enqueue(c)};BioSectionAction.prototype.addItemValues=function(a,b){var e=this.get(MathModel.Variables.ItemValues),c=this.createNextAction(MathAction.Types.Add,a);c.MethodKey=MathModel.Variables.ItemValues;c.put(MathModel.Variables.ItemValues,e);a.addItemValues(e);b.enqueue(c)};BioSectionAction.prototype.addItem=function(a,b){var c=a.TotalValues,f=this.createNextAction(MathAction.Types.Update,a);f.MethodKey=MathModel.Variables.ItemTotalValues;f.put(MathModel.Variables.ItemTotalValues,
c);b.enqueue(f)};BioSectionAction.prototype.removeItem=function(a,b){var c=a.TotalValues,f=this.createNextAction(MathAction.Types.Remove,a);f.MethodKey=MathModel.Variables.ItemTotalValues;f.put(MathModel.Variables.ItemTotalValues,c);b.enqueue(f)};BioSectionAction.prototype.removeItemValues=function(a,b){var c=this.get(MathModel.Variables.ItemValues),f=this.createNextAction(MathAction.Types.Remove,a);f.MethodKey=MathModel.Variables.ItemValues;f.put(MathModel.Variables.ItemValues,c);a.removeItemValues(c);
b.enqueue(f)};BioSectionAction.prototype.removeItemTotalValues=function(a,b){var c=this.get(MathModel.Variables.ItemTotalValues),f=this.createNextAction(MathAction.Types.Remove,a);f.MethodKey=MathModel.Variables.ItemTotalValues;f.put(MathModel.Variables.ItemTotalValues,c);a.removeItemTotalValues(c);b.enqueue(f)};BioSectionAction.prototype.createNextAction=function(a,b){var c=b.NextModelInfo;if(c&&c.Type===BioSectionModel.Type)return new BioSectionAction({Type:a,ModelRef:c});if(c&&c.Type===BiocModel.Type)return new BiocAction({Type:a,
ModelRef:c})};BioSectionAction.prototype.getChangeAction=function(){if(this.MethodKey===MathModel.Variables.LotCode)return this.lotCodeChanged};BioSectionAction.prototype.getAddAction=function(){return this.MethodKey===MathModel.Variables.ItemValues?this.addItemValues:this.addItem};BioSectionAction.prototype.getUpdateAction=function(){var a=this.MethodKey;if(a===MathModel.Variables.CostPriceTotal)return this.updateCostPriceTotal;if(a===MathModel.Variables.CeilingPriceTotal)return this.updateCeilingPriceTotal;
if(a===MathModel.Variables.SalesPriceTotal)return this.updateSalesPriceTotal;if(a===MathModel.Variables.ItemValues)return this.updateTotalValue;if(a===MathModel.Variables.ItemTotalValues)return this.updateTotalValues};BioSectionAction.prototype.getRemoveAction=function(){var a=this.MethodKey;return a===MathModel.Variables.ItemValues?this.removeItemValues:a===MathModel.Variables.ItemTotalValues?this.removeItemTotalValues:this.removeItem}}BiocAction.prototype=new MathAction;
function BiocAction(c){this.init(c);BiocAction.prototype.updateCostPriceTotal=function(a,d){var b=this.get(MathModel.Variables.CostPriceTotal),c=this.get(MathModel.Variables.LotCode),f=this.createNextAction(MathAction.Types.Update,a);f.MethodKey=MathModel.Variables.CostPriceTotal;f.put(MathModel.Variables.CostPriceTotal,b);f.put(MathModel.Variables.LotCode,c);a.updateCostPriceTotal(b,c);d.enqueue(f)};BiocAction.prototype.updateCeilingPriceTotal=function(a,d){var b=this.get(MathModel.Variables.CeilingPriceTotal),
c=this.get(MathModel.Variables.LotCode),f=this.createNextAction(MathAction.Types.Update,a);f.MethodKey=MathModel.Variables.CeilingPriceTotal;f.put(MathModel.Variables.CeilingPriceTotal,b);f.put(MathModel.Variables.LotCode,c);a.updateCeilingPriceTotal(b,c);d.enqueue(f)};BiocAction.prototype.updateSalesPriceTotal=function(a,d){var b=this.get(MathModel.Variables.SalesPriceTotal),c=this.get(MathModel.Variables.LotCode),f=this.createNextAction(MathAction.Types.Update,a);f.MethodKey=MathModel.Variables.SalesPriceTotal;
f.put(MathModel.Variables.SalesPriceTotal,b);f.put(MathModel.Variables.LotCode,c);a.updateSalesPriceTotal(b,c);d.enqueue(f)};BiocAction.prototype.updateTotalValue=function(a,d){var b=this.get(MathModel.Variables.ItemValues),c=this.get(MathModel.Variables.LotCode),f=this.createNextAction(MathAction.Types.Update,a);f.MethodKey=MathModel.Variables.ItemValues;f.put(MathModel.Variables.LotCode,c);f.put(MathModel.Variables.ItemValues,b);a.updateLotValues(c,b);d.enqueue(f)};BiocAction.prototype.updateTotalValues=
function(a,d){var b=this.get(MathModel.Variables.ItemTotalValues),c=this.createNextAction(MathAction.Types.Update,a);c.MethodKey=MathModel.Variables.ItemTotalValues;c.put(MathModel.Variables.ItemTotalValues,b);a.addItemTotalValues(b);d.enqueue(c)};BiocAction.prototype.addItemValues=function(a,d){var b=this.get(MathModel.Variables.ItemValues),c=this.createNextAction(MathAction.Types.Add,a);c.MethodKey=MathModel.Variables.ItemValues;c.put(MathModel.Variables.ItemValues,b);a.addItemValues(b);d.enqueue(c)};
BiocAction.prototype.removeItemValues=function(a,d){var b=this.get(MathModel.Variables.ItemValues),c=this.createNextAction(MathAction.Types.Remove,a);c.MethodKey=MathModel.Variables.ItemValues;c.put(MathModel.Variables.ItemValues,b);a.removeItemValues(b);d.enqueue(c)};BiocAction.prototype.removeItemTotalValues=function(a,d){var b=this.get(MathModel.Variables.ItemTotalValues),c=this.createNextAction(MathAction.Types.Remove,a);c.MethodKey=MathModel.Variables.ItemTotalValues;c.put(MathModel.Variables.ItemTotalValues,
b);a.removeItemTotalValues(b);d.enqueue(c)};BiocAction.prototype.createNextAction=function(a,d){var b=d.NextModelInfo;if(b&&b.Type===RequestDataModel.Type)return new RequestDataAction({Type:a,ModelRef:b})};BiocAction.prototype.getAddAction=function(){if(this.MethodKey===MathModel.Variables.ItemValues)return this.addItemValues};BiocAction.prototype.getUpdateAction=function(){var a=this.MethodKey;if(a===MathModel.Variables.CostPriceTotal)return this.updateCostPriceTotal;if(a===MathModel.Variables.CeilingPriceTotal)return this.updateCeilingPriceTotal;
if(a===MathModel.Variables.SalesPriceTotal)return this.updateSalesPriceTotal;if(a===MathModel.Variables.ItemValues)return this.updateTotalValue;if(a===MathModel.Variables.ItemTotalValues)return this.updateTotalValues};BiocAction.prototype.getRemoveAction=function(){var a=this.MethodKey;if(a===MathModel.Variables.ItemValues)return this.removeItemValues;if(a===MathModel.Variables.ItemTotalValues)return this.removeItemTotalValues}}RequestDataAction.prototype=new MathAction;
function RequestDataAction(c){this.init(c);RequestDataAction.prototype.updateCostPriceTotal=function(a,d){var b=this.get(MathModel.Variables.CostPriceTotal);valueLotCode=this.get(MathModel.Variables.LotCode);a.updateCostPriceTotal(b,valueLotCode)};RequestDataAction.prototype.updateCeilingPriceTotal=function(a,d){var b=this.get(MathModel.Variables.CeilingPriceTotal),c=this.get(MathModel.Variables.LotCode),f=this.createNextAction(MathAction.Types.Update,a);a.updateCeilingPriceTotal(b,c);f&&(f.MethodKey=
MathModel.Variables.CeilingPriceTotal,f.put(MathModel.Variables.LotCode,c),f.put(MathModel.Variables.CeilingPriceTotal,b),d.enqueue(f))};RequestDataAction.prototype.updateSalesPriceTotal=function(a,d){var b=this.get(MathModel.Variables.SalesPriceTotal),c=this.get(MathModel.Variables.LotCode);a.updateSalesPriceTotal(b,c)};RequestDataAction.prototype.updateTotalValue=function(a,d){var b=this.get(MathModel.Variables.ItemValues),c=this.get(MathModel.Variables.LotCode),f=this.createNextAction(MathAction.Types.Update,
a);a.updateLotValues(c,b);f&&(f.MethodKey=MathModel.Variables.ItemValues,f.put(MathModel.Variables.LotCode,c),f.put(MathModel.Variables.ItemValues,b),d.enqueue(f))};RequestDataAction.prototype.updateTotalValues=function(a,d){var b=this.get(MathModel.Variables.ItemTotalValues),c=this.createNextAction(MathAction.Types.Update,a);a.addItemTotalValues(b);c&&(c.MethodKey=MathModel.Variables.ItemTotalValues,c.put(MathModel.Variables.ItemTotalValues,b),d.enqueue(c))};RequestDataAction.prototype.addItemValues=
function(a,d){var b=this.get(MathModel.Variables.ItemValues),c=this.createNextAction(MathAction.Types.Add,a);a.addItemValues(b);c&&(c.MethodKey=MathModel.Variables.ItemValues,c.put(MathModel.Variables.ItemValues,b),d.enqueue(c))};RequestDataAction.prototype.removeItemValues=function(a,d){var b=this.get(MathModel.Variables.ItemValues),c=this.createNextAction(MathAction.Types.Remove,a);a.removeItemValues(b);c&&(c.MethodKey=MathModel.Variables.ItemValues,c.put(MathModel.Variables.ItemValues,b),d.enqueue(c))};
RequestDataAction.prototype.removeItemTotalValues=function(a,d){var b=this.get(MathModel.Variables.ItemTotalValues),c=this.createNextAction(MathAction.Types.Remove,a);a.removeItemTotalValues(b);c&&(c.MethodKey=MathModel.Variables.ItemTotalValues,c.put(MathModel.Variables.ItemTotalValues,b),d.enqueue(c))};RequestDataAction.prototype.createNextAction=function(a,d){var b=d.NextModelInfo;if(b&&b.Type===ProcedureRequestModel.Type)return new ProcedureRequestAction({Type:a,ModelRef:b})};RequestDataAction.prototype.getAddAction=
function(){if(this.MethodKey===MathModel.Variables.ItemValues)return this.addItemValues};RequestDataAction.prototype.getUpdateAction=function(){var a=this.MethodKey;if(a===MathModel.Variables.CostPriceTotal)return this.updateCostPriceTotal;if(a===MathModel.Variables.CeilingPriceTotal)return this.updateCeilingPriceTotal;if(a===MathModel.Variables.SalesPriceTotal)return this.updateSalesPriceTotal;if(a===MathModel.Variables.ItemValues)return this.updateTotalValue;if(a===MathModel.Variables.ItemTotalValues)return this.updateTotalValues};
RequestDataAction.prototype.getRemoveAction=function(){var a=this.MethodKey;if(a===MathModel.Variables.ItemValues)return this.removeItemValues;if(a===MathModel.Variables.ItemTotalValues)return this.removeItemTotalValues}}LotAction.prototype=new MathAction;
function LotAction(c){this.init(c);LotAction.prototype.lotBasePriceChanged=function(a,d){var b=a.BasePrice.get(BigDecimal.ZERO),c=this.createNextAction(MathAction.Types.Update,a);a.BasePrice.load(this.ViewElement);a.updateBasePriceViewModel();b=a.BasePrice.get(BigDecimal.ZERO).subtract(b);c.MethodKey=MathModel.Variables.BasePrice;c.put(MathModel.Variables.LotBasePrice,b);d.enqueue(c)};LotAction.prototype.lotBasePriceVATChanged=function(a,d){var b=a.BasePriceVAT.get(BigDecimal.ZERO),c=this.createNextAction(MathAction.Types.Update,
a);a.BasePriceVAT.load(this.ViewElement);a.updateBasePriceVATViewModel();b=a.BasePriceVAT.get(BigDecimal.ZERO).subtract(b);c.MethodKey=MathModel.Variables.BasePriceVAT;c.put(MathModel.Variables.LotBasePriceVAT,b);d.enqueue(c)};LotAction.prototype.lotMinimumPriceChanged=function(a,c){var b=a.MinimumPrice.get(BigDecimal.ZERO),e=this.createNextAction(MathAction.Types.Update,a);a.MinimumPrice.load(this.ViewElement);a.updateMinimumPriceViewModel();b=a.MinimumPrice.get(BigDecimal.ZERO).subtract(b);e.MethodKey=
MathModel.Variables.MinimumPrice;e.put(MathModel.Variables.LotMinimumPrice,b);c.enqueue(e)};LotAction.prototype.createNextAction=function(a,c){var b=c.NextModelInfo;if(b&&b.Type===ProcedureRequestModel.Type)return new ProcedureRequestAction({Type:a,ModelRef:b})};LotAction.prototype.getChangeAction=function(){var a=this.MethodKey;if(a===MathModel.Variables.LotBasePrice)return this.lotBasePriceChanged;if(a===MathModel.Variables.LotBasePriceVAT)return this.lotBasePriceVATChanged;if(a===MathModel.Variables.LotMinimumPrice)return this.lotMinimumPriceChanged}}
RequestDataAction.prototype=new MathAction;
function RequestDataAction(c){this.init(c);RequestDataAction.prototype.updateCostPriceTotal=function(a,c){var b=this.get(MathModel.Variables.CostPriceTotal);valueLotCode=this.get(MathModel.Variables.LotCode);a.updateCostPriceTotal(b,valueLotCode)};RequestDataAction.prototype.updateCeilingPriceTotal=function(a,c){var b=this.get(MathModel.Variables.CeilingPriceTotal),e=this.get(MathModel.Variables.LotCode),f=this.createNextAction(MathAction.Types.Update,a);a.updateCeilingPriceTotal(b,e);f&&(f.MethodKey=
MathModel.Variables.CeilingPriceTotal,f.put(MathModel.Variables.LotCode,e),f.put(MathModel.Variables.CeilingPriceTotal,b),c.enqueue(f))};RequestDataAction.prototype.updateSalesPriceTotal=function(a,c){var b=this.get(MathModel.Variables.SalesPriceTotal),e=this.get(MathModel.Variables.LotCode);a.updateSalesPriceTotal(b,e)};RequestDataAction.prototype.updateTotalValue=function(a,c){var b=this.get(MathModel.Variables.ItemValues),e=this.get(MathModel.Variables.LotCode),f=this.createNextAction(MathAction.Types.Update,
a);a.updateLotValues(e,b);f&&(f.MethodKey=MathModel.Variables.ItemValues,f.put(MathModel.Variables.LotCode,e),f.put(MathModel.Variables.ItemValues,b),c.enqueue(f))};RequestDataAction.prototype.updateTotalValues=function(a,c){var b=this.get(MathModel.Variables.ItemTotalValues),e=this.createNextAction(MathAction.Types.Update,a);a.addItemTotalValues(b);e&&(e.MethodKey=MathModel.Variables.ItemTotalValues,e.put(MathModel.Variables.ItemTotalValues,b),c.enqueue(e))};RequestDataAction.prototype.addItemValues=
function(a,c){var b=this.get(MathModel.Variables.ItemValues),e=this.createNextAction(MathAction.Types.Add,a);a.addItemValues(b);e&&(e.MethodKey=MathModel.Variables.ItemValues,e.put(MathModel.Variables.ItemValues,b),c.enqueue(e))};RequestDataAction.prototype.removeItemValues=function(a,c){var b=this.get(MathModel.Variables.ItemValues),e=this.createNextAction(MathAction.Types.Remove,a);a.removeItemValues(b);e&&(e.MethodKey=MathModel.Variables.ItemValues,e.put(MathModel.Variables.ItemValues,b),c.enqueue(e))};
RequestDataAction.prototype.removeItemTotalValues=function(a,c){var b=this.get(MathModel.Variables.ItemTotalValues),e=this.createNextAction(MathAction.Types.Remove,a);a.removeItemTotalValues(b);e&&(e.MethodKey=MathModel.Variables.ItemTotalValues,e.put(MathModel.Variables.ItemTotalValues,b),c.enqueue(e))};RequestDataAction.prototype.createNextAction=function(a,c){var b=c.NextModelInfo;if(b&&b.Type===ProcedureRequestModel.Type)return new ProcedureRequestAction({Type:a,ModelRef:b})};RequestDataAction.prototype.getAddAction=
function(){if(this.MethodKey===MathModel.Variables.ItemValues)return this.addItemValues};RequestDataAction.prototype.getUpdateAction=function(){var a=this.MethodKey;if(a===MathModel.Variables.CostPriceTotal)return this.updateCostPriceTotal;if(a===MathModel.Variables.CeilingPriceTotal)return this.updateCeilingPriceTotal;if(a===MathModel.Variables.SalesPriceTotal)return this.updateSalesPriceTotal;if(a===MathModel.Variables.ItemValues)return this.updateTotalValue;if(a===MathModel.Variables.ItemTotalValues)return this.updateTotalValues};
RequestDataAction.prototype.getRemoveAction=function(){var a=this.MethodKey;if(a===MathModel.Variables.ItemValues)return this.removeItemValues;if(a===MathModel.Variables.ItemTotalValues)return this.removeItemTotalValues}}ProcedureRequestAction.prototype=new MathAction;
function ProcedureRequestAction(c){this.init(c);ProcedureRequestAction.prototype.basePriceChanged=function(a,c){a.BasePrice.load(this.ViewElement)};ProcedureRequestAction.prototype.basePriceVATChanged=function(a,c){a.BasePriceVAT.load(this.ViewElement)};ProcedureRequestAction.prototype.minimumPriceChanged=function(a,c){a.MinimumPrice.load(this.ViewElement)};ProcedureRequestAction.prototype.defineBasePriceChanged=function(a,c){a.DefineBasePrice.load(this.ViewElement);a.updateDefineBasePrice()};ProcedureRequestAction.prototype.defineMinimumPriceChanged=
function(a,c){a.DefineMinimumPrice.load(this.ViewElement);a.updateDefineMinimumPrice()};ProcedureRequestAction.prototype.defineLotsChanged=function(a,c){a.DefineLots.load(this.ViewElement);a.updateDefineLots()};ProcedureRequestAction.prototype.defineLotsPricesChanged=function(a,c){a.DefineLotsPrices.load(this.ViewElement);a.updateDefineLotsPrices()};ProcedureRequestAction.prototype.usePriceListValuesChanged=function(a,c){a.UsePriceListValues.load(this.ViewElement);a.updateUsePriceListValues()};ProcedureRequestAction.prototype.addLot=
function(a,c){var b=this.get(MathModel.Variables.Lot),b=LotModel.factory(b),e=b.Key.get();a.addLotModel(b);RequestDataModel.addLot(e)};ProcedureRequestAction.prototype.removeLots=function(a,c){var b=this.get(MathModel.Variables.LotCode);0<b.length&&(a.removeLots(b),RequestDataModel.removeLots(b),$.modelStorage.removeByType(LotModel.Type,b))};ProcedureRequestAction.prototype.addItemValues=function(a,c){var b=this.get(MathModel.Variables.ItemValues);a.addItemValues(b)};ProcedureRequestAction.prototype.updateBasePrice=
function(a,c){var b=this.get(MathModel.Variables.LotBasePrice);a.updateBasePrice(b)};ProcedureRequestAction.prototype.updateBasePriceVAT=function(a,c){var b=this.get(MathModel.Variables.LotBasePriceVAT);a.updateBasePriceVAT(b)};ProcedureRequestAction.prototype.updateMinimumPrice=function(a,c){var b=this.get(MathModel.Variables.LotMinimumPrice);a.updateMinimumPrice(b)};ProcedureRequestAction.prototype.updateCeilingPriceTotal=function(a,c){var b=this.get(MathModel.Variables.CeilingPriceTotal),e=this.get(MathModel.Variables.LotCode);
a.updateLotBasePrice(b,e)};ProcedureRequestAction.prototype.updateTotalValue=function(a,c){var b=this.get(MathModel.Variables.ItemValues),e=this.get(MathModel.Variables.LotCode);a.updateLotValues(e,b)};ProcedureRequestAction.prototype.updateTotalValues=function(a,c){var b=this.get(MathModel.Variables.ItemTotalValues);a.updateLotTotalValues(b)};ProcedureRequestAction.prototype.updateModel=function(a,c){var b=this.get(MathModel.Variables.JsonModel);a.updateValues(b)};ProcedureRequestAction.prototype.removeItemValues=
function(a,c){var b=this.get(MathModel.Variables.ItemValues);a.removeItemValues(b)};ProcedureRequestAction.prototype.removeItemTotalValues=function(a,c){var b=this.get(MathModel.Variables.ItemTotalValues);a.removeItemTotalValues(b)};ProcedureRequestAction.prototype.getChangeAction=function(){var a=this.MethodKey;if(a===MathModel.Variables.BasePrice)return this.basePriceChanged;if(a===MathModel.Variables.DefineBasePrice)return this.defineBasePriceChanged;if(a===MathModel.Variables.MinimumPrice)return this.minimumPriceChanged;
if(a===MathModel.Variables.DefineMinimumPrice)return this.defineMinimumPriceChanged;if(a===MathModel.Variables.DefineLots)return this.defineLotsChanged;if(a===MathModel.Variables.DefineLotsPrices)return this.defineLotsPricesChanged;if(a===MathModel.Variables.UsePriceListValues)return this.usePriceListValuesChanged};ProcedureRequestAction.prototype.getAddAction=function(){var a=this.MethodKey;if(a===MathModel.Variables.Lot)return this.addLot;if(a===MathModel.Variables.ItemValues)return this.addItemValues};
ProcedureRequestAction.prototype.getUpdateAction=function(){var a=this.MethodKey;if(a===MathModel.Variables.BasePrice)return this.updateBasePrice;if(a===MathModel.Variables.BasePriceVAT)return this.updateBasePriceVAT;if(a===MathModel.Variables.MinimumPrice)return this.updateMinimumPrice;if(a===MathModel.Variables.CeilingPriceTotal)return this.updateCeilingPriceTotal;if(a===MathModel.Variables.ItemValues)return this.updateTotalValue;if(a===MathModel.Variables.ItemTotalValues)return this.updateTotalValues;
if(a===MathModel.Variables.Model)return this.updateModel};ProcedureRequestAction.prototype.getRemoveAction=function(){var a=this.MethodKey;if(a===MathModel.Variables.ItemValues)return this.removeItemValues;if(a===MathModel.Variables.ItemTotalValues)return this.removeItemTotalValues;if(a===MathModel.Variables.LotCode)return this.removeLots}}ProcedureRequestEngine.prototype=new MathEngine;
ProcedureRequestEngine.addLot=function(c,a){var d=new ProcedureRequestEngine,b=d._actionFactory({Type:MathAction.Types.Add,MethodKey:MathModel.Variables.Lot,ModelRef:new MathModelReference(c)});b.put(MathModel.Variables.Lot,a);d.enqueue(b);d.execute()};
ProcedureRequestEngine.removeLots=function(c,a){var d=new ProcedureRequestEngine,b=d._actionFactory({Type:MathAction.Types.Remove,MethodKey:MathModel.Variables.LotCode,ModelRef:new MathModelReference(c)});b.put(MathModel.Variables.LotCode,a);d.enqueue(b);d.execute()};
ProcedureRequestEngine.onChange=function(){var c=$(this),a=new ProcedureRequestEngine,d,b;if(d=MathModelProperty.getPropertyName(c))if(b=MathModel.getModelElement(c),b=a.getModelFromElement(b))c=a._actionFactory({Type:MathAction.Types.Change,Model:b,MethodKey:d,ViewElement:c}),a.enqueue(c),a.execute()};ProcedureRequestEngine.onAdd=function(c){var a=new ProcedureRequestEngine;c=a._actionFactory({Type:MathAction.Types.Add,ModelRef:new MathModelReference(c)});a.enqueue(c);a.execute()};
ProcedureRequestEngine.addValues=function(c){if(c){c=JSON.parse(c);for(var a=new ProcedureRequestEngine,d=0,b=c.length;d<b;d++){var e=c[d],f=a._actionFactory({Type:MathAction.Types.Add,MethodKey:MathModel.Variables.ItemTotalValues,ModelRef:new MathModelReference(e.MKey)}),e=TotalValuesModel.factory(e);f.put(MathModel.Variables.ItemValues,e);a.enqueue(f)}a.execute()}};
ProcedureRequestEngine.onRemove=function(){var c=$(this).data("mkey"),a=new ProcedureRequestEngine,c=a._actionFactory({Type:MathAction.Types.Remove,ModelRef:new MathModelReference(c)});a.enqueue(c);a.execute()};ProcedureRequestEngine.removeModels=function(c){if(c){for(var a=new ProcedureRequestEngine,d=0,b=c.length;d<b;d++){var e=a._actionFactory({Type:MathAction.Types.Remove,ModelRef:new MathModelReference(c[d])});a.enqueue(e)}a.execute()}};
ProcedureRequestEngine.onUpdate=function(c,a){var d=$.parseJSON(a),b=new ProcedureRequestEngine,e=b._actionFactory({Type:MathAction.Types.Update,MethodKey:MathModel.Variables.Model,ModelRef:new MathModelReference(c)});e.put(MathModel.Variables.JsonModel,d);b.enqueue(e);b.execute()};ProcedureRequestEngine.loadModel=function(c){(new ProcedureRequestEngine).loadModel(c)};
function ProcedureRequestEngine(){ProcedureRequestEngine.prototype._actionFactory=function(c){var a=void 0,d=c.Model&&c.Model.Info.Type||c.ModelRef&&c.ModelRef.Type;d===BilItemModel.Type?a=new BilItemAction(c):d===BilChapterModel.Type?a=new BilChapterAction(c):d===BilTotalModel.Type?a=new BilTotalAction(c):d===BioQuestionModel.Type?a=new BioQuestionAction(c):d===BioSectionModel.Type?a=new BioSectionAction(c):d===LotModel.Type?a=new LotAction(c):d===ProcedureRequestModel.Type&&(a=new ProcedureRequestAction(c));
return a};ProcedureRequestEngine.prototype._modelFactory=function(c,a){var d=void 0;c===BilItemModel.Type?(d=new BilItemModel,d.load(a)):c===BilChapterModel.Type?(d=new BilChapterModel,d.load(a)):c===BilTotalModel.Type&&(d=new BilTotalModel,d.load(a));return d}};
