Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LineItem" /> class
        /// </summary>
        /// <param name="lineItem">The line item as specified from the YNAB-exported CSV</param>
        /// <param name="culture">The culture to use when parsing the amounts</param>
        public LineItem(CSVLineItem lineItem, CultureInfo culture)
        {
            this.CultureInfo = culture;

            this.Account        = lineItem.Account;
            this.Payee          = lineItem.Payee;
            this.Category       = lineItem.Category;
            this.Inflow         = string.IsNullOrWhiteSpace(lineItem.Inflow) ? string.Empty : lineItem.Inflow.Trim();
            this.MasterCategory = lineItem.MasterCategory;
            this.Memo           = lineItem.Memo;
            this.Outflow        = string.IsNullOrWhiteSpace(lineItem.Outflow) ? string.Empty : lineItem.Outflow.Trim();
            this.Payee          = lineItem.Payee;
            this.SubCategory    = lineItem.SubCategory;

            // YNAB appends a . for currency symbols it abbreviates, e.g. 12,48ден.
            this.Inflow  = this.Inflow.TrimEnd().TrimEnd(new char[] { '.' });
            this.Outflow = this.Outflow.TrimEnd().TrimEnd(new char[] { '.' });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Transaction" /> class
        /// </summary>
        /// <param name="accountTypes">The mapping of account to its type (Asset/Liability)</param>
        /// <param name="useClear">Whether or not to include the clear fields (*/!) in output</param>
        /// <param name="culture">The culture to use when parsing the amounts</param>
        /// <param name="lineItem">A line items to include in the transaction</param>
        public Transaction(
            IDictionary <string, string> accountTypes,
            bool useClear,
            CultureInfo culture,
            CSVLineItem lineItem) : this(accountTypes, useClear, culture)
        {
            this.Flag           = lineItem.Flag;
            this.CheckNumber    = lineItem.CheckNumber;
            this.Date           = lineItem.Date;
            this.Cleared        = lineItem.Cleared;
            this.RunningBalance = lineItem.RunningBalance;
            LineItem transactionLineItem = new LineItem(lineItem, this.Culture);

            this.LineItems.Add(transactionLineItem);

            if (!transactionLineItem.HasOutflow && !transactionLineItem.HasInflow)
            {
                Console.WriteLine("Warning: record doesn't transfer any money.");
            }
            else if (transactionLineItem.HasOutflow && transactionLineItem.HasInflow)
            {
                Console.WriteLine("A single transaction has both inflow and outflow.");
            }
        }