public static bool IsEqual(this BillReceive billReceive, Client client, Systore.Domain.Entities.BillReceive billReceiveCheck) { if ((client.code != billReceiveCheck.ClientId) && (Utils.OnlyNumbers(client.cpf) != "00925146692")) { return(false); } if (billReceive.code != billReceiveCheck.Code) { return(false); } if (billReceive.quota != billReceiveCheck.Quota) { return(false); } if (decimal.Round(billReceive.original_value, 2, MidpointRounding.AwayFromZero) != billReceiveCheck.OriginalValue) { return(false); } if (decimal.Round(billReceive.interest, 2, MidpointRounding.AwayFromZero) != billReceiveCheck.Interest) { return(false); } if (decimal.Round(billReceive.final_value, 2, MidpointRounding.AwayFromZero) != billReceiveCheck.FinalValue) { return(false); } if ((billReceive.purchase_date ?? DateTime.MinValue.ToUniversalTime()).Date != billReceiveCheck.PurchaseDate.Date) { return(false); } if ((billReceive.due_date ?? DateTime.MinValue.ToUniversalTime()).Date != billReceiveCheck.DueDate.Date) { return(false); } if (billReceive.pay_date?.Date != billReceiveCheck.PayDate?.Date) { return(false); } if (billReceive.days_delay != billReceiveCheck.DaysDelay) { return(false); } if (billReceive.situation != billReceiveCheck.Situation.GetSituationString()) { return(false); } if (billReceive.vendor != billReceiveCheck.Vendor) { return(false); } return(true); }
public static async Task <string> InserirBillReceive(BillReceive billReceive, List <string> billsReceiveInserted) { try { SystoreContext context = _systoreContextFactory.CreateDbContext(new string[] { }); var tuple = clientsInserted.Where(c => c.Item2 == billReceive.client).FirstOrDefault(); if (tuple == null) { throw new Exception($"Cliente {billReceive.client} da parcela {billReceive.code}-{billReceive.quota} não encontrado"); } int clientId = clientsInserted.Where(c => c.Item2 == billReceive.client).FirstOrDefault().Item1; var _billReceive = new Systore.Domain.Entities.BillReceive() { ClientId = clientId, Code = billReceive.code, DaysDelay = billReceive.days_delay, DueDate = (addhour(billReceive.due_date) ?? DateTime.MinValue.ToUniversalTime()), //billReceive.due_date.HasValue ? DateTime.SpecifyKind(billReceive.due_date.Value, DateTimeKind.Local) : DateTime.MinValue.ToUniversalTime(), FinalValue = billReceive.final_value, Interest = billReceive.interest, OriginalValue = billReceive.original_value, PayDate = addhour(billReceive.pay_date), //billReceive.pay_date.HasValue ? DateTime.SpecifyKind(billReceive.pay_date.Value, DateTimeKind.Local) : billReceive.pay_date, PurchaseDate = (addhour(billReceive.purchase_date) ?? DateTime.MinValue.ToUniversalTime()), // billReceive.purchase_date.HasValue ? DateTime.SpecifyKind(billReceive.purchase_date.Value, DateTimeKind.Local) : DateTime.MinValue.ToUniversalTime(), Quota = billReceive.quota, Situation = billReceive.situation == "O" ? Systore.Domain.Enums.BillReceiveSituation.Open : Systore.Domain.Enums.BillReceiveSituation.Closed, Vendor = billReceive.vendor, }; var billReceiveRepository = new BillReceiveRepository(context, null); billReceiveRepository.IsConversion = true; string retBill = await billReceiveRepository.AddAsync(_billReceive); if (string.IsNullOrWhiteSpace(retBill)) { Console.WriteLine($"BillReceive: ClientId: {clientId} {_billReceive.Code}-{_billReceive.Quota} inserido com sucesso"); billsReceiveInserted.Add($"BillReceive: ClientId: {clientId} {_billReceive.Code}-{_billReceive.Quota} inserido com sucesso"); return(""); } else { Console.WriteLine($"Erro ao inserir BillReceive: ClientId: {clientId} {_billReceive.Code}-{_billReceive.Quota} : {retBill}"); billsReceiveInserted.Add($"Erro ao inserir BillReceive: ClientId: {clientId} {_billReceive.Code}-{_billReceive.Quota} : {retBill}"); return($"Erro ao inserir BillReceive: ClientId: {clientId} {_billReceive.Code}-{_billReceive.Quota} : {retBill}"); } } catch (Exception e) { billsReceiveInserted.Add($"Erro ao inserir BillReceive: {billReceive.code}-{billReceive.quota} : {e.Message}"); Console.WriteLine($"Erro ao inserir BillReceive: {billReceive.code}-{billReceive.quota} : {e.Message}"); return($"Erro ao inserir BillReceive: {billReceive.code}-{billReceive.quota} : {e.Message}"); } }