public async Task <List <DettaglioPagamentoDTO> > AddAsync(DettaglioPagamentoModel dp) { if (dp.DatiPagamentoModelId < 1) { return(new List <DettaglioPagamentoDTO>()); } await DbContext.DettaglioPagamento .AddAsync(dp) .ConfigureAwait(false); await DbContext .SaveChangesAsync() .ConfigureAwait(false); var dettagliPagamenti = await DbContext.DatiPagamento .Where(dati => dati.Id == dp.DatiPagamentoModelId) .Select(dati => dati.DettaglioPagamento) .FirstOrDefaultAsync() .ConfigureAwait(false); var pagamentiList = new List <DettaglioPagamentoDTO>(); foreach (var dettaglio in dettagliPagamenti) { pagamentiList.Add(Mapper.Map <DettaglioPagamentoModel, DettaglioPagamentoDTO>(dettaglio)); } return(pagamentiList); }
public async Task <DateTime?> SetPaymentStatusAsync(int id) { if (await DbContext.DettaglioPagamento.AnyAsync(dp => dp.Id == id).ConfigureAwait(false)) { DettaglioPagamentoModel pagamento = await DbContext.DettaglioPagamento .Where(dp => dp.Id == id) .FirstOrDefaultAsync() .ConfigureAwait(false); if (pagamento.PaymentDate == null) { pagamento.PaymentDate = DateTime.Now; } else { pagamento.PaymentDate = null; } DbContext.Update(pagamento); int res = await DbContext.SaveChangesAsync().ConfigureAwait(false); if (res == 1) { return(pagamento.PaymentDate); } } return(DateTime.MinValue); }
public BodyModel(Semplificata.FatturaElettronicaBody.FatturaElettronicaBody body, Semplificata.FatturaElettronicaHeader.FatturaElettronicaHeader header) { if (body != null) { this.Simplified = true; this.TipoDocumento = body.DatiGenerali.DatiGeneraliDocumento.TipoDocumento; this.Divisa = body.DatiGenerali.DatiGeneraliDocumento.Divisa; this.Data = body.DatiGenerali.DatiGeneraliDocumento.Data; this.Numero = body.DatiGenerali.DatiGeneraliDocumento.Numero; this.BolloVirtuale = body.DatiGenerali.DatiGeneraliDocumento.BolloVirtuale; int beniServiziLength = body.DatiBeniServizi.Count; if (beniServiziLength > 0) { this.DatiBeniServizi = new List <DatiBeniServiziModel>(); } foreach (var linea in body.DatiBeniServizi) { this.DatiBeniServizi.Add(new DatiBeniServiziModel(linea)); } decimal importoTotaleDocumento = 0; foreach (var beni in body.DatiBeniServizi) { importoTotaleDocumento += beni.Importo; importoTotaleDocumento += beni.DatiIVA.Imposta ?? 0; } var defaultDettaglio = new DettaglioPagamentoModel ( "MP05", importoTotaleDocumento, body.DatiGenerali.DatiGeneraliDocumento.Data ); var defaultPagamento = new DatiPagamentoModel ( "TP02", defaultDettaglio ); this.DatiPagamento = new List <DatiPagamentoModel>(); this.DatiPagamento.Add(defaultPagamento); this.DatiPagamento[0].Active = true; this.CedentePrestatore = new CliForModel(header.CedentePrestatore); this.CessionarioCommittente = new CliForModel(header.CessionarioCommittente); } }
private string GetIBAN(DettaglioPagamentoModel dpm) { if (dpm.ContoBancarioId == null) { return(null); } return(dpm.DatiPagamento.BodyModel.CedentePrestatore.ContiBancari .Where(cb => cb.Id == dpm.ContoBancarioId) .Select(cb => cb.IBAN) .FirstOrDefault()); }
public async Task <IActionResult> AddDettaglioPagamento(DettaglioPagamentoModel dp) { var res = await InvService.AddAsync(dp).ConfigureAwait(false); if (res.Count > 0) { return(Ok(res)); } else { return(BadRequest()); } }
public async Task <IActionResult> UpdateDettaglioPagamento(DettaglioPagamentoModel dp) { if (dp.Id < 1) { return(BadRequest("Invalid ID property")); } DettaglioPagamentoDTO res = await InvService.UpdateDettaglioPagamentoAsync(dp).ConfigureAwait(false); if (res.Id == dp.Id) { return(Ok(res)); } else { return(BadRequest()); } }
public async Task <DettaglioPagamentoDTO> UpdateDettaglioPagamentoAsync(DettaglioPagamentoModel dp) { if (await DbContext.DettaglioPagamento.AnyAsync(pagamento => pagamento.Id == dp.Id).ConfigureAwait(false)) { DbContext.DettaglioPagamento.Update(dp); int changes = await DbContext .SaveChangesAsync() .ConfigureAwait(false); if (changes == 1) { DettaglioPagamentoModel updated = await DbContext.DettaglioPagamento .Where(pagamento => pagamento.Id == dp.Id) .FirstOrDefaultAsync() .ConfigureAwait(false); return(Mapper.Map <DettaglioPagamentoModel, DettaglioPagamentoDTO>(updated)); } } return(new DettaglioPagamentoDTO()); }
public DatiPagamentoModel(string defaultCondizioniPagamento, DettaglioPagamentoModel defaultDettaglio) { this.CondizioniPagamento = defaultCondizioniPagamento; this.DettaglioPagamento = new List <DettaglioPagamentoModel>(); this.DettaglioPagamento.Add(defaultDettaglio); }
public BodyModel(FatturaElettronicaBody body, FatturaElettronicaHeader header) { if (body != null) { this.Simplified = false; this.TipoDocumento = body.DatiGenerali.DatiGeneraliDocumento.TipoDocumento; this.Divisa = body.DatiGenerali.DatiGeneraliDocumento.Divisa; this.Data = body.DatiGenerali.DatiGeneraliDocumento.Data; this.Numero = body.DatiGenerali.DatiGeneraliDocumento.Numero; this.BolloVirtuale = body.DatiGenerali.DatiGeneraliDocumento.DatiBollo.BolloVirtuale; this.ImportoBollo = body.DatiGenerali.DatiGeneraliDocumento.DatiBollo.ImportoBollo; this.ImportoTotaleDocumento = body.DatiGenerali.DatiGeneraliDocumento.ImportoTotaleDocumento; this.Arrotondamento = body.DatiGenerali.DatiGeneraliDocumento.Arrotondamento; this.Art73 = body.DatiGenerali.DatiGeneraliDocumento.Art73; this.NumeroFatturaPrincipale = body.DatiGenerali.FatturaPrincipale.NumeroFatturaPrincipale; this.DataFatturaPrincipale = body.DatiGenerali.FatturaPrincipale.DataFatturaPrincipale; this.MezzoTrasporto = body.DatiGenerali.DatiTrasporto.MezzoTrasporto; this.CausaleTrasporto = body.DatiGenerali.DatiTrasporto.CausaleTrasporto; this.NumeroColli = body.DatiGenerali.DatiTrasporto.NumeroColli; this.Descrizione = body.DatiGenerali.DatiTrasporto.Descrizione; this.UnitaMisuraPeso = body.DatiGenerali.DatiTrasporto.UnitaMisuraPeso; this.PesoLordo = body.DatiGenerali.DatiTrasporto.PesoLordo; this.PesoNetto = body.DatiGenerali.DatiTrasporto.PesoNetto; this.DataOraRitiro = body.DatiGenerali.DatiTrasporto.DataOraRitiro; this.DataInizioTrasporto = body.DatiGenerali.DatiTrasporto.DataInizioTrasporto; this.TipoResa = body.DatiGenerali.DatiTrasporto.TipoResa; this.DataOraConsegna = body.DatiGenerali.DatiTrasporto.DataOraConsegna; if (body.DatiGenerali.DatiTrasporto != null && body.DatiGenerali.DatiTrasporto.IndirizzoResa != null && body.DatiGenerali.DatiTrasporto.IndirizzoResa.CAP != null) { this.LuogoResa = new SediModel(body.DatiGenerali.DatiTrasporto.IndirizzoResa); } int causaleLength = body.DatiGenerali.DatiGeneraliDocumento.Causale.Count; if (causaleLength > 0) { this.Causale = new List <CausaleModel>(); } foreach (var c in body.DatiGenerali.DatiGeneraliDocumento.Causale) { this.Causale.Add(new CausaleModel(c)); } int ddtLength = body.DatiGenerali.DatiDDT.Count; if (ddtLength > 0) { this.DatiDDT = new List <DatiDDTModel>(); } foreach (var ddt in body.DatiGenerali.DatiDDT) { this.DatiDDT.Add(new DatiDDTModel(ddt)); } int cassaLength = body.DatiGenerali.DatiGeneraliDocumento.DatiCassaPrevidenziale.Count; if (cassaLength > 0) { this.DatiCassaPrevidenziale = new List <DatiCassaPrevidenzialeModel>(); } foreach (var cassa in body.DatiGenerali.DatiGeneraliDocumento.DatiCassaPrevidenziale) { this.DatiCassaPrevidenziale.Add(new DatiCassaPrevidenzialeModel(cassa)); } // ---DatiModel--- int acquistoLength = body.DatiGenerali.DatiOrdineAcquisto.Count; int contrattoLength = body.DatiGenerali.DatiContratto.Count; int convenzioneLength = body.DatiGenerali.DatiConvenzione.Count; int ricezioneLength = body.DatiGenerali.DatiRicezione.Count; int fCollegateLength = body.DatiGenerali.DatiFattureCollegate.Count; if (acquistoLength > 0 || contrattoLength > 0 || convenzioneLength > 0 || ricezioneLength > 0 || fCollegateLength > 0 ) { this.Dati = new List <DatiModel>(); } foreach (var acquisto in body.DatiGenerali.DatiOrdineAcquisto) { this.Dati.Add(new DatiModel(acquisto)); } foreach (var contratto in body.DatiGenerali.DatiContratto) { this.Dati.Add(new DatiModel(contratto)); } foreach (var convenzione in body.DatiGenerali.DatiConvenzione) { this.Dati.Add(new DatiModel(convenzione)); } foreach (var ricezione in body.DatiGenerali.DatiRicezione) { this.Dati.Add(new DatiModel(ricezione)); } foreach (var collegate in body.DatiGenerali.DatiFattureCollegate) { this.Dati.Add(new DatiModel(collegate)); } //---End DatiModel--- this.DatiPagamento = new List <DatiPagamentoModel>(); int pagamentoLength = body.DatiPagamento.Count; if (pagamentoLength > 0) { foreach (var pagamento in body.DatiPagamento) { this.DatiPagamento.Add(new DatiPagamentoModel(pagamento)); } } else { var defaultDettaglio = new DettaglioPagamentoModel ( "MP05", body.DatiGenerali.DatiGeneraliDocumento.ImportoTotaleDocumento ?? default(int), body.DatiGenerali.DatiGeneraliDocumento.Data ); var defaultPagamento = new DatiPagamentoModel ( "TP02", defaultDettaglio ); this.DatiPagamento.Add(defaultPagamento); } this.DatiPagamento[0].Active = true; int riepilogoLength = body.DatiBeniServizi.DatiRiepilogo.Count; if (riepilogoLength > 0) { this.DatiRiepilogo = new List <DatiRiepilogoModel>(); } foreach (var riepilogo in body.DatiBeniServizi.DatiRiepilogo) { this.DatiRiepilogo.Add(new DatiRiepilogoModel(riepilogo)); } int salLength = body.DatiGenerali.DatiSAL.Count; if (salLength > 0) { this.DatiSAL = new List <DatiSALModel>(); } foreach (var sal in body.DatiGenerali.DatiSAL) { this.DatiSAL.Add(new DatiSALModel(sal)); } int lineeLength = body.DatiBeniServizi.DettaglioLinee.Count; if (lineeLength > 0) { this.DettaglioLinee = new List <DettaglioLineeModel>(); } foreach (var linea in body.DatiBeniServizi.DettaglioLinee) { this.DettaglioLinee.Add(new DettaglioLineeModel(linea)); } int ritenutaLength = body.DatiGenerali.DatiGeneraliDocumento.DatiRitenuta.Count; if (ritenutaLength > 0) { this.DatiRitenuta = new List <DatiRitenutaModel>(); foreach (var r in body.DatiGenerali.DatiGeneraliDocumento.DatiRitenuta) { this.DatiRitenuta.Add(new DatiRitenutaModel(r)); } } DettaglioPagamento dettaglioPagamento = new DettaglioPagamento(); if (body.DatiPagamento.Count > 0 && body.DatiPagamento[0].DettaglioPagamento.Count > 0) { dettaglioPagamento = body.DatiPagamento[0].DettaglioPagamento[0]; } this.CedentePrestatore = new CliForModel(header.CedentePrestatore, header.Rappresentante, dettaglioPagamento); this.CessionarioCommittente = new CliForModel(header.CessionarioCommittente); if (body.DatiGenerali.DatiTrasporto.DatiAnagraficiVettore != null) { this.Vettore = new CliForModel(body.DatiGenerali.DatiTrasporto.DatiAnagraficiVettore); } } }