コード例 #1
0
ファイル: AP.Remittance.cs プロジェクト: weiplanet/openpetra
        public static Boolean CreateRemittanceAdviceAndChequeFormData(TFormLetterFinanceInfo AFormLetterFinanceInfo,
                                                                      ref AccountsPayableTDSAApPaymentTable APaymentTable,
                                                                      Int32 ALedgerNumber,
                                                                      bool AIncludeChequeFormData,
                                                                      out List <TFormData> AFormDataList)
        {
            AFormDataList = new List <TFormData>();
            TProgressTracker.InitProgressTracker(DomainManager.GClientID.ToString(), Catalog.GetString("Creating Remittance Advice"));
            TProgressTracker.SetCurrentState(DomainManager.GClientID.ToString(), Catalog.GetString("Starting ..."), 10.0m);

            // Print in payment number order
            APaymentTable.DefaultView.Sort = string.Format("{0} ASC", AccountsPayableTDSAApPaymentTable.GetPaymentNumberDBName());

            for (int i = 0; i < APaymentTable.DefaultView.Count; i++)
            {
                AccountsPayableTDSAApPaymentRow row = (AccountsPayableTDSAApPaymentRow)APaymentTable.DefaultView[i].Row;
                int paymentNumber = row.PaymentNumber;

                decimal progress = i / APaymentTable.DefaultView.Count * 100.0m;
                TProgressTracker.SetCurrentState(DomainManager.GClientID.ToString(),
                                                 Catalog.GetString(string.Format("Printing payment {0} ...", paymentNumber)),
                                                 progress);

                CreateFormDataInternal(ALedgerNumber, paymentNumber, AFormLetterFinanceInfo, AFormDataList,
                                       AIncludeChequeFormData, row.ChequeNumber, row.ChequeAmountInWords);
            }

            TProgressTracker.FinishJob(DomainManager.GClientID.ToString());

            return(true);
        }
コード例 #2
0
        private void MakePayment(object sender, EventArgs e)
        {
            //FSelectedDocumentRow.Amount = Decimal.Parse(txtAmountToPay.Text);
            FSelectedDocumentRow.Amount     = txtAmountToPay.NumberValueDecimal.Value;
            FSelectedPaymentRow.BankAccount = cmbBankAccount.GetSelectedString();
            AccountsPayableTDSAApPaymentTable AApPayment = FMainDS.AApPayment;

            //
            // I want to check whether the user is paying more than the due amount on any of these payments...
            //
            foreach (AccountsPayableTDSAApPaymentRow PaymentRow in AApPayment.Rows)
            {
                FMainDS.AApDocumentPayment.DefaultView.RowFilter = String.Format("{0}={1}",
                                                                                 AApDocumentPaymentTable.GetPaymentNumberDBName(), PaymentRow.PaymentNumber);

                foreach (DataRowView rv in FMainDS.AApDocumentPayment.DefaultView)
                {
                    AccountsPayableTDSAApDocumentPaymentRow DocPaymentRow = (AccountsPayableTDSAApDocumentPaymentRow)rv.Row;
                    Boolean overPayment = (DocPaymentRow.DocType == "INVOICE") ?
                                          (DocPaymentRow.Amount > DocPaymentRow.InvoiceTotal) : (DocPaymentRow.Amount < DocPaymentRow.InvoiceTotal);

                    if (overPayment)
                    {
                        String strMessage =
                            String.Format(Catalog.GetString(
                                              "Payment of {0} {1} to {2}: Payment cannot be more than the due amount."),
                                          StringHelper.FormatUsingCurrencyCode(DocPaymentRow.Amount, PaymentRow.CurrencyCode),
                                          PaymentRow.CurrencyCode, PaymentRow.SupplierName);

                        System.Windows.Forms.MessageBox.Show(strMessage, Catalog.GetString("OverPayment"));
                        return;
                    }
                }
            }

            TDlgGLEnterDateEffective dateEffectiveDialog = new TDlgGLEnterDateEffective(
                FMainDS.AApDocument[0].LedgerNumber,
                Catalog.GetString("Select payment date"),
                Catalog.GetString("The date effective for the payment") + ":");

            if (dateEffectiveDialog.ShowDialog() != DialogResult.OK)
            {
                MessageBox.Show(Catalog.GetString("The payment was cancelled."), Catalog.GetString(
                                    "No Success"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            DateTime PaymentDate = dateEffectiveDialog.SelectedDate;
            TVerificationResultCollection Verifications;

            this.Cursor = Cursors.WaitCursor;

            if (!TRemote.MFinance.AP.WebConnectors.PostAPPayments(
                    ref FMainDS,
                    PaymentDate,
                    out Verifications))
            {
                this.Cursor = Cursors.Default;
                string ErrorMessages = String.Empty;

                foreach (TVerificationResult verif in Verifications)
                {
                    ErrorMessages += "[" + verif.ResultContext + "] " +
                                     verif.ResultTextCaption + ": " +
                                     verif.ResultText + Environment.NewLine;
                }

                System.Windows.Forms.MessageBox.Show(ErrorMessages, Catalog.GetString("Payment failed"));
            }
            else
            {
                this.Cursor = Cursors.Default;
                PrintPaymentReport(sender, e);
                PrintRemittanceAdvice();

                // TODO: show posting register of GL Batch?

                // After the payments screen, The status of this document may have changed.
                TFormsMessage broadcastMessage = new TFormsMessage(TFormsMessageClassEnum.mcAPTransactionChanged);
                broadcastMessage.SetMessageDataAPTransaction(String.Empty);
                TFormsList.GFormsList.BroadcastFormMessage(broadcastMessage);

                Close();
            }
        }