using Vbdsm.Common; namespace Vbdsm.Gen { public class TerminalData { public TerminalData() { CompanyId = ""; TerminalId = ""; } public TerminalData(string? companyId, string terminalId) { CompanyId = companyId; TerminalId = terminalId; } public string? CompanyId { get; set; } public string TerminalId { get; set; } public Dictionary MonthTotal_P { get; set; } = new Dictionary(); public decimal Total_P { get; set; } public Dictionary MonthTotal_E { get; set; } = new Dictionary(); public decimal Total_E { get; set; } private string Key => $"{DateTime.Now:yyyyMMdd}"; public decimal GetCurMonthTotal_P() { if (!MonthTotal_P.TryGetValue(Key, out var d)) { d = 0; } return d; } public decimal GetCurMonthTotal_E() { if (!MonthTotal_E.TryGetValue(Key, out var d)) { d = 0; } return d; } public TerminalData SetTotal_P(decimal d) { Total_P = d; return this; } public TerminalData SetMouthTotal_P(decimal d) { if (MonthTotal_P.ContainsKey(Key)) { MonthTotal_P.Remove(Key); } MonthTotal_P.Add(Key, d); return this; } public TerminalData SetTotal_E(decimal d) { Total_E = d; return this; } public TerminalData SetMouthTotal_E(decimal d) { if (MonthTotal_E.ContainsKey(Key)) { MonthTotal_E.Remove(Key); } MonthTotal_E.Add(Key, d); return this; } public TerminalData Save() { FileHelper.SaveFileInfo(this, $"{CompanyId}@{TerminalId}"); return this; } } }