Example #1
0
        private Uniconta.DataModel.GLDailyJournalLine CreateGLDailyJournalLine(string account, double feeAmount, long invoice, Uniconta.DataModel.GLDailyJournal dailyJournal, long lineNumber, DateTime date, string transType, string offsetAccount, Currencies?currency, int nextVoucherNumber, string payment)
        {
            var glDailJournallineclient = new Uniconta.DataModel.GLDailyJournalLine();

            glDailJournallineclient.SetMaster(dailyJournal);
            if (this.AddInterest)
            {
                glDailJournallineclient._DCPostType = DCPostType.InterestFee;
            }
            else
            {
                glDailJournallineclient._DCPostType = DCPostType.CollectionLetter;
                glDailJournallineclient._Payment    = payment;
            }
            glDailJournallineclient._LineNumber    = ++lineNumber;
            glDailJournallineclient._Date          = date;
            glDailJournallineclient._Invoice       = invoice;
            glDailJournallineclient._TransType     = transType;
            glDailJournallineclient._AccountType   = (byte)GLJournalAccountType.Debtor;
            glDailJournallineclient._Account       = account;
            glDailJournallineclient._OffsetAccount = offsetAccount;
            glDailJournallineclient._Voucher       = nextVoucherNumber;

            if (currency.HasValue)
            {
                glDailJournallineclient._DebitCur = feeAmount;
                glDailJournallineclient._Currency = (byte)currency;
            }
            else
            {
                glDailJournallineclient._Debit = feeAmount;
            }

            return(glDailJournallineclient);
        }
Example #2
0
        Uniconta.DataModel.GLDailyJournalLine CreateGLDailyJournalLine(List <Uniconta.DataModel.GLDailyJournalLine> lst, string account, double feeAmount, double charge, string invoice, Uniconta.DataModel.GLDailyJournal dailyJournal, int lineNumber, DateTime date, string transType, string offsetAccount, Currencies?currency, int nextVoucherNumber, string payment)
        {
            var line = new Uniconta.DataModel.GLDailyJournalLine();

            line.SetMaster(dailyJournal);
            if (this.AddInterest)
            {
                line._DCPostType = DCPostType.InterestFee;
            }
            else
            {
                line._DCPostType = DCPostType.CollectionLetter;
                line._Payment    = payment;
            }
            line._LineNumber    = lineNumber + lst.Count;
            line._Date          = date;
            line._DueDate       = date;
            line._Invoice       = invoice;
            line._TransType     = transType;
            line._AccountType   = (byte)GLJournalAccountType.Debtor;
            line._Account       = account;
            line._OffsetAccount = offsetAccount;
            line._Voucher       = nextVoucherNumber;

            if (currency.HasValue)
            {
                line._DebitCur = feeAmount;
                line._Currency = (byte)currency;
            }
            else
            {
                line._Debit = feeAmount;
            }

            lst.Add(line);
            if (charge != 0)
            {
                var chargelin = CreateGLDailyJournalLine(lst, account, charge, 0, invoice, dailyJournal, lineNumber, date, transType, offsetAccount, currency, nextVoucherNumber, payment);
                chargelin._DCPostType = DCPostType.PaymentCharge;
            }
            return(line);
        }
Example #3
0
        public static void GenerateJournalLines(CrudAPI api, Uniconta.DataModel.GLDailyJournal jour, string filename)
        {
            try
            {
                DateTime date = DateTime.Today.Date;

                double amount = 0;

                string creditAccountRef = "";
                string kid = "";

                List <Uniconta.DataModel.GLDailyJournalLine> JournalLines = new List <Uniconta.DataModel.GLDailyJournalLine>();

                using (StreamReader sr = new StreamReader(filename, System.Text.Encoding.Default, false)) //Ver 02
                {
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        if (line.Length != 80)
                        {
                            UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("InvalidFileFormat"), Uniconta.ClientTools.Localization.lookup("Error"));
                            break;
                        }

                        var formatCode  = line.Substring(0, 2);
                        var serviceCode = line.Substring(2, 2);
                        var transType   = line.Substring(4, 2);
                        var recordType  = line.Substring(6, 2);
                        if (formatCode == "NY")
                        {
                            if (serviceCode == "04")
                            {
                                if (recordType == "30")
                                {
                                    date = DateTime.ParseExact(line.Substring(15, 6), "ddMMyy", CultureInfo.InvariantCulture);
                                    var amountTxt = line.Substring(32, 17);
                                    amount           = Convert.ToDouble(amountTxt) / 100d;
                                    creditAccountRef = line.Substring(21, 10);
                                    kid = line.Substring(49, 25);
                                }

                                if (recordType == "31")
                                {
                                    var rec = new Uniconta.DataModel.GLDailyJournalLine();
                                    rec._DCPostType = DCPostType.Payment;
                                    rec._TransType  = jour._TransType;
                                    rec._Dim1       = jour._Dim1;
                                    rec._Dim2       = jour._Dim2;
                                    rec._Dim3       = jour._Dim3;
                                    rec._Dim4       = jour._Dim4;
                                    rec._Dim5       = jour._Dim5;
                                    if (amount >= 0)
                                    {
                                        rec._Debit = amount;
                                    }
                                    else
                                    {
                                        rec._Credit = -amount;
                                    }

                                    rec._Date        = date;
                                    rec._Account     = creditAccountRef;
                                    rec._AccountType = (byte)GLJournalAccountType.Creditor;

                                    rec._OffsetAccount     = jour._OffsetAccount;
                                    rec._OffsetAccountType = (byte)jour._DefaultOffsetAccountType;

                                    string voucherstring = line.Substring(25, 25).Trim();
                                    rec._Settlements = voucherstring;
                                    rec._SettleValue = SettleValueType.Voucher;

                                    rec._Text      = line.Substring(15, 10).Trim();
                                    rec._PaymentId = kid.Trim();

                                    rec.SetMaster(jour);
                                    JournalLines.Add(rec);
                                }
                            }
                        }
                        else
                        {
                            UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("InvalidFileFormat"), Uniconta.ClientTools.Localization.lookup("Information"));
                        }
                    }
                }

                if (JournalLines.Count > 0)
                {
                    api.InsertNoResponse(JournalLines);
                }
            }
            catch (Exception ex)
            {
                api.ReportException(ex, string.Format("NETSForge GenerateJournalLines, CompanyId={0}", api.CompanyId));
            }
        }