Esempio n. 1
0
        private string GetTransferPayee(TransactionItem trans, DestinationAccountTypes accountType)
        {
            QifFilterSettings settings = QifFilterSettings.GetCurrent();
            string            result   = string.Empty;


            Match  match       = Regex.Match(trans.Category, @"\[(\w*)]");
            string accountName = match.Groups[1].ToString();


            foreach (TransfersInfo item in settings.TranfersRules.ListTransferInfo)
            {
                if (item.AccountName == accountName && item.DestAccountType == accountType)
                {
                    if (trans.Amount.Contains("-"))
                    {
                        result = item.WithdrawalPayee;
                    }
                    else
                    {
                        result = item.DepositPayee;
                    }
                    tag = item.Tag;
                }
            }

            return(result);
        }
Esempio n. 2
0
        private DestinationAccountTypes ObtenerTipoCuenta(string valorTexto)
        {
            DestinationAccountTypes result = DestinationAccountTypes.Cash;

            if (valorTexto == "!Type:Cash")
            {
                result = DestinationAccountTypes.Cash;
            }
            else if (valorTexto == "!Type:Bank")
            {
                result = DestinationAccountTypes.Bank;
            }
            else if (valorTexto == "!Type:CCard")
            {
                result = DestinationAccountTypes.Credit;
            }

            return(result);
        }
Esempio n. 3
0
        private void btnProcesar_Click(object sender, EventArgs e)
        {
            //string strFilename;
            string   strFecha;
            DateTime dFecha;
            string   strLinea;
            int      cntLinea;
            bool     bolGraba;
            DestinationAccountTypes accountType = DestinationAccountTypes.Cash;

            string sFmtFecIN;
            string sFmtFecOut;


            ValidarSelecciones();

            ValidarFormatosDecimales();

            ValidarRutaArchivos();

            transList = new List <TransactionItem>();
            TransactionItem trans = null;

            cntLinea = 0;
            bolGraba = true;

            using (StreamReader sr = File.OpenText(strFilename))
            {
                while ((strLinea = sr.ReadLine()) != null)
                {
                    cntLinea++;

                    if (strHeader == String.Empty && cntLinea == 1)
                    {
                        strHeader = strLinea;
                    }
                    else if (strHeader != string.Empty && cntLinea == 1 && strLinea.Contains("!Type"))
                    {
                        strHeader = strLinea;
                    }


                    strLinea = strLinea.Replace("\t", "");

                    if (strLinea.Trim() != "^")
                    {
                        if (strLinea.Substring(0, 1) == "D")
                        {
                            trans = new TransactionItem();

                            bolGraba = false;
                            strFecha = strLinea.Substring(1);

                            sFmtFecIN = this.cboTipoFechaIn.SelectedItem.ToString().Replace("'", " ");

                            dFecha = ValidarFechas(strFecha, ref bolGraba, sFmtFecIN);

                            sFmtFecOut = this.cboTipoFechaOut.SelectedItem.ToString().Replace("'", " ");
                            strLinea   = string.Format("{0:" + sFmtFecOut + "}", dFecha);
                            strLinea   = strLinea.Replace(" ", "'");
                            trans.Date = strLinea;
                            strLinea   = string.Format("D{0}", strLinea);
                        }
                        else
                        {
                            if (sFmtDecOrig != "")
                            {
                                if (strLinea.Substring(0, 1) == "T")
                                {
                                    strLinea.Replace(sFmtDecOrig, sFmtDecDest);
                                }
                            }

                            if (strLinea.Trim() == "!Account")
                            {
                                bolGraba = false;
                            }

                            if (strLinea.Trim().Contains("!Type") && !strLinea.Trim().Contains("!Type:Cat"))
                            {
                                accountType = ObtenerTipoCuenta(strLinea.Trim());
                            }


                            if (strLinea != "" && !strLinea.Contains(@"!Type") && trans != null)
                            {
                                if (bolGraba == true)
                                {
                                    switch (strLinea.Substring(0, 1))
                                    {
                                    case "T":
                                        trans.Amount = strLinea.Substring(1);
                                        break;

                                    case "L":
                                        trans.Category = strLinea.Substring(1);
                                        break;

                                    case "P":
                                        trans.Payee = strLinea.Substring(1);
                                        break;

                                    case "M":
                                        trans.Memo = strLinea.Substring(1);
                                        break;

                                    default:
                                        trans.OtherField = strLinea;
                                        break;
                                    }

                                    if (trans.Category != null && trans.Category.Contains("["))
                                    {
                                        if (!chkAvoidTransfers.Checked)
                                        {
                                            trans.Payee = GetTransferPayee(trans, accountType);
                                            if (!string.IsNullOrEmpty(tag))
                                            {
                                                trans.Category += "/" + tag;
                                            }
                                        }
                                        else
                                        {
                                            bolGraba = false;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (cntLinea > 1 && this.cboFormatos.Text == "Mercantil-Quicken")
                        {
                            AdaptarFormatoMercantil(ref trans);
                        }

                        if (bolGraba == true)
                        {
                            transList.Add(trans);
                        }

                        cntLinea = 0;
                        tag      = string.Empty;
                        bolGraba = false;
                    }
                }
            }

            if (transList.Count != 0)
            {
                this.SalvarResultados();
            }

            this.SaveLog();

            MessageBox.Show("Proceso Finalizado!!!");
        }