Exemplo n.º 1
0
        public static QifConversionResult ConvertTextToQif(FormatType.FormatTypeEnum formatType, List<string> inputLines)
        {
            var conversionResult = new QifConversionResult {Header = GetQifHeader(formatType)};

            ConvertLinesToQif(formatType, inputLines, conversionResult);

            conversionResult.Success = conversionResult.FailedLines.Count < 1;
            return conversionResult;
        }
Exemplo n.º 2
0
        public string CreateOutput(ParseResult parsedData, FormatType.FormatTypeEnum formatType)
        {
            var strb = new StringBuilder();
            strb.AppendLine(GetQifHeader(formatType));

            foreach (var transaction in parsedData.Transactions)
            {
                var qifText = new QifTransaction(transaction).ToString();
                strb.AppendLine(qifText);
            }

            return strb.ToString();
        }
Exemplo n.º 3
0
 private string GetQifHeader(FormatType.FormatTypeEnum formatType)
 {
     switch (formatType)
     {
         case FormatType.FormatTypeEnum.Peugeot:
         case FormatType.FormatTypeEnum.SjPrio:
             return @"!Account
     NChecking Account
     TCCard
     !Type:CCard";
         case FormatType.FormatTypeEnum.Swedbank:
         case FormatType.FormatTypeEnum.Seb:
         case FormatType.FormatTypeEnum.Coop:
         case FormatType.FormatTypeEnum.ICA:
             return @"!Account
     NChecking Account
     TBank
     !Type:Bank";
         default:
             throw new ArgumentOutOfRangeException("formatType");
     }
 }
Exemplo n.º 4
0
 public FormatterV2(FormatType.FormatTypeEnum formatType, string yearToUse)
 {
     _yearToUse = yearToUse;
     _formatType = formatType;
 }
Exemplo n.º 5
0
        private static void ConvertLinesToQif(FormatType.FormatTypeEnum formatType, IEnumerable<string> inputLines, QifConversionResult conversionResult)
        {
            var regex = GetRegexForFormatType(formatType);

            foreach (var inputLine in inputLines)
            {
                if(string.IsNullOrWhiteSpace(inputLine))
                    continue;
                var match = regex.Match(inputLine);
                if (match.Success)
                {
                    string qifText = ConvertMatchToQif(formatType, match);
                    if (qifText == null) return;
                    conversionResult.OutputLines.Append(qifText);
                }
                else
                {
                    conversionResult.FailedLines.Add(inputLine);
                }
            }
        }
Exemplo n.º 6
0
 private static Regex GetRegexForFormatType(FormatType.FormatTypeEnum formatType)
 {
     switch (formatType)
     {
         case FormatType.FormatTypeEnum.SjPrio:
             return new Regex(@"(?<date1>\d\d-\d\d)\s+(?<date2>\d\d-\d\d)\s+(?<desc>[\w $#'-@&¦{]+)\s+(?<loc>[\w $@#'-{}]+)\s+(?<cur>[\w]*)\s+(?<utlbelopp>[\d, ]+)\s+(?<kronor>-?[\d ]+),(?<ore>[\d]{2})");
             //Uppdaterar eftersom det verkar ha lagts till valutafält + utl valuta värde.
         //return new Regex(@"(?<date1>\d\d-\d\d)\s+(?<date2>\d\d-\d\d)\s+(?<desc>[\w $#'-@&]+)\s+(?<loc>[\w $@#']+)\s+(?<kronor>-?[\d ]+),(?<ore>[\d]{2})");
         //return new Regex(@"(?<date1>(\d\d-\d\d))\s+(?<date2>(\d\d-\d\d))\s+(?<desc>(.+))\s{2}(?<loc>(.+))\s+(?<kronor>(-?[\d ]+)),(?<ore>([\d]{2}))");
         case FormatType.FormatTypeEnum.Swedbank:
             //7 Clnr 12 Kontonr 21 Kontonamn 8 valuta 17 Bokföringsdatum
             // 19 Transdatum 36 Referens 24? Kontohändelse 14 Belopp
             return new Regex(@"(?<clnr>[\d\s]{7})(?<kontonr>[\d\s]{12})(?<kontonamn>[\w\s-]{21})(?<valuta>[\w\s]{8})(?<date1>[\d\s-]{17})(?<date2>[\d\s-]{19})(?<desc>[/\w\s+\{\}@-]{36})(?<kontohand>[\w\s-\./]{24})(?<kronor>[- \d]+),(?<ore>\d\d)");
             //return new Regex(@"(?<clnr>[\d\s]{7})(?<kontonr>[\d\s]{12})(?<kontonamn>[\w\s]{21})(?<valuta>[\w\s]{8})(?<date1>[\d\s-]{17})(?<date2>[\d\s-]{19})(?<desc>[\w\s]{36})(?<kontohand>[\w\s]{24})(?<amount>.*)");
             //return new Regex(@"(?<date1>\d\d-\d\d-\d\d)\s(?<date2>\d\d-\d\d-\d\d)\s+(?<desc>[-:&/*\\' \w\d\(\)]+)\s+(?<kronor>-?[ \d]+),(?<ore>\d\d)\s");
         case FormatType.FormatTypeEnum.SwedbankOld:
             return new Regex(@"(?<date1>\d\d-\d\d-\d\d)\s(?<date2>\d\d-\d\d-\d\d)\s+(?<desc>[-:&/*\\' \w\d\(\)]+)\s+(?<kronor>-?[ \d]+),(?<ore>\d\d)\s");
         case FormatType.FormatTypeEnum.Seb:
             return new Regex(@"(?<date1>\d\d\d\d-\d\d-\d\d)\s(?<date2>\d\d\d\d-\d\d-\d\d)\s\d{10}[LS]?\s(?<desc>[-:&/*\\' \w\d\.>]+)\s(?<kronor>[-\d ]+),(?<ore>\d\d)\s");
         case FormatType.FormatTypeEnum.Coop:
             return new Regex(@"(?<date1>\d\d\d\d-\d\d-\d\d)\s+(?<action>\w+)\s+(?<purchaser>[\w ]+)\s+(?<placeOfPurchase>[ \w\d]+)\s+(?<kronor>[-\d ]+),(?<ore>\d\d)\s");
         case FormatType.FormatTypeEnum.ICA:
             return new Regex(@"(?<date1>\d\d\d\d-\d\d-\d\d)\s+(?<placeOfPurchase>[ \w\d,]+)\s(?<kronor>[-\d \t]+),(?<ore>\d\d)");
         default:
             throw new ArgumentOutOfRangeException("formatType");
     }
 }
Exemplo n.º 7
0
 private static string ConvertMatchToQif(FormatType.FormatTypeEnum formatType, Match match)
 {
     switch (formatType)
     {
         case FormatType.FormatTypeEnum.SjPrio:
             return ConvertSjPrioMatchToQif(match);
         case FormatType.FormatTypeEnum.Swedbank:
             return ConvertSwedbankMatchToQif(match);
         case FormatType.FormatTypeEnum.SwedbankOld:
             return ConvertSwedbankMatchToQifOld(match);
         case FormatType.FormatTypeEnum.Seb:
             return ConvertSebMatchToQif(match);
         case FormatType.FormatTypeEnum.Coop:
             return ConvertCoopMatchToQif(match);
         case FormatType.FormatTypeEnum.ICA:
             return ConvertICAMatchToQif(match);
         default:
             throw new ArgumentOutOfRangeException("formatType");
     }
 }