示例#1
0
        private void parseTRANS(SieDataItem di, SieVoucher v)
        {
            if (!KONTO.ContainsKey(di.GetString(0)))
            {
                KONTO.Add(di.GetString(0), new SieAccount()
                {
                    Number = di.GetString(0), Company = this.Company, Import = this.Import
                });
            }

            var objOffset = 0;

            if (di.RawData.Contains("{"))
            {
                objOffset = 1;
            }

            var vr = new SieVoucherRow()
            {
                Account   = KONTO[di.GetString(0)],
                Objects   = di.GetObjects(),
                Amount    = di.GetDecimal(1 + objOffset),
                RowDate   = di.GetDate(2 + objOffset).HasValue ? di.GetDate(2 + objOffset).Value : v.VoucherDate,
                Text      = di.GetString(3 + objOffset),
                Quantity  = di.GetIntNull(4 + objOffset),
                CreatedBy = di.GetString(5 + objOffset),
                Token     = di.ItemType,
                Company   = this.Company,
                Import    = this.Import
            };

            v.Rows.Add(vr);
        }
示例#2
0
 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);
 }
示例#3
0
        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);
        }
示例#4
0
        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();
        }