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 FOutlay;
(function (FOutlay) {
    var FDocument = (function (_super) {
        __extends(FDocument, _super);
        function FDocument(id, version, oldVersion) {
            var _this = _super.call(this, id, version, oldVersion) || this;
            _this._p1GroupSheet = null;
            _this._p2GroupSheet = null;
            _this._p3GroupSheet = null;
            _this._p4GroupSheet = null;
            _this._p5sp2GroupSheet = null;
            _this._p5sp3p1GroupSheet = null;
            _this._p5sp3p2GroupSheet = null;
            _this._p5sp3p3GroupSheet = null;
            _this._excelExport = null;
            _this._tableRules = new FOutlay.TableRules(_this);
            _this._interfaceRules = new FOutlay.InterfaceRules(_this);
            return _this;
        }
        Object.defineProperty(FDocument.prototype, "ExcelExport", {
            get: function () {
                if (this._excelExport == null) {
                    this._excelExport = new FOutlay.ExcelExport(this);
                }
                return this._excelExport;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(FDocument.prototype, "P1GroupSheet", {
            get: function () {
                if (this._p1GroupSheet == null) {
                    this._p1GroupSheet = new FOutlay.P1GroupSheet(this, "Part1_Outlay_SumByAnalytics");
                }
                return this._p1GroupSheet;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(FDocument.prototype, "P2GroupSheet", {
            get: function () {
                if (this._p2GroupSheet == null) {
                    this._p2GroupSheet = new FOutlay.P2GroupSheet(this, "Part2_Outlay_SumByAnalytics", "Part4_Outlay_SumByAnalytics");
                }
                return this._p2GroupSheet;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(FDocument.prototype, "P3GroupSheet", {
            get: function () {
                if (this._p3GroupSheet == null) {
                    this._p3GroupSheet = new FOutlay.PXGroupSheet(this, "Part3_Outlay_SumByAnalytics");
                }
                return this._p3GroupSheet;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(FDocument.prototype, "P4GroupSheet", {
            get: function () {
                if (this._p4GroupSheet == null) {
                    this._p4GroupSheet = new FOutlay.PXGroupSheet(this, "Part4_Outlay_SumByAnalytics");
                }
                return this._p4GroupSheet;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(FDocument.prototype, "P5sp2GroupSheet", {
            get: function () {
                if (this._p5sp2GroupSheet == null) {
                    this._p5sp2GroupSheet = new FOutlay.PXGroupSheet(this, "Part5sp2_Outlay_SumByAnalytics");
                }
                return this._p5sp2GroupSheet;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(FDocument.prototype, "P5sp3p1GroupSheet", {
            get: function () {
                if (this._p5sp3p1GroupSheet == null) {
                    this._p5sp3p1GroupSheet = new FOutlay.P5sp3xGroupSheet(this, "Part5sp3p1_Outlay_SumByAnalytics");
                }
                return this._p5sp3p1GroupSheet;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(FDocument.prototype, "P5sp3p2GroupSheet", {
            get: function () {
                if (this._p5sp3p2GroupSheet == null) {
                    this._p5sp3p2GroupSheet = new FOutlay.P5sp3xGroupSheet(this, "Part5sp3p2_Outlay_SumByAnalytics");
                }
                return this._p5sp3p2GroupSheet;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(FDocument.prototype, "P5sp3p3GroupSheet", {
            get: function () {
                if (this._p5sp3p3GroupSheet == null) {
                    this._p5sp3p3GroupSheet = new FOutlay.P5sp3xGroupSheet(this, "Part5sp3p3_Outlay_SumByAnalytics");
                }
                return this._p5sp3p3GroupSheet;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(FDocument.prototype, "TableRules", {
            get: function () {
                return this._tableRules;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(FDocument.prototype, "InterfaceRules", {
            get: function () {
                return this._interfaceRules;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(FDocument.prototype, "DocType", {
            get: function () {
                return this.MainParametersTable.GetFieldValue("DocType");
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(FDocument.prototype, "OutlayType", {
            get: function () {
                var filterTable = ObasTableCollection.RroOutlaySumByAnalyticsFilterTable;
                var rroOutlaySumByAnalyticsTable = ObasTableCollection.RroOutlaySumByAnalyticsTable;
                var rroOutlayTable = null;
                if (filterTable.RroOutlayFieldId.Value === rroOutlaySumByAnalyticsTable.RroOutlay.ForeignKey.Id) {
                    rroOutlayTable = ObasTableCollection.RroOutlayTable;
                }
                else {
                    rroOutlayTable = ObasTableCollection.RroSumOutlayTable;
                }
                var curKey = rroOutlayTable.RecordKey.Value;
                rroOutlayTable.Locate(rroOutlayTable.RecordKey.Id, filterTable.RroOutlayKey.Value);
                var result = rroOutlayTable.Type.Value;
                rroOutlayTable.Locate(rroOutlayTable.RecordKey.Id, curKey);
                return result;
            },
            enumerable: true,
            configurable: true
        });
        return FDocument;
    }(BaseDocumentObject));
    FOutlay.FDocument = FDocument;
    var FDocument2 = (function (_super) {
        __extends(FDocument2, _super);
        function FDocument2() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        return FDocument2;
    }(FDocument));
    FOutlay.FDocument2 = FDocument2;
})(FOutlay || (FOutlay = {}));
