public override Amortization Deserialize(IBsonReader bsonReader)
        {
            string read = null;

            bsonReader.ReadStartDocument();

            var amort = new Amortization
            {
                ID        = bsonReader.ReadGuid("_id", ref read),
                User      = bsonReader.ReadString("user", ref read),
                Name      = bsonReader.ReadString("name", ref read),
                Value     = bsonReader.ReadDouble("value", ref read),
                Date      = bsonReader.ReadDateTime("date", ref read),
                TotalDays = bsonReader.ReadInt32("tday", ref read),
            };

            amort.Interval = bsonReader.ReadString("interval", ref read) switch
            {
                "d" => AmortizeInterval.EveryDay,
                "w" => AmortizeInterval.SameDayOfWeek,
                "W" => AmortizeInterval.LastDayOfWeek,
                "m" => AmortizeInterval.SameDayOfMonth,
                "M" => AmortizeInterval.LastDayOfMonth,
                "y" => AmortizeInterval.SameDayOfYear,
                "Y" => AmortizeInterval.LastDayOfYear,
                _ => amort.Interval,
            };

            amort.Template = bsonReader.ReadDocument("template", ref read, VoucherSerializer.Deserialize);
            amort.Schedule = bsonReader.ReadArray("schedule", ref read, ItemSerializer.Deserialize);
            amort.Remark   = bsonReader.ReadString("remark", ref read);
            bsonReader.ReadEndDocument();
            return(amort);
        }
Beispiel #2
0
        public override Voucher Deserialize(IBsonReader bsonReader)
        {
            string read = null;

            bsonReader.ReadStartDocument();

            var voucher = new Voucher
            {
                ID   = bsonReader.ReadObjectId("_id", ref read),
                Date = bsonReader.ReadDateTime("date", ref read),
                Type = VoucherType.Ordinary,
            };

            voucher.Type = bsonReader.ReadString("special", ref read) switch
            {
                "amorz" => VoucherType.Amortization,
                "acarry" => VoucherType.AnnualCarry,
                "carry" => VoucherType.Carry,
                "dep" => VoucherType.Depreciation,
                "dev" => VoucherType.Devalue,
                "unc" => VoucherType.Uncertain,
                _ => VoucherType.Ordinary,
            };

            voucher.Details = bsonReader.ReadArray("detail", ref read, new VoucherDetailSerializer().Deserialize);
            voucher.Remark  = bsonReader.ReadString("remark", ref read);
            bsonReader.ReadEndDocument();

            return(voucher);
        }
Beispiel #3
0
        public override Asset Deserialize(IBsonReader bsonReader)
        {
            string read = null;

            bsonReader.ReadStartDocument();

            var asset = new Asset
            {
                ID                       = bsonReader.ReadGuid("_id", ref read),
                User                     = bsonReader.ReadString("user", ref read),
                Name                     = bsonReader.ReadString("name", ref read),
                Date                     = bsonReader.ReadDateTime("date", ref read),
                Currency                 = bsonReader.ReadString("currency", ref read),
                Value                    = bsonReader.ReadDouble("value", ref read),
                Salvge                   = bsonReader.ReadDouble("salvge", ref read),
                Life                     = bsonReader.ReadInt32("life", ref read),
                Title                    = bsonReader.ReadInt32("title", ref read),
                DepreciationTitle        = bsonReader.ReadInt32("deptitle", ref read),
                DevaluationTitle         = bsonReader.ReadInt32("devtitle", ref read),
                DepreciationExpenseTitle = bsonReader.ReadInt32("exptitle", ref read),
                DevaluationExpenseTitle  = bsonReader.ReadInt32("exvtitle", ref read)
            };

            switch (bsonReader.ReadString("method", ref read))
            {
            case "sl":
                asset.Method = DepreciationMethod.StraightLine;
                break;

            case "sy":
                asset.Method = DepreciationMethod.SumOfTheYear;
                break;

            case "dd":
                asset.Method = DepreciationMethod.DoubleDeclineMethod;
                break;

            default:
                asset.Method = DepreciationMethod.None;
                break;
            }

            if (asset.DepreciationExpenseTitle > 100)
            {
                asset.DepreciationExpenseSubTitle = asset.DepreciationExpenseTitle % 100;
                asset.DepreciationExpenseTitle   /= 100;
            }

            if (asset.DevaluationExpenseTitle > 100)
            {
                asset.DevaluationExpenseSubTitle = asset.DevaluationExpenseTitle % 100;
                asset.DevaluationExpenseTitle   /= 100;
            }

            asset.Schedule = bsonReader.ReadArray("schedule", ref read, ItemSerializer.Deserialize);
            asset.Remark   = bsonReader.ReadString("remark", ref read);
            bsonReader.ReadEndDocument();
            return(asset);
        }
        public override Amortization Deserialize(IBsonReader bsonReader)
        {
            string read = null;

            bsonReader.ReadStartDocument();

            var amort = new Amortization
            {
                ID        = bsonReader.ReadGuid("_id", ref read),
                User      = bsonReader.ReadString("user", ref read),
                Name      = bsonReader.ReadString("name", ref read),
                Value     = bsonReader.ReadDouble("value", ref read),
                Date      = bsonReader.ReadDateTime("date", ref read),
                TotalDays = bsonReader.ReadInt32("tday", ref read)
            };

            switch (bsonReader.ReadString("interval", ref read))
            {
            case "d":
                amort.Interval = AmortizeInterval.EveryDay;
                break;

            case "w":
                amort.Interval = AmortizeInterval.SameDayOfWeek;
                break;

            case "W":
                amort.Interval = AmortizeInterval.LastDayOfWeek;
                break;

            case "m":
                amort.Interval = AmortizeInterval.SameDayOfMonth;
                break;

            case "M":
                amort.Interval = AmortizeInterval.LastDayOfMonth;
                break;

            case "y":
                amort.Interval = AmortizeInterval.SameDayOfYear;
                break;

            case "Y":
                amort.Interval = AmortizeInterval.LastDayOfYear;
                break;
            }

            amort.Template = bsonReader.ReadDocument("template", ref read, VoucherSerializer.Deserialize);
            amort.Schedule = bsonReader.ReadArray("schedule", ref read, ItemSerializer.Deserialize);
            amort.Remark   = bsonReader.ReadString("remark", ref read);
            bsonReader.ReadEndDocument();
            return(amort);
        }
        public override Voucher Deserialize(IBsonReader bsonReader)
        {
            string read = null;

            bsonReader.ReadStartDocument();

            var voucher = new Voucher
            {
                ID   = bsonReader.ReadObjectId("_id", ref read),
                Date = bsonReader.ReadDateTime("date", ref read),
                Type = VoucherType.Ordinary
            };

            switch (bsonReader.ReadString("special", ref read))
            {
            case "amorz":
                voucher.Type = VoucherType.Amortization;
                break;

            case "acarry":
                voucher.Type = VoucherType.AnnualCarry;
                break;

            case "carry":
                voucher.Type = VoucherType.Carry;
                break;

            case "dep":
                voucher.Type = VoucherType.Depreciation;
                break;

            case "dev":
                voucher.Type = VoucherType.Devalue;
                break;

            case "unc":
                voucher.Type = VoucherType.Uncertain;
                break;

            default:
                voucher.Type = VoucherType.Ordinary;
                break;
            }

            voucher.Details = bsonReader.ReadArray("detail", ref read, new VoucherDetailSerializer().Deserialize);
            voucher.Remark  = bsonReader.ReadString("remark", ref read);
            bsonReader.ReadEndDocument();

            return(voucher);
        }