Beispiel #1
0
        private CBIPaymentInstructionInformation getPaymentInfo(Condominio condominio, IList<Pagamento> pagamenti)
        {
            var contoCorrente = pagamenti.First().ContoCorrenteBancario ?? condominio.DatiBancariPrincipale;
            if (contoCorrente == null)
            {
                _log.ErrorFormat("Errore nell'identificazione del conto corrente - {0} - condominio:{1} - azienda:{2}", Library.Utility.GetMethodDescription(), condominio.ID, condominio.Azienda.ID);
                throw new InvalidDataException("Conto corrente non trovato");
            }

            var paymentInfo = new CBIPaymentInstructionInformation
            {
                PaymentMethod = PaymentMethod3Code.TRF,
                BatchBooking = false,
                PaymentInfoId = getDisposizioneUniqueId(pagamenti.First()),
                PaymentTypeInfo = new CBIPaymentTypeInformation1
                {
                    ServiceLevel = new CBIServiceLevel1 {Code = CBIServiceLevel1Code.SEPA}
                },
                RequestedExecutionDate = DateTime.Today,
                Debitor = getDebitor(condominio),
                DebtorAccount = new CBICashAccount1
                {
                    Id = new CBIAccountIdentification1 {IBAN = contoCorrente.Iban}
                },
                DebtorAgent = new CBIBranchAndFinancialInstitutionIdentification2
                {
                    FinancialInstitutionId = new CBIFinancialInstitutionIdentification3
                    {
                        ClearingSystemMemberId = new CBIClearingSystemMemberIdentification1 {MemberId = contoCorrente.Abi}
                    }
                },

                ChargeBearer = CBIChargeBearerTypeCode.SLEV,
                CreditTransferTransactionInfo = new List<CBICreditTransferTransactionInformation>()
            };

            // Il BIC è obbligatorio solo per i bonifici esteri
            if (!pagamenti.Any(item => item.ScadenzaRiferimento.SpesaRiferimento.FornitoreRiferimento.PersonaRiferimento.Iban.StartsWith("IT")))
                paymentInfo.DebtorAgent.FinancialInstitutionId.BIC = BancheHelper.GetCodiceBic(contoCorrente.Abi, _aziendaService.GetKey(condominio.Azienda.ID));


            var index = 0;
            foreach (var pagamento in pagamenti)
            {
                index++;
                paymentInfo.CreditTransferTransactionInfo.Add(getCreditTransferTransactionInfo(pagamento, index));
            }

            return paymentInfo;
        }
 public CBIPaymentRequest000400()
 {
     PaymentInfo = new CBIPaymentInstructionInformation();
     GroupHeader = new CBIGroupHeader();
 }