var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var F01XXXBase;
(function (F01XXXBase) {
    var ObasTableFields = (function (_super) {
        __extends(ObasTableFields, _super);
        function ObasTableFields() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        Object.defineProperty(ObasTableFields, "OtherRubField", {
            get: function () {
                if (this._otherRubField == null) {
                    this._otherRubField = new BaseGenericObasTableField("Other_Rub_Y");
                }
                return this._otherRubField;
            },
            enumerable: true,
            configurable: true
        });
        ObasTableFields._otherRubField = null;
        return ObasTableFields;
    }(BaseObasTableFields));
    F01XXXBase.ObasTableFields = ObasTableFields;
    var TableRules = (function () {
        function TableRules(_document) {
            this._document = _document;
        }
        return TableRules;
    }());
    F01XXXBase.TableRules = TableRules;
    var PurchaseObjectsSprTable = (function (_super) {
        __extends(PurchaseObjectsSprTable, _super);
        function PurchaseObjectsSprTable() {
            var _this = _super.call(this, "PurchaseObjects") || this;
            _this._npaGroupKey = null;
            _this._number = null;
            _this._npaGroup = null;
            return _this;
        }
        Object.defineProperty(PurchaseObjectsSprTable.prototype, "Number", {
            get: function () {
                if (this._number == null) {
                    this._number = new ObasTableField("Number", this);
                }
                return this._number;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PurchaseObjectsSprTable.prototype, "NpaGroupKey", {
            get: function () {
                if (this._npaGroupKey == null) {
                    this._npaGroupKey = new NumberObasTableField("SubgroupNormativeExpenses_ID", this);
                }
                return this._npaGroupKey;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PurchaseObjectsSprTable.prototype, "NpaGroup", {
            get: function () {
                if (this._npaGroup == null) {
                    this._npaGroup = new ObasSprTableField(ObasTableCollection.SubgroupNormativeExpensesSprTable, this);
                }
                return this._npaGroup;
            },
            enumerable: true,
            configurable: true
        });
        return PurchaseObjectsSprTable;
    }(SprTable));
    F01XXXBase.PurchaseObjectsSprTable = PurchaseObjectsSprTable;
    var PartObjectDataTable = /** @class */ (function (_super) {
        __extends(PartObjectDataTable, _super);
        function PartObjectDataTable(id, _document, _descTable) {
            var _this = _super.call(this, id) || this;
            _this._document = _document;
            _this._descTable = _descTable;
            _this._objectKey = null;
            _this._object = _this._document.PurchaseObjectsSprTable;
            _this._deletedObjKey = 0;
            return _this;
        }
        Object.defineProperty(PartObjectDataTable.prototype, "ObjectKey", {
            get: function () {
                if (this._objectKey == null) {
                    this._objectKey = new NumberObasTableField("PurchaseObjects_ID", this);
                }
                return this._objectKey;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PartObjectDataTable.prototype, "ObjectName", {
            get: function () {
                this._object.LocateByKeys(this.ObjectKey.Value);
                return this._object.Name;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PartObjectDataTable.prototype, "ObjectNumber", {
            get: function () {
                this._object.LocateByKeys(this.ObjectKey.Value);
                return this._object.Number;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PartObjectDataTable.prototype, "ObjectNpaGroupCode", {
            get: function () {
                this._object.LocateByKeys(this.ObjectKey.Value);
                return this._object.NpaGroup.Code;
            },
            enumerable: true,
            configurable: true
        });
        PartObjectDataTable.prototype.CalcSubgroupNormativeExpensesName = function () {
            this._object.LocateByKeys(this.ObjectKey.Value);
            return this._object.NpaGroup.Name || "";
        };
        PartObjectDataTable.prototype.ObjectChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            this.AfterDeleteEventHandler(this.Id, oldValue);
            this._descTable.AddObject(newValue);
        };
        PartObjectDataTable.prototype.DeleteEventHandler = function (tableId) {
            this._deletedObjKey = this.ObjectKey.Value;
        };
        PartObjectDataTable.prototype.AfterDeleteEventHandler = function (tableId, objKey) {
            if (objKey === void 0) { objKey = this._deletedObjKey; }
            this._descTable.DeleteObject(tableId, objKey);
        };
        return PartObjectDataTable;
    }(ObasTable));
    F01XXXBase.PartObjectDataTable = PartObjectDataTable;
    var PartOkpdTable = (function (_super) {
        __extends(PartOkpdTable, _super);
        function PartOkpdTable(id, document, parent) {
            var _this = _super.call(this, id, document, parent) || this;
            _this._okpdKey = null;
            _this._okpd = null;
            return _this;
        }
        Object.defineProperty(PartOkpdTable.prototype, "OKPDKey", {
            get: function () {
                if (this._okpdKey == null) {
                    this._okpdKey = new NumberObasTableField("OKPD_ID", this);
                }
                return this._okpdKey;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PartOkpdTable.prototype, "Okpd", {
            get: function () {
                if (this._okpd == null) {
                    this._okpd = new ObasSprTableField(ObasTableCollection.OkpdSprTable, this);
                }
                return this._okpd;
            },
            enumerable: true,
            configurable: true
        });
        return PartOkpdTable;
    }(ObasTableWithSimpleKeysParent));
    F01XXXBase.PartOkpdTable = PartOkpdTable;
    var PartKosguTable = (function (_super) {
        __extends(PartKosguTable, _super);
        function PartKosguTable(id, document, parent) {
            var _this = _super.call(this, id, document, parent) || this;
            _this._kosguKey = null;
            _this._kosgu = null;
            _this._analysisFeatureKey = null;
            _this._analysisFeature = null;
            _this._year = null;
            return _this;
        }
        Object.defineProperty(PartKosguTable.prototype, "KosguKey", {
            get: function () {
                if (this._kosguKey == null) {
                    this._kosguKey = new NumberObasTableField("KOSGU_ID", this);
                }
                return this._kosguKey;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PartKosguTable.prototype, "AnalysisFeatureKey", {
            get: function () {
                if (this._analysisFeatureKey == null) {
                    this._analysisFeatureKey = new NumberObasTableField("AddAnalysisFeature_ID", this);
                }
                return this._analysisFeatureKey;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PartKosguTable.prototype, "Kosgu", {
            get: function () {
                if (this._kosgu == null) {
                    this._kosgu = new ObasSprTableField(ObasTableCollection.KosguSprTable, this);
                }
                return this._kosgu;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PartKosguTable.prototype, "AnalysisFeature", {
            get: function () {
                if (this._analysisFeature == null) {
                    this._analysisFeature = new ObasSprTableField(ObasTableCollection.AddAnalysisFeatureSprtable, this);
                }
                return this._analysisFeature;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PartKosguTable.prototype, "Year", {
            get: function () {
                if (this._year == null) {
                    this._year = new NumberObasTableField(BaseObasTableFields.YearField.Id, this);
                }
                return this._year;
            },
            enumerable: true,
            configurable: true
        });
        return PartKosguTable;
    }(ObasTableWithSimpleKeysParent));
    F01XXXBase.PartKosguTable = PartKosguTable;
    var UsdPartKosguTable = (function (_super) {
        __extends(UsdPartKosguTable, _super);
        function UsdPartKosguTable(id, document, parent) {
            return _super.call(this, id, document, parent) || this;
        }
        UsdPartKosguTable.prototype.SumPartsChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            this.SetFieldValue(BaseObasTableFields.YearDataField.GenerateId(fieldId), (this.GetFieldValue(BaseObasTableFields.RubYearDataField.GenerateId(fieldId)) || 0) +
                (this.GetFieldValue(ObasTableFields.OtherRubField.GenerateId(fieldId)) || 0));
        };
        UsdPartKosguTable.prototype.UsdChangeEventHandler = function (tableId, oldValue, newValue, fieldId) {
            var yearOffSet = ObasHelper.GetYearOffsetById(fieldId);
            var usdValue = this.Document.CommonRules.GetDollarRateByYear(ObasStageSettings.CurrentYear + yearOffSet);
            this.SetFieldValue(BaseObasTableFields.RubYearDataField.GenerateId(yearOffSet + 1), usdValue * newValue);
        };
        return UsdPartKosguTable;
    }(PartKosguTable));
    F01XXXBase.UsdPartKosguTable = UsdPartKosguTable;
    var ObjectDescTable = (function (_super) {
        __extends(ObjectDescTable, _super);
        function ObjectDescTable(id, _document) {
            var _this = _super.call(this, id) || this;
            _this._document = _document;
            _this._program = null;
            _this._action = null;
            _this._result = null;
            _this._rationale = null;
            _this._info = null;
            _this._objectKey = null;
            _this._object = _this._document.PurchaseObjectsSprTable;
            return _this;
        }
        Object.defineProperty(ObjectDescTable.prototype, "Info", {
            get: function () {
                if (this._info == null) {
                    this._info = new ObasTableField("Info", this);
                }
                return this._info;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescTable.prototype, "Rationale", {
            get: function () {
                if (this._rationale == null) {
                    this._rationale = new ObasTableField("Rationale", this);
                }
                return this._rationale;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescTable.prototype, "Result", {
            get: function () {
                if (this._result == null) {
                    this._result = new ObasTableField("Result", this);
                }
                return this._result;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescTable.prototype, "Action", {
            get: function () {
                if (this._action == null) {
                    this._action = new ObasTableField("ActionName", this);
                }
                return this._action;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescTable.prototype, "Program", {
            get: function () {
                if (this._program == null) {
                    this._program = new ObasTableField("ProgName", this);
                }
                return this._program;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescTable.prototype, "ObjectKey", {
            get: function () {
                if (this._objectKey == null) {
                    this._objectKey = new NumberObasTableField("PurchaseObjects_ID", this);
                }
                return this._objectKey;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescTable.prototype, "ObjectName", {
            get: function () {
                this._object.LocateByKeys(this.ObjectKey.Value);
                return this._object.Name;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescTable.prototype, "ObjectNumber", {
            get: function () {
                this._object.LocateByKeys(this.ObjectKey.Value);
                return this._object.Number;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescTable.prototype, "ObjectNpaGroupCode", {
            get: function () {
                this._object.LocateByKeys(this.ObjectKey.Value);
                return this._object.NpaGroup.Code;
            },
            enumerable: true,
            configurable: true
        });
        ObjectDescTable.prototype.CalcSubgroupNormativeExpensesName = function () {
            this._object.LocateByKeys(this.ObjectKey.Value);
            return this._object.NpaGroup.Name || "";
        };
        ObjectDescTable.prototype.AddObject = function (objKey) {
            this._document.CommonRules.AddNewLink(this.Id, [this.ObjectKey.Id], [objKey]);
        };
        ObjectDescTable.prototype.DeleteObject = function (objectDataTable, objKey) {
            this._document.CommonRules.DeleteOldLink(this.Id, [objectDataTable], [this.ObjectKey.Id], [objKey]);
        };
        return ObjectDescTable;
    }(ObasTable));
    F01XXXBase.ObjectDescTable = ObjectDescTable;
    var ObjectDescNpaTable = (function (_super) {
        __extends(ObjectDescNpaTable, _super);
        function ObjectDescNpaTable() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this._npaFields = null;
            return _this;
        }
        Object.defineProperty(ObjectDescNpaTable.prototype, "NpaFields", {
            get: function () {
                if (this._npaFields == null) {
                    this._npaFields = new NpaRequisitesFields(this);
                }
                return this._npaFields;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescNpaTable.prototype, "NpaNumber", {
            get: function () {
                return this.NpaFields.NpaNumber;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescNpaTable.prototype, "NpaName", {
            get: function () {
                return this.NpaFields.NpaName;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescNpaTable.prototype, "NpaDate", {
            get: function () {
                return this.NpaFields.NpaDate;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescNpaTable.prototype, "NpaType", {
            get: function () {
                return this.NpaFields.NpaType;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescNpaTable.prototype, "NpaStatus", {
            get: function () {
                return this.NpaFields.NpaStatus;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(ObjectDescNpaTable.prototype, "NpaStatusChangeDate", {
            get: function () {
                return this.NpaFields.NpaStatusChangeDate;
            },
            enumerable: true,
            configurable: true
        });
        return ObjectDescNpaTable;
    }(ObasTableWithSimpleKeysParent));
    F01XXXBase.ObjectDescNpaTable = ObjectDescNpaTable;
})(F01XXXBase || (F01XXXBase = {}));
