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); }
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); }