private void parseIB(SieDataItem di) { if (!KONTO.ContainsKey(di.GetString(1))) { KONTO.Add(di.GetString(1), new SieAccount() { Number = di.GetString(1), Company = this.Company, Import = this.Import }); } var v = new SiePeriodValue() { YearNr = di.GetInt(0), Account = KONTO[di.GetString(1)], Amount = di.GetDecimal(2), Quantity = di.GetDecimal(3), Token = di.ItemType }; Callbacks.CallbackIB(v); if (!StreamValues) { IB.Add(v); } }
private void parseRES(SieDataItem di) { if (!KONTO.ContainsKey(di.GetString(1))) { KONTO.Add(di.GetString(1), new SieAccount() { Number = di.GetString(1), Company = this.Company, Import = this.Import }); } var objOffset = 0; if (di.RawData.Contains("{")) { objOffset = 1; } var v = new SiePeriodValue() { YearNr = di.GetInt(0), Account = KONTO[di.GetString(1)], Amount = di.GetDecimal(2 + objOffset), Quantity = di.GetDecimal(3 + objOffset), Token = di.ItemType }; Callbacks.CallbackRES(v); if (!StreamValues) { RES.Add(v); } return; }
private SiePeriodValue parsePBUDGET_PSALDO(SieDataItem di) { //Create the account if it hasn't been loaded yet. if (!KONTO.ContainsKey(di.GetString(2))) { KONTO.Add(di.GetString(2), new SieAccount() { Number = di.GetString(2), Company = this.Company, Import = this.Import }); } if (SIETYP == 1) { Callbacks.CallbackException(new SieInvalidFeatureException("Neither PSALDO or PBUDGET is part of SIE 1")); } if (SIETYP == 2 && di.RawData.Contains("{") && !di.RawData.Contains("{}")) { //Applications reading SIE type 2 should ignore PSALDO containing non empty dimension. return(null); } var objOffset = 0; if (di.RawData.Contains("{")) { objOffset = 1; } var v = new SiePeriodValue() { YearNr = di.GetInt(0), Period = di.GetInt(1), Account = KONTO[di.GetString(2)], Amount = di.GetDecimal(3 + objOffset), Quantity = di.GetDecimal(4 + objOffset), Token = di.ItemType }; if (SIETYP != 2 && di.RawData.Contains("{")) { v.Objects = di.GetObjects(); } return(v); }
private void parseRAR(SieDataItem di) { rar = new SieBookingYear(); rar.BookyearId = di.GetInt(0); rar.Start = di.GetDate(1); rar.End = di.GetDate(2); rar.Company = this.Company; rar.Import = this.Import; RAR.Add(rar.BookyearId, rar); }
private SiePeriodValue parseOIB_OUB(SieDataItem di) { //Create the account if it hasn't been loaded yet. if (!KONTO.ContainsKey(di.GetString(1))) { KONTO.Add(di.GetString(1), new SieAccount() { Number = di.GetString(1), Company = this.Company, Import = this.Import }); } if (SIETYP < 3) { Callbacks.CallbackException(new SieInvalidFeatureException("Neither OIB or OUB is part of SIE < 3")); } var objOffset = 0; if (di.RawData.Contains("{")) { objOffset = 1; } var v = new SiePeriodValue() { YearNr = di.GetInt(0), Period = di.GetInt(1), Account = KONTO[di.GetString(1)], Amount = di.GetDecimal(3 + objOffset), Quantity = di.GetDecimal(4) + objOffset, Objects = di.GetObjects(), Token = di.ItemType }; return(v); }
/// <summary> /// Does a fast scan of the file to get the Sie version it adheres to. /// </summary> /// <param name="fileName"></param> /// <returns>-1 if no SIE version was found in the file else SIETYPE is returned.</returns> public static int GetSieVersion(string fileName) { int ret = -1; foreach (var line in File.ReadLines(fileName, Encoding.GetEncoding(437))) { if (line.StartsWith("#SIETYP")) { var di = new SieDataItem(line, null); ret = di.GetInt(0); break; } } return(ret); }
private SieVoucher parseVER(SieDataItem di) { if (!di.GetDate(2).HasValue) { Callbacks.CallbackException(new MissingFieldException("Vaoucher date")); } var v = new SieVoucher() { Series = di.GetString(0), Number = di.GetString(1), VoucherDate = di.GetDate(2).HasValue ? di.GetDate(2).Value : new DateTime(), Text = di.GetString(3), CreatedDate = di.GetInt(4), CreatedBy = di.GetString(5), Token = di.ItemType, Company = this.Company, Import = this.Import }; return(v); }
public void ReadStreamDocument(StreamReader reader) { if (ThrowErrors) { Callbacks.SieException += throwCallbackException; } #region Initialize lists FNAMN = new SieCompany(); KONTO = new Dictionary <string, SieAccount>(); DIM = new Dictionary <string, SieDimension>(); OIB = new List <SiePeriodValue>(); OUB = new List <SiePeriodValue>(); PSALDO = new List <SiePeriodValue>(); PBUDGET = new List <SiePeriodValue>(); PROGRAM = new List <string>(); RAR = new Dictionary <int, SieBookingYear>(); IB = new List <SiePeriodValue>(); UB = new List <SiePeriodValue>(); RES = new List <SiePeriodValue>(); VER = new List <SieVoucher>(); ValidationExceptions = new List <Exception>(); InitializeDimensions(); #endregion //Initialize listst SieVoucher curVoucher = null; bool firstLine = true; // foreach (var line in reader.ReadLine()) // (_fileName, Encoding.ASCII)) string line = null; while (!reader.EndOfStream) { line = reader.ReadLine(); Callbacks.CallbackLine(line); var di = new SieDataItem(line, this); if (firstLine) { firstLine = false; if (di.ItemType != "#FLAGGA") { Callbacks.CallbackException(new SieInvalidFileException(_fileName)); return; } } if (CRC.Started && di.ItemType != "#KSUMMA") { CRC.AddData(di); } SiePeriodValue pv = null; switch (di.ItemType) { case "#ADRESS": FNAMN.Contact = di.GetString(0); FNAMN.Street = di.GetString(1); FNAMN.ZipCity = di.GetString(2); FNAMN.Phone = di.GetString(3); break; case "#BKOD": FNAMN.SNI = di.GetInt(0); break; case "#BTRANS": if (!IgnoreBTRANS) { parseTRANS(di, curVoucher); } break; case "#DIM": parseDimension(di); break; case "#ENHET": parseENHET(di); break; case "#FLAGGA": FLAGGA = di.GetInt(0); break; case "#FNAMN": FNAMN.Name = di.GetString(0); break; case "#FNR": FNAMN.Code = di.GetString(0); break; case "#FORMAT": FORMAT = di.GetString(0); break; case "#FTYP": FNAMN.OrgType = di.GetString(0); break; case "#GEN": GEN_DATE = di.GetDate(0); GEN_NAMN = di.GetString(1); break; case "#IB": parseIB(di); break; case "#KONTO": parseKONTO(di); break; case "#KSUMMA": if (CRC.Started) { parseKSUMMA(di); } else { CRC.Start(); } break; case "#KTYP": parseKTYP(di); break; case "#KPTYP": KPTYP = di.GetString(0); break; case "#OBJEKT": parseOBJEKT(di); break; case "#OIB": pv = parseOIB_OUB(di); Callbacks.CallbackOIB(pv); if (!StreamValues) { OIB.Add(pv); } break; case "#OUB": pv = parseOIB_OUB(di); Callbacks.CallbackOUB(pv); if (!StreamValues) { OUB.Add(pv); } break; case "#ORGNR": FNAMN.OrgIdentifier = di.GetString(0); break; case "#OMFATTN": OMFATTN = di.GetDate(0); break; case "#PBUDGET": pv = parsePBUDGET_PSALDO(di); if (pv != null) { Callbacks.CallbackPBUDGET(pv); if (!StreamValues) { PBUDGET.Add(pv); } } break; case "#PROGRAM": PROGRAM = di.Data; break; case "#PROSA": PROSA = di.GetString(0); break; case "#PSALDO": pv = parsePBUDGET_PSALDO(di); if (pv != null) { Callbacks.CallbackPSALDO(pv); if (!StreamValues) { PSALDO.Add(pv); } } break; case "#RAR": parseRAR(di); break; case "#RTRANS": if (!IgnoreBTRANS) { parseTRANS(di, curVoucher); } break; case "#SIETYP": SIETYP = di.GetInt(0); break; case "#SRU": parseSRU(di); break; case "#TAXAR": TAXAR = di.GetInt(0); break; case "#UB": parseUB(di); break; case "#TRANS": parseTRANS(di, curVoucher); break; case "#RES": parseRES(di); break; case "#VALUTA": VALUTA = di.GetString(0); break; case "#VER": curVoucher = parseVER(di); break; case "": //Empty line break; case "{": break; case "}": if (curVoucher != null) { closeVoucher(curVoucher); } curVoucher = null; break; default: Callbacks.CallbackException(new NotImplementedException(di.ItemType)); break; } } validateDocument(); }