Beispiel #1
0
 /// <summary>
 /// Crea una Spesa valido
 /// </summary>
 public PagamentoRitenuta(int idAzienda, string descrizione, DateTime? data, bool isFittizio, TipoVersamentoF24Enum tipoVersamentoF24)
 {
     Descrizione = descrizione;
     Data = data;
     IsFittizio = isFittizio;
     TipoVersamentoF24 = tipoVersamentoF24;
     AziendaID = idAzienda;
 }
        public bool Salva(List<RitenutaAccontoDTO> ritenute, DateTime dataPagamento, string descrizione, string nomeFile, string descrizioneAddebitoInteressi, string descrizioneAddebitoSanzioni, bool mittenteCondominio, bool testataPerCondominio, TipoVersamentoF24Enum tipoVersamento)
        {
            try
            {
                var fileBody = GetServiceClient().SalvaRitenuteAcconto(ritenute, dataPagamento, descrizione, descrizioneAddebitoInteressi, descrizioneAddebitoSanzioni, mittenteCondominio, testataPerCondominio, tipoVersamento, GetUserInfo());
                CloseService();

                var result = false;
                if (fileBody != null)
                {
                    var doc = new DocumentInfo { Body = fileBody, FileName = nomeFile };
                    _manageDocumentService.Save(doc);
                    if (tipoVersamento == TipoVersamentoF24Enum.PDF)
                    {
                        try
                        {
                            _manageDocumentService.Open(doc, "Modello F24", false, MergeFieldType.Default);
                        }
                        catch (Exception ex)
                        {
                            _log.ErrorFormat("Errore nell'apertura del pdf - {0} - data:{1} - azienda:{2}", ex, Utility.GetMethodDescription(), dataPagamento, Login.Instance.CurrentLogin().Azienda);
                            throw;
                        }
                    }
                    result = true;
                }

                return result;
            }
            catch (CommunicationObjectAbortedException ex)
            {
                _log.DebugFormat("Errore nella chiamata al servizio - {0} - azienda:{1}", ex, Utility.GetMethodDescription(), Login.Instance.CurrentLogin().Azienda);
            }
            catch (CommunicationObjectFaultedException ex)
            {
                _log.DebugFormat("Errore nella chiamata al servizio - {0} - azienda:{1}", ex, Utility.GetMethodDescription(), Login.Instance.CurrentLogin().Azienda);
            }
            catch (CommunicationException ex)
            {
                _log.DebugFormat("Errore nella chiamata al servizio - {0} - azienda:{1}", ex, Utility.GetMethodDescription(), Login.Instance.CurrentLogin().Azienda);
            }
            catch (IOException ex)
            {
                _log.DebugFormat("Errore nella chiamata al servizio - {0} - azienda:{1}", ex, Utility.GetMethodDescription(), Login.Instance.CurrentLogin().Azienda);
            }
            catch (ObjectDisposedException ex)
            {
                _log.DebugFormat("Errore nella chiamata al servizio - {0} - azienda:{1}", ex, Utility.GetMethodDescription(), Login.Instance.CurrentLogin().Azienda);
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Errore nella chiamata al servizio - {0} - azienda:{1}", ex, Utility.GetMethodDescription(), Login.Instance.CurrentLogin().Azienda);
                throw;
            }

            return false;
        }
 public string IsAllowPagamentoRitenute(List<RitenutaAccontoDTO> ritenute, DateTime dataVersamento, TipoVersamentoF24Enum tipoVersamento)
 {
     if (ritenute.Count > 0)
     {
         var result = GetServiceClient().IsAllowPagamentoRitenuteAcconto(ritenute, dataVersamento, tipoVersamento, GetUserInfo());
         CloseService();
         return result;
     }
     return string.Empty;
 }
        public byte[] CreateRitenute(int idAzienda, IList<RitenutaAccontoDTO> lista, DateTime dataPagamento, string descrizione, string descrizioneAddebitoInteressi, string descrizioneAddebitoSanzioni, bool mittenteCondominio, bool testataPerCondominio, TipoVersamentoF24Enum tipoVersamento)
        {
            var fileRitenuta = new PagamentoRitenuta(idAzienda, descrizione, dataPagamento, false, tipoVersamento);
            _daoFactory.GetPagamentoRitenutaDao().SaveOrUpdate(fileRitenuta);
            decimal importoTotaleRitenuta = 0;
            decimal importoTotaleInteressi = 0;
            decimal importoTotaleSanzione = 0;
            foreach (var ritenuta in lista)
            {
                var pagamentoRiferimento = _daoFactory.GetPagamentoDao().Find(ritenuta.IdPagamento.GetValueOrDefault(), true);
                if(pagamentoRiferimento != null)
                {
                    pagamentoRiferimento.RitenutaAcconto.TestataRiferimento = fileRitenuta;
                    fileRitenuta.Pagamenti.Add(pagamentoRiferimento);
                    pagamentoRiferimento.RitenutaAcconto.Stato = StatoRitenutaEnum.Pagata;
                    pagamentoRiferimento.RitenutaAcconto.ImportoInteressi = ritenuta.ImportoInteressi;
                    pagamentoRiferimento.RitenutaAcconto.ImportoSanzione = ritenuta.ImportoSanzione;
                    importoTotaleRitenuta += ritenuta.ImportoRitenuta.GetValueOrDefault();
                    importoTotaleInteressi += ritenuta.ImportoInteressi.GetValueOrDefault();
                    importoTotaleSanzione += ritenuta.ImportoSanzione.GetValueOrDefault();
                }
            }

            fileRitenuta.ImportoRitenuta = importoTotaleRitenuta;
            fileRitenuta.ImportoInteressi = importoTotaleInteressi;
            fileRitenuta.ImportoSanzione = importoTotaleSanzione;

            var fileBody = _esecuzioneRitenuta.EsecuzionePagamenti(fileRitenuta, testataPerCondominio, mittenteCondominio, dataPagamento);
            if (fileBody != null)
            {
                // Se richiesto il modulo PDF salvo il modulo come documento
                if(tipoVersamento == TipoVersamentoF24Enum.PDF)
                {
                    var fileName = string.Format("Modulo F24 del {0}-{1}-{2}", dataPagamento.Day, dataPagamento.Month, dataPagamento.Year);
                    var documentMessage = _documentService.SaveDocument(fileBody, fileName, ".pdf", null, idAzienda);
                    if(documentMessage.Documento != null)
                    {
                        var checksum = documentMessage.Documento.Checksum;
                        var moduloPdf = new Documento(checksum, fileName, ".pdf", "ModuloF24", false, _daoFactory.GetAziendaDao().GetById(idAzienda, false)) { PagamentoRitenuta = fileRitenuta };
                        _daoFactory.GetDocumentoDao().SaveOrUpdate(moduloPdf);
                    }
                }

                _movimentiContabilitaService.SetMovimentiRitenuta(fileRitenuta, descrizioneAddebitoInteressi, descrizioneAddebitoSanzioni);
                return fileBody;
            }
            _persistenceContext.RollbackAndCloseSession(Security.Login.Instance.CurrentLogin().LoginName);
            _persistenceContext.BeginTransaction(Security.Login.Instance.CurrentLogin().LoginName, IsolationLevel.ReadUncommitted);

            return null;
        }
