// For now we are only dealing with Debit records where the Transaction Type is 480 (Donation)
        private async Task <string> GenerateCreditAndDebitRecords()
        {
            logger.LogInformation("Entering GenerateCreditAndDebitRecords");

            StringBuilder          creditAndDebitRecords = new StringBuilder();
            List <PaymentSchedule> paymentSchedules      = GetPaymentSchedulesFromBankRun(BankRun);

            foreach (PaymentSchedule curPaymentSchedule in paymentSchedules)
            {
                PaymentMethod curPaymentMethod = GetPaymentMethodFromPaymentSchedule(curPaymentSchedule);
                string        recordType       = "D";
                string        transactionType  = "480";         // Donation - for now, we are only dealing with this Transaction Type
                string        amount           = FormatCurrencyValue(curPaymentSchedule.RecurringAmount, 10);
                string        dueDate          = FormatDateValueToJulianFormat(BankRun.DateToBeProcessed);
                string        filler           = " ";
                string        institutionCode  = GetSpecificLengthString(curPaymentMethod.BankActRtNumber, 3);
                string        transitNumber    = GetSpecificLengthString(curPaymentMethod.BankActRtNumber, 5, 3);
                string        accountNumber    = GetSpecificLengthString(curPaymentMethod.BankActNumber, 12);
                string        recipientsName   = GetSpecificLengthString(curPaymentSchedule.LastName + ", " + curPaymentSchedule.FirstName, 30);
                string        originatorsCrossReferenceNumber = GetSpecificLengthString(curPaymentSchedule.Name, 19);
                string        customerSundryInformation       = GetSpecificLengthString(originatorsCrossReferenceNumber, 15);

                string currentRecord = recordType + transactionType + amount + dueDate + filler + institutionCode +
                                       transitNumber + accountNumber + recipientsName +
                                       originatorsCrossReferenceNumber + customerSundryInformation;
                Debits.Add(curPaymentSchedule);
                creditAndDebitRecords.AppendLine(currentRecord);
            }

            logger.LogInformation("Exiting GenerateCreditAndDebitRecords");
            return(creditAndDebitRecords.ToString());
        }
Пример #2
0
        private async Task <string> GenerateDebitRecords()
        {
            logger.LogInformation("Entering GenerateDebitRecords");

            StringBuilder          debitRecords     = new StringBuilder();
            List <PaymentSchedule> paymentSchedules = GetPaymentSchedulesFromBankRun(BankRun);

            foreach (PaymentSchedule curPaymentSchedule in paymentSchedules)
            {
                PaymentMethod curPaymentMethod = GetPaymentMethodFromPaymentSchedule(curPaymentSchedule);

                string logicalRecordTypeId = "D";
                string amount             = FormatCurrencyValue(curPaymentSchedule.RecurringAmount, 10);
                string payorInstitutionId = "0" + GetSpecificLengthString(curPaymentMethod.BankActRtNumber, 3) +
                                            GetSpecificLengthString(curPaymentMethod.BankActRtNumber, 5, 3);
                string payorAccountNumber   = GetSpecificLengthString(curPaymentMethod.BankActNumber, 12);
                string payorName            = GetSpecificLengthString(curPaymentSchedule.FirstName + " " + curPaymentSchedule.LastName, 29);
                string crossReferenceNumber = GetSpecificLengthString(curPaymentSchedule.Name, 15);
                string filler = new string(' ', 4);

                string currentRecord = logicalRecordTypeId + amount + payorInstitutionId + payorAccountNumber +
                                       payorName + crossReferenceNumber + filler;
                Debits.Add(curPaymentSchedule);
                debitRecords.AppendLine(currentRecord);
            }

            logger.LogInformation("Exiting GenerateDebitRecords");
            return(debitRecords.ToString());
        }
 private void ClearForm()
 {
     Amount      = 0;
     Description = "";
     ScannedDocumentList.Clear();
     Credits.Clear();
     Debits.Clear();
 }
