예제 #1
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());
        }
        // 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());
        }
        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());
        }
        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);
        }