Beispiel #5
0
        public byte[] SalvaRitenuteAcconto(IList<RitenutaAccontoDTO> ritenute, DateTime dataPagamento, string descrizione, string descrizioneAddebitoInteressi, string descrizioneAddebitoSanzioni, bool mittenteCondominio, bool testataPerCondominio, TipoVersamentoF24Enum tipoVersamento, UserInfo userinfo)
		{
            var retryCount = 5;
            var success = false;
            var windsorRep = new WindsorConfigRepository();
            byte[] item = null;
            while (retryCount >= 0 && !success)
            {
                try
                {
                    windsorRep.BeginTransaction(userinfo);
                    var ritenutaService = windsorRep.GetContainer(userinfo.Azienda).Resolve<IRitenutaAccontoService>(tipoVersamento == TipoVersamentoF24Enum.CBI ? "ritenutaAccontoService.CBI" : "ritenutaAccontoService.PDF");
                    item = ritenutaService.CreateRitenute(userinfo.Azienda, ritenute, dataPagamento, descrizione, descrizioneAddebitoInteressi, descrizioneAddebitoSanzioni, mittenteCondominio, testataPerCondominio, tipoVersamento);
                    windsorRep.Commit();
                    success = true;
                }
                catch (Exception ex)
                {
                    _log.ErrorFormat("Errore nella esecuzione della funzione - TENTATIVO:{0} - {1} - azienda:{2} - number:{3}", ex, (6 - retryCount), Utility.GetMethodDescription(), userinfo.Azienda, getExceptionId(ex));

                    windsorRep.Rollback();
                    if (!isRetryException(ex))
                        throw;

                    // Add delay here if you wish. 
                    System.Threading.Thread.Sleep(1000 * (6 - retryCount));
                    retryCount--;
                    _log.InfoFormat("Errore nella esecuzione della funzione - INIZIO TENTATIVO:{0} - {1} - azienda:{2}", (6 - retryCount), Utility.GetMethodDescription(), userinfo.Azienda);
                }
            }

            if (!success)
                windsorRep.Rollback();

            return item;
		}
Beispiel #6
0
        public string IsAllowPagamentoRitenuteAcconto(IList<RitenutaAccontoDTO> ritenute, DateTime dataVersamento, TipoVersamentoF24Enum tipoVersamento, UserInfo userinfo)
		{
			var windsorRep = new WindsorConfigRepository();
			try
			{
				windsorRep.BeginTransaction(userinfo);
                var ritenutaService = windsorRep.GetContainer(userinfo.Azienda).Resolve<IRitenutaAccontoService>(tipoVersamento == TipoVersamentoF24Enum.CBI ? "ritenutaAccontoService.CBI" : "ritenutaAccontoService.PDF");
			    var item = ritenutaService.IsAllowPagamentoRitenuta(ritenute, dataVersamento, userinfo.Azienda);
				windsorRep.Commit();
				return item;
			}
			catch (Exception ex)
			{
				_log.ErrorFormat("Errore nella esecuzione della funzione - {0} - azienda:{1}", ex, Utility.GetMethodDescription(), userinfo.Azienda);
				windsorRep.Rollback();
				throw;
			}
		}