Пример #4
0
 /// <summary>
 /// Debits the specified amount.
 /// </summary>
 /// <param name="amount">The amount.</param>
 /// <param name="description">The description.</param>
 /// <param name="source_uri">The source_uri.</param>
 /// <param name="appears_on_statement_as">The appears_on_statement_as.</param>
 /// <param name="meta">The meta.</param>
 /// <returns>Debit.</returns>
 public Debit Debit(int amount,
                    string description,
                    string source_uri,
                    string appears_on_statement_as,
                    IDictionary <string, string> meta)
 {
     return(Debits.Create(amount, description, source_uri, appears_on_statement_as, null, meta));
 }
 private void ClearDebits()
 {
     Debits.Clear();
     IsEnabledDebitorDropDown = true;
     RaisePropertyChanged("DebitsDisplay");
     if (IsEnabledCreditorDropDown && IsEnabledDebitorDropDown)
     {
         IsEnabledTaxDropDown = true;
     }
 }
 private void AddDebitSplitsToList(DebitSplitList debitSplitList)
 {
     CostAccountDebitor.CostAccountId = 0;
     CostAccountDebitorId             = 0;
     Debits.AddRange(debitSplitList.Debits);
     RaisePropertyChanged("DebitsDisplay");
     IsEnabledDebitorDropDown = false;
     IsEnabledTaxDropDown     = false;
     SelectedTax = FilteredTaxTypes.First();
 }
        private async Task <string> GenerateCreditAndDebitRecords()
        {
            logger.LogInformation("Entering GenerateCreditAndDebitRecords");

            StringBuilder          creditAndDebitRecords = new StringBuilder();
            List <PaymentSchedule> paymentSchedules      = GetPaymentSchedulesFromBankRun(BankRun);

            foreach (PaymentSchedule curPaymentSchedule in paymentSchedules)
            {
                PaymentMethod curPaymentMethod       = GetPaymentMethodFromPaymentSchedule(curPaymentSchedule);
                string        recordType             = "1";
                string        bsbNumber              = formatBSBNumber(curPaymentMethod.BankActRtNumber);
                string        accountNumber          = formatBankAccountNumber(curPaymentMethod.BankActNumber, curPaymentMethod.BankName);
                string        indicator              = " ";
                string        transactionCode        = "13";   // 13 = debit - only dealing with Debits for now
                string        amount                 = FormatCurrencyValue(curPaymentSchedule.RecurringAmount, 10);
                string        titleOfAccount         = GetSpecificLengthString(curPaymentMethod.NameAsItAppearsOnTheAccount, 32, 0, ' ', true);
                string        lodgementReference     = GetSpecificLengthString(curPaymentSchedule.Name, 18, 0, ' ', true);
                string        traceBSBNumber         = formatBSBNumber(PaymentMethod.BankActRtNumber);
                string        traceAccountNumber     = formatBankAccountNumber(PaymentMethod.BankActNumber, PaymentMethod.BankName);
                string        nameOfRemitter         = GetSpecificLengthString(PaymentProcessor.AbaRemitterName, 16);
                string        amountOfWithholdingTax = FormatCurrencyValue(0, 8);

                string currentRecord = recordType + bsbNumber + accountNumber + indicator + transactionCode + amount +
                                       titleOfAccount + lodgementReference + traceBSBNumber + traceAccountNumber +
                                       nameOfRemitter + amountOfWithholdingTax;

                Debits.Add(curPaymentSchedule);
                creditAndDebitRecords.AppendLine(currentRecord);
            }

            // NAB Connect requires self-balanced files. That is the last transaction within the file must be
            // a settling transaction to your NAB Account for the total file value.
            string sbRecordType             = "1";
            string sbBsbNumber              = formatBSBNumber(PaymentMethod.BankActRtNumber);
            string sbAccountNumber          = formatBankAccountNumber(PaymentMethod.BankActNumber, PaymentMethod.BankName);
            string sbIndicator              = " ";
            string sbTransactionCode        = "50";      // 50 = credit- this is "balancing out" all the debits from above
            string sbAmount                 = getTotalValueOfDebits(10);
            string sbTitleOfAccount         = GetSpecificLengthString(PaymentMethod.NameAsItAppearsOnTheAccount, 32, 0, ' ', true);
            string sbLodgementReference     = GetSpecificLengthString(PaymentProcessor.AbaUserNumber, 18, 0, ' ', true);
            string sbTraceBSBNumber         = formatBSBNumber(PaymentMethod.BankActRtNumber);
            string sbTraceAccountNumber     = formatBankAccountNumber(PaymentMethod.BankActNumber, PaymentMethod.BankName);
            string sbNameOfRemitter         = GetSpecificLengthString(PaymentProcessor.AbaRemitterName, 16);
            string sbAmountOfWithholdingTax = FormatCurrencyValue(0, 8);

            string sbRecord = sbRecordType + sbBsbNumber + sbAccountNumber + sbIndicator + sbTransactionCode + sbAmount +
                              sbTitleOfAccount + sbLodgementReference + sbTraceBSBNumber + sbTraceAccountNumber +
                              sbNameOfRemitter + sbAmountOfWithholdingTax;


            creditAndDebitRecords.AppendLine(sbRecord);
            logger.LogInformation("Exiting GenerateCreditAndDebitRecords");
            return(creditAndDebitRecords.ToString());
        }
        public UserControlBillsToPay()
        {
            InitializeComponent();

            // Instanciando objetos
            dao         = new Debits();
            logs        = new Logs();
            aux         = null;
            _employe    = new Employe();
            _employe.id = MainWindow.currentId;
            actionIndex = -1;
            BlockFields();
            RefreshGrid();
        }
        /// <summary>
        /// Saves all bookings on the BookingList to the database
        /// </summary>
        public void SaveBookingsToDB()
        {
            foreach (var booking in BookingList)
            {
                int bookingId = Bookings.Insert(booking);

                foreach (var item in booking.Credits.OrderBy(x => x.CreditId))
                {
                    item.RefBookingId = bookingId;
                    var fakeId = item.CreditId;
                    item.CreditId = Credits.Insert(item);
                    foreach (var credit in booking.Credits)
                    {
                        if (credit.RefCreditId == fakeId)
                        {
                            credit.RefCreditId = item.CreditId;
                        }
                    }
                }

                foreach (var item in booking.Debits.OrderBy(x => x.DebitId))
                {
                    item.RefBookingId = bookingId;
                    var fakeId = item.DebitId;
                    item.DebitId = Debits.Insert(item);
                    foreach (var debit in booking.Debits)
                    {
                        if (debit.RefDebitId == fakeId)
                        {
                            debit.RefDebitId = item.DebitId;
                        }
                    }
                }

                foreach (ScannedDocument item in booking.ScannedDocuments)
                {
                    item.RefBookingId = bookingId;
                }
                ScannedDocuments.Insert(booking.ScannedDocuments);

                foreach (BookingCostCenterMapping item in booking.BookingCostCenterMappingList)
                {
                    item.RefBookingId = bookingId;
                }
                BookingCostCenterMappings.Insert(booking.BookingCostCenterMappingList);
            }

            BookingList.Clear();
            SelectedBooking = null;
        }
        private void CancelingSelectedBooking()
        {
            SelectedBooking.IsCanceled = true;
            Bookings.UpdateCancelingStatus(SelectedBooking);

            Booking cancelBooking = new Booking(DateTime.Now, "Stornierung von Buchung " + SelectedBooking.BookingId + " - " + SelectedBooking.Description)
            {
                RefFixedCostAllocationId = SelectedBooking.RefFixedCostAllocationId,
                FixedCostAllocation      = SelectedBooking.FixedCostAllocation,
            };

            cancelBooking.BookingId = Bookings.Insert(cancelBooking);

            foreach (Credit item in SelectedBooking.Credits)
            {
                cancelBooking.Credits.Add(new Credit(item.Amount * (-1), item.RefCostAccountId, cancelBooking.BookingId));
            }

            foreach (Debit item in SelectedBooking.Debits)
            {
                cancelBooking.Debits.Add(new Debit(item.Amount * (-1), item.RefCostAccountId, cancelBooking.BookingId));
            }

            foreach (BookingCostCenterMapping item in SelectedBooking.BookingCostCenterMappingList)
            {
                cancelBooking.BookingCostCenterMappingList.Add(new BookingCostCenterMapping(cancelBooking.BookingId, item.RefCostCenterId, item.Amount * (-1))
                {
                    CostCenter = item.CostCenter
                });
            }

            Credits.Insert(cancelBooking.Credits);
            Debits.Insert(cancelBooking.Debits);
            BookingCostCenterMappings.Insert(cancelBooking.BookingCostCenterMappingList);

            SearchForData();
        }
Пример #11
0
 public DebitSplitViewModel()
 {
     GetDataFromDB();
     AddCommand    = new DelegateCommand(() => AddToCollection(), () => (Amount > 0 && CostAccount != null));
     DeleteCommand = new DelegateCommand(DeleteSelectedItem, () => SelectedDebit != null && Debits.Contains(SelectedDebit));
     SaveCommand   = new DelegateCommand(SendSelectedToParent, () => Debits.Count > 0);
 }
        private string getTotalValueOfDebits(int desiredLength)
        {
            decimal totalDebits = Debits.Sum(d => d.RecurringAmount.Value);

            return(FormatCurrencyValue(totalDebits, desiredLength));
        }
Пример #13
0
        private void SetCommands()
        {
            GetCreditorCommand = new DelegateCommand(() =>
            {
                Messenger.Default.Send(new OpenKontenrahmenWindowMessage {
                    AccountingType = AccountingType.Credit
                });
            });

            GetDebitorCommand = new DelegateCommand(() =>
            {
                Messenger.Default.Send(new OpenKontenrahmenWindowMessage {
                    AccountingType = AccountingType.Debit
                });
            });
            OpenDebitSplitWindowCommand = new DelegateCommand(() =>
            {
                Messenger.Default.Send(new OpenDebitSplitWindowMessage(SelectedBookingType, Amount));
            }, () => Amount != 0);
            OpenCreditSplitWindowCommand = new DelegateCommand(() =>
            {
                Messenger.Default.Send(new OpenCreditSplitWindowMessage(SelectedBookingType, Amount));
            }, () => Amount != 0);

            OpenFileCommand = new DelegateCommand(() =>
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Filter         = "pdf Dateien (*.pdf)|*.pdf";
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    CreateScannedDocumentItem(openFileDialog.FileName);
                }
            });

            DoubleClickListBoxCommand = new DelegateCommand(() =>
            {
                if (SelectedScannedDocument != null)
                {
                    Messenger.Default.Send(new OpenPDFViewerWindowMessage(SelectedScannedDocument.Path));
                }
            });

            AddToStackCommand = new DelegateCommand(() =>
            {
                AccountBookingManager.Instance.NewBookingItem(Date, Description);
                if (Credits.Count == 0 && Debits.Count == 0)
                {
                    CostAccountDebitor.TaxType      = SelectedTax;
                    CostAccountDebitor.RefTaxTypeId = SelectedTax.TaxTypeId;
                    AccountBookingManager.Instance.CreateAndAddCreditDebit(GrossNetType, SelectedBookingType, Amount, CostAccountCreditor, CostAccountDebitor, SelectedTax);
                }
                else if (Credits.Count > 0 && Debits.Count == 0)
                {
                    Debits.Add(new Debit(Amount, CostAccountDebitor.CostAccountId, 0));

                    AccountBookingManager.Instance.AddCreditsAndDebits(Credits.ToList(), Debits.ToList());
                }
                else if (Credits.Count == 0 && Debits.Count > 0)
                {
                    Credits.Add(new Credit(Amount, CostAccountCreditor.CostAccountId, 0));
                    AccountBookingManager.Instance.AddCreditsAndDebits(Credits.ToList(), Debits.ToList());
                }
                else
                {
                    AccountBookingManager.Instance.AddCreditsAndDebits(Credits.ToList(), Debits.ToList());
                }

                AccountBookingManager.Instance.AddScannedDocuments(ScannedDocumentList);

                if (IsFixedCostAllocationActive)
                {
                    AccountBookingManager.Instance.AddFixedCostAllocation(SelectedFixedCostAllocation, SelectedProjectId);
                }
                else
                {
                    AccountBookingManager.Instance.AddCostCenter(SelectedCostCenter, SelectedProjectId);
                }

                BookingsOnStack = AccountBookingManager.Instance.BookingList.ToSvenTechCollection();

                ClearForm();
            }, () => ValidateBooking());

            SaveStackToDbCommand = new DelegateCommand(SaveStackToDb, () => BookingsOnStack.Count > 0);

            DeleteCommand = new DelegateCommand(DeleteBooking, () => SelectedBooking != null);

            DeleteSelectedScannedDocumentCommand =
                new DelegateCommand(DeleteSelectedScannedDocument, () => ScannedDocumentList.Count > 0);

            CancelCommand       = new DelegateCommand(ClearForm);
            ClearCreditsCommand = new DelegateCommand(ClearCredits, () => Credits.Count > 0);
            ClearDebitsCommand  = new DelegateCommand(ClearDebits, () => Debits.Count > 0);
        }
        private string getTotalValueOfDebits()
        {
            decimal totalDebits = Debits.Sum(d => d.RecurringAmount.Value);

            return(FormatCurrencyValue(totalDebits, 14));
        }