public async Task <ActionResult <VendorInvoice> > Insert([FromBody] VendorInvoice pVendorInvoice) { VendorInvoice _VendorInvoiceq = new VendorInvoice(); _VendorInvoiceq = pVendorInvoice; using (var transaction = _context.Database.BeginTransaction()) { try { _VendorInvoiceq.PurchaseOrderId = null; //_VendorInvoiceq.Sucursal = await _context.Branch.Where(q => q.BranchId == _VendorInvoiceq.BranchId).Select(q => q.BranchCode).FirstOrDefaultAsync(); Numalet let; let = new Numalet(); let.SeparadorDecimalSalida = "Lempiras"; let.MascaraSalidaDecimal = "00/100 "; let.ApocoparUnoParteEntera = true; _VendorInvoiceq.TotalLetras = let.ToCustomCardinal((_VendorInvoiceq.Total)).ToUpper(); _context.VendorInvoice.Add(_VendorInvoiceq); //await _context.SaveChangesAsync(); JournalEntry _je = new JournalEntry { Date = _VendorInvoiceq.VendorInvoiceDate, Memo = "Factura de Compra a Proveedores", DatePosted = _VendorInvoiceq.VendorInvoiceDate, ModifiedDate = DateTime.Now, CreatedDate = DateTime.Now, ModifiedUser = _VendorInvoiceq.UsuarioModificacion, CreatedUser = _VendorInvoiceq.UsuarioCreacion, DocumentId = _VendorInvoiceq.VendorInvoiceId, }; Accounting account = await _context.Accounting.Where(acc => acc.AccountId == _VendorInvoiceq.AccountId).FirstOrDefaultAsync(); _je.JournalEntryLines.Add(new JournalEntryLine { AccountId = Convert.ToInt32(_VendorInvoiceq.AccountId), //Description = _VendorInvoiceq.Account.AccountName, Description = account.AccountName, Credit = 0, Debit = _VendorInvoiceq.Total, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now, CreatedUser = _VendorInvoiceq.UsuarioCreacion, ModifiedUser = _VendorInvoiceq.UsuarioModificacion, Memo = "", }); foreach (var item in _VendorInvoiceq.VendorInvoiceLine) { account = await _context.Accounting.Where(acc => acc.AccountId == _VendorInvoiceq.AccountId).FirstOrDefaultAsync(); item.VendorInvoiceId = _VendorInvoiceq.VendorInvoiceId; _context.VendorInvoiceLine.Add(item); _je.JournalEntryLines.Add(new JournalEntryLine { AccountId = Convert.ToInt32(item.AccountId), Description = account.AccountName, Credit = item.Total, Debit = 0, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now, CreatedUser = _VendorInvoiceq.UsuarioCreacion, ModifiedUser = _VendorInvoiceq.UsuarioModificacion, Memo = "", }); } await _context.SaveChangesAsync(); double sumacreditos = 0, sumadebitos = 0; if (sumacreditos != sumadebitos) { transaction.Rollback(); _logger.LogError($"Ocurrio un error: No coinciden debitos :{sumadebitos} y creditos{sumacreditos}"); return(BadRequest($"Ocurrio un error: No coinciden debitos :{sumadebitos} y creditos{sumacreditos}")); } _je.TotalCredit = sumacreditos; _je.TotalDebit = sumadebitos; _context.JournalEntry.Add(_je); await _context.SaveChangesAsync(); BitacoraWrite _write = new BitacoraWrite(_context, new Bitacora { IdOperacion = 4, ///////Falta definir los Id de las Operaciones DocType = "VendorInvoice", ClaseInicial = Newtonsoft.Json.JsonConvert.SerializeObject(_VendorInvoiceq, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }), ResultadoSerializado = Newtonsoft.Json.JsonConvert.SerializeObject(_VendorInvoiceq, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }), Accion = "Insert", FechaCreacion = DateTime.Now, FechaModificacion = DateTime.Now, UsuarioCreacion = _VendorInvoiceq.UsuarioCreacion, UsuarioModificacion = _VendorInvoiceq.UsuarioModificacion, UsuarioEjecucion = _VendorInvoiceq.UsuarioModificacion, }); await _context.SaveChangesAsync(); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); _logger.LogError($"Ocurrio un error: { ex.ToString() }"); throw ex; } } return(await Task.Run(() => Ok(_VendorInvoiceq))); }
async Task SaveInvoice(int InvoiceType) { if (InvoiceType == 0) { order.PaymentType = 0; double finalPayment = Convert.ToDouble(lblFinalPayment.Text); if (finalPayment == 0) { await DisplayAlert("صدور فاکتور", "فاکتور به مبلغ صفر نمیتواتد در سیستم ثبت گردد", "باشه"); } else { await SandoghcheController._connection.InsertAsync(order); await SandoghcheController._connection.InsertAllAsync(order.OrderDetails); await SandoghcheController._connection.UpdateWithChildrenAsync(order); await UpdateProductsAmount(); await DisplayAlert("صدور فاکتور", string.Format(" فاکتور {0} شماره فیش {1} به مبلغ {2} ثبت شد", order.ReceiptNumber, order.OrderId, Convert.ToDouble(lblFinalPayment.Text)), "باشه"); await setOrderNumber(); await setReceiptNumber(); lblTax.Text = "0"; lblDiscount.Text = "0"; lblService.Text = "0"; lblTax.Text = "0"; lblFinalPayment.Text = "0"; lblTotalPrice.Text = "0"; lblDelivery.Text = "0"; ProductsDataGrid.ItemsSource = null; lstProducts.ItemsSource = null; srchClients.Text = ""; pkrCategory.ItemsSource = null; lblTotalNumberOfItem.Text = "سبد" + "( " + "0" + " )"; lblCreditStatus.Text = "مانده : 0"; await getCategories(); order = new Order(); TabReceipt.IsSelected = true; } } else if (InvoiceType == 1) { order.PaymentType = 1; double finalPayment = Convert.ToDouble(lblFinalPayment.Text); if (finalPayment == 0) { await DisplayAlert("صدور فاکتور", "فاکتور به مبلغ صفر نمیتواتد در سیستم ثبت گردد", "باشه"); } else { Accounting accounting = new Accounting(); accounting.ClientId = order.ClientId; accounting.DebtorAmount = order.FinalPayment; accounting.CreditorAmount = 0; await SandoghcheController._connection.InsertAsync(order); await SandoghcheController._connection.InsertAllAsync(order.OrderDetails); await SandoghcheController._connection.UpdateWithChildrenAsync(order); await SandoghcheController._connection.InsertAsync(accounting); await UpdateProductsAmount(); await DisplayAlert("صدور فاکتور", string.Format(" فاکتور {0} شماره فیش {1} به مبلغ {2} ثبت شد", order.ReceiptNumber, order.OrderId, Convert.ToDouble(lblFinalPayment.Text)), "باشه"); await setOrderNumber(); await setReceiptNumber(); lblTax.Text = "0"; lblDiscount.Text = "0"; lblService.Text = "0"; lblTax.Text = "0"; lblFinalPayment.Text = "0"; lblTotalPrice.Text = "0"; lblDelivery.Text = "0"; ProductsDataGrid.ItemsSource = null; lstProducts.ItemsSource = null; srchClients.Text = ""; lblTotalNumberOfItem.Text = "سبد" + "( " + "0" + " )"; await getCategories(); await ClientCreditStatus(clientId); order = new Order(); TabReceipt.IsSelected = true; lblCreditStatus.Text = "مانده : 0"; } } }
public async Task <ActionResult <TypeAccount> > Insert([FromBody] TypeAccountDTO _TypeAccount) { TypeAccount _TypeAccountq = new TypeAccount(); try { using (var transaction = _context.Database.BeginTransaction()) { try { _TypeAccountq = _TypeAccount; _context.TypeAccount.Add(_TypeAccountq); await _context.SaveChangesAsync(); CompanyInfo _co = await _context.CompanyInfo.FirstOrDefaultAsync(); Accounting _padreaccount = new Accounting { AccountName = _TypeAccountq.TypeAccountName, AccountCode = _TypeAccountq.TypeAccountId.ToString(), TypeAccountId = _TypeAccountq.TypeAccountId, IsCash = false, Description = _TypeAccountq.TypeAccountName, CompanyInfoId = _co.CompanyInfoId, UsuarioCreacion = _TypeAccountq.CreatedUser, UsuarioModificacion = _TypeAccountq.ModifiedUser, FechaCreacion = DateTime.Now, FechaModificacion = DateTime.Now, ParentAccountId = null, Totaliza = true, DeudoraAcreedora = _TypeAccount.DeudoraAcreedora, IdEstado = 1, Estado = "Activo", }; _context.Accounting.Add(_padreaccount); await _context.SaveChangesAsync(); BitacoraWrite _write = new BitacoraWrite(_context, new Bitacora { IdOperacion = _TypeAccount.TypeAccountId, DocType = "TypeAccount", ClaseInicial = Newtonsoft.Json.JsonConvert.SerializeObject(_TypeAccountq, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }), Accion = "Insertar", FechaCreacion = DateTime.Now, FechaModificacion = DateTime.Now, UsuarioCreacion = _TypeAccountq.CreatedUser, UsuarioModificacion = _TypeAccountq.ModifiedUser, UsuarioEjecucion = _TypeAccountq.ModifiedUser, }); await _context.SaveChangesAsync(); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); _logger.LogError($"Ocurrio un error: { ex.ToString() }"); return(await Task.Run(() => BadRequest($"Ocurrio un error:{ex.Message}"))); } } } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); return(BadRequest($"Ocurrio un error:{ex.Message}")); } return(await Task.Run(() => Ok(_TypeAccountq))); }
public void SetUp() { _accounting = new Accounting(); }
public void TestInit() { _accounting = new Accounting(_budgetRepository); }
/// <summary> /// 新增科目 /// </summary> /// <param name="accounting">科目对象</param> /// <returns>新增是否成功</returns> public Boolean newAccounting(Accounting accounting) { accounting.company = account.company; return(accountingModel.newAccounting(accounting) > 0); }
public virtual ActionResult Checkout(OrderEditModel model) { // validate form if (String.IsNullOrEmpty(model.ShippingAddress.Address1)) { ModelState.AddModelError("ShippingAddress.Address1", "Please include a valid street address."); } if (String.IsNullOrEmpty(model.ShippingAddress.City)) { ModelState.AddModelError("ShippingAddress.City", "Please specify your city."); } if (String.IsNullOrEmpty(model.ShippingAddress.State)) { ModelState.AddModelError("ShippingAddress.State", "Please specify your state."); } if (String.IsNullOrEmpty(model.ShippingAddress.PostalCode)) { ModelState.AddModelError("ShippingAddress.PostalCode", "Please specify your postal code."); } if (String.IsNullOrEmpty(model.ShippingPhone.Number)) { ModelState.AddModelError("ShippingPhone.Number", "Please include a phone number where we can reach you for any questions regarding this order."); } if (!ModelState.IsValid) { return(View(model)); } // update the shopping cart to get current pricing CurrentCart.Update(Catalog, Application.DefaultCatalog); // create order var ticks = DateTime.Now.Ticks.ToString(); var o = new Order { Document = new Document { Id = Document.For <Order>(string.Format( "{0}-{1}-{2}", CurrentUser.Login, DateTime.UtcNow.ToShortDateString(), ticks.Substring(ticks.Length - 4)).ToSlug()) }, User = CurrentUser.Document.Id, State = OrderStateMachine.Create(), ShippingName = model.ShippingName, ShippingAddress = model.ShippingAddress, ShippingPhone = model.ShippingPhone, Items = CurrentCart.Select(x => x.Value.ToOrderItem()).ToArray(), }; // pay for order try { var tx = Accounting.CreateOrderPayment(CurrentUser, o); o.Transaction = tx.Document.Id; } catch { throw; } CurrentUser.Cart = null; Orders.Save(o); UserRepository.Save(CurrentUser); Notifier.Notify( Severity.Success, "Thank you for your order!", "You should receive an email confirmation with your order number shortly, and you can always review your order in My Activity.", o); return(RedirectToAction(MVC.Site.Home.Index())); }
static void Main(string[] args) { log.Info("Starting Report Application..."); DateTime timestamp = DateTime.Now; List <String> reports = new List <String> { "Funded Report", "Not Purchased Report", "Not CTC Report < 60 days", "Processors Report", "Locked for Files CTC, Not Funded Report", "Funded w/o Investor Lock Report", "Accounting Report for Current Month", "db testing", "db update: 'My Pipeline'", "db update: 'Completed Loans'", "db update: 'Servicing'", "db update: 'Adverse'", "db update: ALL" }; parseArgs(args); new EllieMae.Encompass.Runtime.RuntimeServices().Initialize(); if (args.Length == 0) { debug = true; Console.Out.WriteLine("----------------------"); Console.Out.WriteLine("Select report to run:"); for (int i = 0; i < reports.Count; i++) { Console.Out.WriteLine(i + " " + reports[i]); } Console.Out.WriteLine("----------------------"); int input = Int32.Parse(Console.In.ReadLine()); report = input; Console.Out.WriteLine("Selection: " + reports[input]); } else { debug = false; } String text = null; mySession = new SessionManager(); log.Info("Encompass Session begin"); switch (report) { case 0: FundedReport report1 = new FundedReport(); text = report1.run(); outputReport(reports[report], text); break; case 1: NotPurchasedReport report2 = new NotPurchasedReport(); text = report2.run(); outputReport(reports[report], text); break; case 2: NotCTCReport report3 = new NotCTCReport(); text = report3.run(); outputReport(reports[report], text); break; case 3: ProcessorsReport report4 = new ProcessorsReport(); text = report4.run(); outputReport(reports[report], text); break; case 4: Locks4CTCNotFundedReport report5 = new Locks4CTCNotFundedReport(); text = report5.run(); outputReport(reports[report], text); break; case 5: FundedNotLockedReport report6 = new FundedNotLockedReport(); text = report6.run(); outputReport(reports[report], text); break; case 6: Accounting report7 = new Accounting(); text = report7.run(); outputReport(reports[report], text); break; case 7: db.db_connect connection = new db.db_connect(); connection.connect(); log.Debug("everything working"); connection.close(); break; case 8: db.EncompassUpdate update = new db.EncompassUpdate(); update.run(report); break; case 9: db.EncompassUpdate update1 = new db.EncompassUpdate(); update1.run(report); break; case 10: db.EncompassUpdate update2 = new db.EncompassUpdate(); update2.run(report); break; case 11: db.EncompassUpdate update3 = new db.EncompassUpdate(); update3.run(report); break; case 12: db.EncompassUpdate updateAll = new db.EncompassUpdate(); updateAll.run(8); updateAll.run(9); updateAll.run(10); updateAll.run(11); updateAll.run(12); break; default: log.Error("No report chosen"); break; } log.Info("Encompass session closing.."); mySession.closeSession(); TimeSpan time = DateTime.Now.Subtract(timestamp); log.Info("Report Application Finished in " + String.Format("{0} min {1}.{2} sec" , time.Minutes , time.Seconds , time.Milliseconds)); //log.Info("Report Application Finished!"); }
public async Task <ActionResult <Accounting> > Update([FromBody] Accounting _Account) { Accounting _Accountq = _Account; try { using (var transaction = _context.Database.BeginTransaction()) { try { _Accountq = await(from c in _context.Accounting .Where(q => q.AccountId == _Accountq.AccountId) select c ).FirstOrDefaultAsync(); _context.Entry(_Accountq).CurrentValues.SetValues((_Account)); //_context.Alert.Update(_Alertq); await _context.SaveChangesAsync(); BitacoraWrite _write = new BitacoraWrite(_context, new Bitacora { IdOperacion = _Accountq.AccountId, DocType = "Accounting", ClaseInicial = Newtonsoft.Json.JsonConvert.SerializeObject(_Accountq, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }), ResultadoSerializado = Newtonsoft.Json.JsonConvert.SerializeObject(_Account, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }), Accion = "Actualizar", FechaCreacion = DateTime.Now, FechaModificacion = DateTime.Now, UsuarioCreacion = _Account.UsuarioCreacion, UsuarioModificacion = _Account.UsuarioModificacion, UsuarioEjecucion = _Account.UsuarioModificacion, }); await _context.SaveChangesAsync(); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); _logger.LogError($"Ocurrio un error: { ex.ToString() }"); throw ex; // return BadRequest($"Ocurrio un error:{ex.Message}"); } } } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); return(await Task.Run(() => BadRequest($"Ocurrio un error:{ex.Message}"))); } return(await Task.Run(() => Ok(_Accountq))); }
private void RenderMyViewData(Accounting model) { ViewData.Add("Rank", new SelectList(EnumHelper.GetItemValueList <EnumRank>(), "Key", "Value", model.Rank)); ViewData.Add("AccountDep", new SelectList(EnumHelper.GetItemValueList <EnumDep>(), "Key", "Value", model.AccountDep)); }
private List <AccountingDTO> ObtenerCategoriarJerarquia(List <Int32> Parents) { List <AccountingDTO> Items = new List <AccountingDTO>(); List <Int32> _padre = new List <Int32>(); foreach (var padre in Parents) { Accounting _ac = _context.Accounting.Where(q => q.AccountId == padre).FirstOrDefault(); if (_ac.ParentAccountId != null) { _padre.Add(_ac.ParentAccountId.Value); } Items.Add(new AccountingDTO { AccountId = _ac.AccountId, AccountName = _ac.AccountName, AccountCode = _ac.AccountCode, AccountBalance = _ac.AccountBalance, ParentAccountId = _ac.ParentAccountId, }); } List <Accounting> categoriasList = (from c in Items select new Accounting { AccountId = c.AccountId, AccountBalance = c.AccountBalance, AccountCode = c.AccountCode, AccountName = c.AccountName, ParentAccountId = c.ParentAccountId, } ).ToList(); var res = (from c in categoriasList // where c.ParentAccountId == null || c.ParentAccountId == 0 select new AccountingDTO { AccountId = c.AccountId, AccountName = c.AccountName, AccountBalance = c.AccountBalance, AccountCode = c.AccountCode, ParentAccountId = c.ParentAccountId, // Children = ObtenerHijos(c.AccountId, categoriasList) }).ToList(); if (res.Count > 0) { foreach (var item in res) { var existe = query.Where(q => q.AccountId == item.AccountId).ToList(); if (existe.Count == 0) { query.Add(item); } } } if (_padre.Count > 0) { ObtenerCategoriarJerarquia(_padre); } return(query); }
private void SaveChanges_Click(object sender, RoutedEventArgs e) { using (var connection = new SqlConnection(ConnectionString)) { try { connection.Open(); if (AudienceTableID == 0) { var command = new SqlCommand("AddAudienceTable", connection) { CommandType = CommandType.StoredProcedure }; command.Parameters.Add(new SqlParameter("@AudienceID", AudienceID)); command.Parameters.Add(new SqlParameter("@Name", CurrentPlace.Name)); command.Parameters.Add(new SqlParameter("@Description", CurrentPlace.Description)); command.Parameters.Add(new SqlParameter { ParameterName = "@TableID", Direction = ParameterDirection.Output, DbType = DbType.Int32 }); command.ExecuteNonQuery(); AudienceTableID = Convert.ToInt32(command.Parameters["@TableID"].Value); CurrentPlace.ID = AudienceTableID; } //new SqlCommand($"Update AudienceTable Set Name=N'{CurrentPlace.Name}', Description=N'{CurrentPlace.Description}' where ID={CurrentPlace.ID}", // connection).ExecuteNonQuery(); var count = CurrentPlace.TypeDeviceRemovedCollection.Count; for (var i = 0; i < count; i++) { var temp = CurrentPlace.TypeDeviceRemovedCollection[i]; if (temp.Row != null) { var obj = new SqlCommand( $"Select TOP(1) PlaceID from {temp.Row["TableName"]} Where ID={temp.Row["ID"]}", connection) .ExecuteScalar(); var id = Convert.ToInt32(!(obj is DBNull) ? obj : 0); if (id == temp.PlaceID) { new SqlCommand($"Update {temp.Row["TableName"]} set PlaceID=null Where ID={temp.Row["ID"]}", connection).ExecuteNonQuery(); } } if (temp.PlaceID != 0) { if (temp.IsRemoved) { new SqlCommand($"Delete from Place Where ID={temp.PlaceID}", connection).ExecuteNonQuery(); } } } count = CurrentPlace.TypeDeviceCollection.Count; for (var i = 0; i < count; i++) { var temp = CurrentPlace.TypeDeviceCollection[i]; if (temp.PlaceID != 0) { new SqlCommand( $"Update Place set TypeDeviceID=dbo.GetTypeDeviceID(N'{temp.TypeDevice.Type}') Where ID={temp.PlaceID}", connection).ExecuteNonQuery(); if (temp.Row != null) // устройство { new SqlCommand( $"Update {temp.Row["TableName"]} set PlaceID={temp.PlaceID} Where ID={temp.Row["ID"]}", connection).ExecuteNonQuery(); } } else if (!(temp.TypeDevice is null)) { var command = new SqlCommand("AddLocation", connection) { CommandType = CommandType.StoredProcedure }; command.Parameters.Add(new SqlParameter("@AudienceTableID", AudienceTableID)); command.Parameters.Add(new SqlParameter("@TypeDeviceID", Convert.ToInt32(new SqlCommand($"Select dbo.GetTypeDeviceID(N'{temp.TypeDevice.Type}')", connection).ExecuteScalar()))); var parameter = new SqlParameter { ParameterName = "@PlaceID", Direction = ParameterDirection.Output, DbType = DbType.Int32 }; command.Parameters.Add(parameter); command.ExecuteNonQuery(); var PID = Convert.ToInt32(command.Parameters["@PlaceID"].Value); if (temp.Row != null) // устройство { new SqlCommand( $"Update {temp.Row["TableName"]} set PlaceID={PID} Where ID={temp.Row["ID"]}", connection).ExecuteNonQuery(); } } } } catch (Exception exception) { MessageBox.Show(exception.Message, exception.GetType().Name, MessageBoxButton.OK, MessageBoxImage.Error); if (connection.State == ConnectionState.Open) { connection.Close(); } } } Accounting.IsHitTestVisible = true; Accounting.ChangeLocationView(); Close(); }
public void UpdateAccounting(Accounting accounting) { using (var db = new LogistoDb()) { db.Accountings.Where(w => w.ID == accounting.ID) //.Set(u => u.No, accounting.No) .Set(u => u.Vat, accounting.Vat) .Set(u => u.Sum, accounting.Sum) .Set(u => u.Number, accounting.Number) .Set(u => u.Route, accounting.Route) .Set(u => u.Comment, accounting.Comment) .Set(u => u.ActDate, accounting.ActDate) .Set(u => u.RequestDate, accounting.RequestDate) .Set(u => u.InvoiceDate, accounting.InvoiceDate) .Set(u => u.AccountingDate, accounting.AccountingDate) .Set(u => u.PaymentPlanDate, accounting.PaymentPlanDate) .Set(u => u.AccountingPaymentMethodId, accounting.AccountingPaymentMethodId) .Set(u => u.AccountingDocumentTypeId, accounting.AccountingDocumentTypeId) .Set(u => u.AccountingPaymentTypeId, accounting.AccountingPaymentTypeId) .Set(u => u.CargoLegalId, accounting.CargoLegalId) .Set(u => u.OurLegalId, accounting.OurLegalId) .Set(u => u.PayMethodId, accounting.PayMethodId) .Set(u => u.ContractId, accounting.ContractId) .Set(u => u.LegalId, accounting.LegalId) .Set(u => u.VatInvoiceNumber, accounting.VatInvoiceNumber) .Set(u => u.InvoiceNumber, accounting.InvoiceNumber) .Set(u => u.ActNumber, accounting.ActNumber) .Set(u => u.SecondSignerEmployeeId, accounting.SecondSignerEmployeeId) .Set(u => u.SecondSignerPosition, accounting.SecondSignerPosition) .Set(u => u.SecondSignerInitials, accounting.SecondSignerInitials) .Set(u => u.SecondSignerName, accounting.SecondSignerName) .Set(u => u.CurrencyRate, accounting.CurrencyRate) .Set(u => u.OriginalSum, accounting.OriginalSum) .Set(u => u.OriginalVat, accounting.OriginalVat) .Set(u => u.ecnExportTO, accounting.ecnExportTO) .Set(u => u.ecnExportTOEN, accounting.ecnExportTOEN) .Set(u => u.ecnGOcomment, accounting.ecnGOcomment) .Set(u => u.ecnGOcommentEN, accounting.ecnGOcommentEN) .Set(u => u.ecnGOcontact, accounting.ecnGOcontact) .Set(u => u.ecnGOcontactEN, accounting.ecnGOcontactEN) .Set(u => u.ecnGOcontTel, accounting.ecnGOcontTel) .Set(u => u.ecnGOnameINN, accounting.ecnGOnameINN) .Set(u => u.ecnGOnameINNEN, accounting.ecnGOnameINNEN) .Set(u => u.ecnGOtime, accounting.ecnGOtime) .Set(u => u.ecnGOtimeEN, accounting.ecnGOtimeEN) .Set(u => u.ecnGPcomment, accounting.ecnGPcomment) .Set(u => u.ecnGPcommentEN, accounting.ecnGPcommentEN) .Set(u => u.ecnGPcontact, accounting.ecnGPcontact) .Set(u => u.ecnGPcontactEN, accounting.ecnGPcontactEN) .Set(u => u.ecnGPconTel, accounting.ecnGPconTel) .Set(u => u.ecnGPnameINN, accounting.ecnGPnameINN) .Set(u => u.ecnGPnameINNEN, accounting.ecnGPnameINNEN) .Set(u => u.ecnGPtime, accounting.ecnGPtime) .Set(u => u.ecnGPtimeEN, accounting.ecnGPtimeEN) .Set(u => u.ecnImportTO, accounting.ecnImportTO) .Set(u => u.ecnImportTOEN, accounting.ecnImportTOEN) .Set(u => u.ecnKommentEN, accounting.ecnKommentEN) .Set(u => u.ecnLoadingDate, accounting.ecnLoadingDate) .Set(u => u.ecnMarshrutEN, accounting.ecnMarshrutEN) .Set(u => u.Payment, accounting.Payment) .Set(u => u.ecnTransport, accounting.ecnTransport) .Set(u => u.ecnTS, accounting.ecnTS) .Set(u => u.ecnUnloadingDate, accounting.ecnUnloadingDate) .Set(u => u.strGOcontTelEN, accounting.strGOcontTelEN) .Set(u => u.strGPcontTelEN, accounting.strGPcontTelEN) .Update(); } }
public virtual ActionResult Budget() { var users = Accounting.GetUsersManangerCanDisitributeBudgetTo(CurrentUser); return(PartialView(users)); }
public void Add(Accounting entity) { _accountings.Add(entity); }
public ActionResult StudentAccount() { String userId = User.Identity.GetUserId(); var context = HttpContext.GetOwinContext().Get <ApplicationDbContext>(); decimal CREDIT_HOUR_COST = 240; // gets a list of enrollments for current student var currentEnrollments = context.Enrollments.Include(x => x.User).Include(c => c.Course).Where(s => s.User.Id == userId).ToList(); // get currentStudent var currentStudent = context.Users.Where(x => x.Id == userId).FirstOrDefault(); // gets sum of all credit hours enrolled in var totalCreditHours = currentEnrollments.Sum(x => x.Course.CreditHours); ViewBag.TotalCreditHours = totalCreditHours; var totalCostofCreditHours = totalCreditHours * CREDIT_HOUR_COST; // if the student already exists in the accounting table if (context.Accounting.Any(x => x.User.Id == userId)) { // gets current student account from Accounting table var currentStudentAccount = context.Accounting.Where(x => x.User.Id == userId).FirstOrDefault(); // get the difference in credit hours var diffInCreditHours = (totalCreditHours - currentStudentAccount.TotalCreditHours); // get new cost needed to be added or subtracted to account decimal newCreditCosts = (diffInCreditHours * CREDIT_HOUR_COST); var newTotalBalance = (currentStudentAccount.TotalBalance + newCreditCosts); // update total cost in database currentStudentAccount.TotalBalance = newTotalBalance; // update credit hours in database currentStudentAccount.TotalCreditHours = totalCreditHours; context.SaveChanges(); // the user already exists, get their balance var formattedCost = String.Format("{0:C2}", currentStudentAccount.TotalBalance); ViewBag.TotalFormattedCost = formattedCost; } else { var accounting = new Accounting() { User = currentStudent, PaymentDate = DateTime.Now, TotalCreditHours = totalCreditHours, TotalBalance = totalCostofCreditHours }; var formattedCost = String.Format("{0:C2}", accounting.TotalBalance); context.Accounting.Add(accounting); context.SaveChanges(); ViewBag.TotalFormattedCost = formattedCost; } return(View(currentEnrollments)); }
async Task SaveInvoice(int InvoiceType) { if (InvoiceType == 0) { order.PaymentType = 0; order.isEdited = true; order.EditedTime = Convert.ToDateTime(DateTime.Now).ToString("yyyy-MM-dd HH:mm:ss"); double finalPayment = Convert.ToDouble(lblFinalPayment.Text); if (finalPayment <= 0) { await DisplayAlert("صدور فاکتور", "فاکتور به مبلغ صفر و کمتر نمیتواتد در سیستم ویرایش گردد", "باشه"); } else { var OriginalOrder = await SandoghcheController.GetConnection().Table <Order>().FirstOrDefaultAsync(o => o.OrderId == OrderId); var OriginalOrderDetails = await SandoghcheController.GetConnection().Table <OrderDetail>().Where(d => d.OrderId == order.OrderId).ToListAsync(); //order = OriginalOrder; //order.OrderDetails = OriginalOrderDetails; await SandoghcheController._connection.DeleteAllAsync(OriginalOrderDetails); await SandoghcheController._connection.InsertAllAsync(order.OrderDetails); await SandoghcheController._connection.UpdateAsync(order); await SandoghcheController._connection.UpdateWithChildrenAsync(order); edited.ClientId = OriginalOrder.ClientId; edited.Comment = OriginalOrder.Comment; edited.DateCreated = OriginalOrder.DateCreated; edited.DeliveryFee = OriginalOrder.DeliveryFee; edited.DiscountPercent = OriginalOrder.DiscountPercent; edited.DiscountType = OriginalOrder.DiscountType; edited.EditedDate = Convert.ToDateTime(DateTime.Now).ToString("yyyy-MM-dd HH:mm:ss"); edited.FinalPayment = OriginalOrder.FinalPayment; edited.OrderId = OriginalOrder.OrderId; edited.PaymentType = OriginalOrder.PaymentType; edited.ReceiptNumber = OriginalOrder.ReceiptNumber; edited.ServicePercent = OriginalOrder.ServicePercent; edited.ServiceType = OriginalOrder.ServiceType; edited.Tax1 = OriginalOrder.Tax1; edited.Tax1Percent = OriginalOrder.Tax1Percent; edited.Tax2 = OriginalOrder.Tax2; edited.Tax2Percent = OriginalOrder.Tax2Percent; edited.TotalDiscount = OriginalOrder.TotalDiscount; edited.TotalPrice = OriginalOrder.TotalPrice; edited.TotalServiceFee = OriginalOrder.TotalServiceFee; edited.EditedOrderDetailsLogs = new List <EditedOrderDetailsLogs>(); foreach (var item in OriginalOrderDetails) { edited.EditedOrderDetailsLogs.Add(new EditedOrderDetailsLogs { CategoryId = item.CategoryId, DetailId = item.DetailId, Number = item.Number, OrderId = item.OrderId, Price = item.Price, ProductId = item.ProductId, TotalPrice = item.TotalPrice }); } await SandoghcheController._connection.InsertAsync(edited); await SandoghcheController._connection.InsertAllAsync(edited.EditedOrderDetailsLogs); await SandoghcheController._connection.UpdateWithChildrenAsync(edited); //edited.EditedOrderDetailsLogs = editedOrderDetailsLogs; await UpdateProductsAmount(); await DisplayAlert("ویرایش فاکتور", string.Format(" فاکتور {0} شماره فیش {1} به مبلغ {2} ویرایش شد", order.ReceiptNumber, order.OrderId, Convert.ToDouble(lblFinalPayment.Text)), "باشه"); lblTax.Text = "0"; lblDiscount.Text = "0"; lblService.Text = "0"; lblTax.Text = "0"; lblFinalPayment.Text = "0"; lblTotalPrice.Text = "0"; lblDelivery.Text = "0"; ProductsDataGrid.ItemsSource = null; lstProducts.ItemsSource = null; await Navigation.PushAsync(new SandoghcheMainPage()); } } else if (InvoiceType == 1) { order.PaymentType = 1; order.isEdited = true; order.EditedTime = Convert.ToDateTime(DateTime.Now).ToString("yyyy-MM-dd HH:mm:ss");; double finalPayment = Convert.ToDouble(lblFinalPayment.Text); if (finalPayment <= 0) { await DisplayAlert("ویرایش فاکتور", "فاکتور به مبلغ صفر و کمتر نمیتواتد در سیستم ویرایش گردد", "باشه"); } else { Accounting accounting = new Accounting(); accounting.ClientId = order.ClientId; accounting.CreditorAmount = 0; var OriginalOrder = await SandoghcheController.GetConnection().Table <Order>().FirstOrDefaultAsync(o => o.OrderId == OrderId); var OriginalOrderDetails = await SandoghcheController.GetConnection().Table <OrderDetail>().Where(d => d.OrderId == order.OrderId).ToListAsync(); if (OriginalOrder.PaymentType == 0) { accounting.DebtorAmount = order.FinalPayment; } else if (OriginalOrder.PaymentType == 1) { accounting.DebtorAmount = order.FinalPayment - OriginalOrder.FinalPayment; } await SandoghcheController._connection.DeleteAllAsync(OriginalOrderDetails); await SandoghcheController._connection.InsertAllAsync(order.OrderDetails); await SandoghcheController._connection.UpdateAsync(order); await SandoghcheController._connection.UpdateWithChildrenAsync(order); await SandoghcheController._connection.InsertAsync(accounting); edited.ClientId = OriginalOrder.ClientId; edited.Comment = OriginalOrder.Comment; edited.DateCreated = OriginalOrder.DateCreated; edited.DeliveryFee = OriginalOrder.DeliveryFee; edited.DiscountPercent = OriginalOrder.DiscountPercent; edited.DiscountType = OriginalOrder.DiscountType; edited.EditedDate = Convert.ToDateTime(DateTime.Now).ToString("yyyy-MM-dd HH:mm:ss"); edited.FinalPayment = OriginalOrder.FinalPayment; edited.OrderId = OriginalOrder.OrderId; edited.PaymentType = OriginalOrder.PaymentType; edited.ReceiptNumber = OriginalOrder.ReceiptNumber; edited.ServicePercent = OriginalOrder.ServicePercent; edited.ServiceType = OriginalOrder.ServiceType; edited.Tax1 = OriginalOrder.Tax1; edited.Tax1Percent = OriginalOrder.Tax1Percent; edited.Tax2 = OriginalOrder.Tax2; edited.Tax2Percent = OriginalOrder.Tax2Percent; edited.TotalDiscount = OriginalOrder.TotalDiscount; edited.TotalPrice = OriginalOrder.TotalPrice; edited.TotalServiceFee = OriginalOrder.TotalServiceFee; edited.EditedOrderDetailsLogs = new List <EditedOrderDetailsLogs>(); foreach (var item in OriginalOrderDetails) { edited.EditedOrderDetailsLogs.Add(new EditedOrderDetailsLogs { //EditedLogId = edited.EditedLogId, CategoryId = item.CategoryId, DetailId = item.DetailId, Number = item.Number, OrderId = item.OrderId, Price = item.Price, ProductId = item.ProductId, TotalPrice = item.TotalPrice }); } await SandoghcheController._connection.InsertAsync(edited); await SandoghcheController._connection.InsertAllAsync(edited.EditedOrderDetailsLogs); await SandoghcheController._connection.UpdateWithChildrenAsync(edited); await UpdateProductsAmount(); await DisplayAlert(",ویرایش فاکتور", string.Format(" فاکتور {0} شماره فیش {1} به مبلغ {2} ویرایش شد", order.ReceiptNumber, order.OrderId, Convert.ToDouble(lblFinalPayment.Text)), "باشه"); lblTax.Text = "0"; lblDiscount.Text = "0"; lblService.Text = "0"; lblTax.Text = "0"; lblFinalPayment.Text = "0"; lblTotalPrice.Text = "0"; lblDelivery.Text = "0"; ProductsDataGrid.ItemsSource = null; lstProducts.ItemsSource = null; await Navigation.PushAsync(new SandoghcheMainPage()); } } else if (InvoiceType == 3) { bool result = await DisplayAlert("حذف فاکتور", "آیا از حذف این فاکتور اطمینان دارید", "بله", "خیر"); if (result) { if (order.PaymentType == 1) { await DisplayAlert("خطا", "به دلیل وجود اطلاعات مرتبط یا بدهی امکان حذف نمی باشد", "باشه"); return; } var OriginalOrder = await SandoghcheController.GetConnection().Table <Order>().FirstOrDefaultAsync(o => o.OrderId == OrderId); var OriginalOrderDetails = await SandoghcheController.GetConnection().Table <OrderDetail>().Where(od => od.OrderId == OrderId).ToListAsync(); OriginalOrder.isDeleted = true; OriginalOrder.DeletedTime = OriginalOrder.DeletedTime = Convert.ToDateTime(DateTime.Now).ToString("yyyy-MM-dd HH:mm:ss"); await SandoghcheController._connection.UpdateAsync(OriginalOrder); order = OriginalOrder; order.OrderDetails = OriginalOrderDetails; await UpdateProductsAmount(true); await Navigation.PushAsync(new SandoghcheMainPage()); } } }
public async Task <IActionResult> AddReciept([Bind("ID,WalletID,FN,FD,FP")] Accounting accounting) { if (ModelState.IsValid) { _context.Add(accounting); if (accounting.FD != null && accounting.FN != null && accounting.FP != null) { NalogData data = new NalogData(); string json = await data.GetReceiptAsinch(accounting.FD, accounting.FN, accounting.FP); accounting.RecieptJSON = json; Receipt rec = ReceiptToClass.FromJson(json).Document.Receipt; IQueryable <Account> accQuery = (from a in _context.Accounts where a.INN == Convert.ToInt64(rec.UserInn) select a); if (accQuery.Count() > 0) { accounting.Account = accQuery.First(); accounting.OperationTypeID = accQuery.First().OperationTypeID; } else { Account lAcc = new Account() { ID = new Guid(), INN = Convert.ToInt64(rec.UserInn), Name = rec.User, Address = rec.RetailPlaceAddress, OperationTypeID = _context.OperationType.Where(o => o.Name == "default").Select(o => o.ID).First() }; _context.Update(lAcc); accounting.Account = lAcc; accounting.OperationTypeID = _context.OperationType.Where(o => o.Name == "default").Select(o => o.ID).First(); } accounting.Summ = rec.TotalSum / 100; accounting.DateTimeOperation = rec.DateTime.DateTime; accounting.AccountingType = AccountingTypes.Expense; accounting.Currency = Currencyes.rub; } if (accounting.Summ != null && accounting.Summ.Value > 0) { decimal sum = accounting.Summ.Value; Wallet wallet = (from w in _context.Wallets where w.ID == accounting.WalletID && w.UserID == _userManager.GetUserId(User) select w).First(); if (accounting.AccountingType == 0) { wallet.Balance = wallet.Balance + sum; } else { wallet.Balance = wallet.Balance - sum; } _context.Update(wallet); } await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(accounting)); }
static void Main(string[] args) { const double baseBudget = 75000.00; // Create some instances HumanResources hr01 = new HumanResources("HR 1", "Toby Flenderson", 2, "Dunder Mifflin"); HumanResources hr02 = new HumanResources("HR 2", "Jack Frost", 13, "South Pole"); Accounting ac01 = new Accounting("Accounting", "Angela Martin", 10, "Dunder Mifflin"); Sales sa01 = new Sales("Sales 1", "Michael Scott", 50, "Dunder Mifflin"); hr01.printDetails(); hr02.printDetails(); ac01.printDetails(); sa01.printDetails(); hr01.AddPolicy("Terminating Employees", "How to give people the shaft."); hr01.AddPolicy("Selling Out People", "How to screw people over."); hr01.AddPolicy("Bankrupting the System", "How to steal like a politician."); hr01.printPolicies(); sa01.AddSale("Dwight Schrute", 58975); sa01.AddSale("Phyllis Lapin", 48502); sa01.AddSale("Stanley Hudson", 1254871); sa01.printSalesStats(); ac01.AddBudget("Kevin Malone", -13); ac01.AddBudget("Oscar Gutierrez", 4858502); ac01.AddBudget("Angela Martin", 101254871); ac01.printBudgetStats(); // Add derived departments to the list List <Department> departmentsList = new List <Department>(); departmentsList.Add(hr01); departmentsList.Add(hr02); departmentsList.Add(ac01); departmentsList.Add(sa01); foreach (Department d in departmentsList) { d.SetBudget(baseBudget); } Console.WriteLine("\nToString() method on each list object:"); foreach (Department d in departmentsList) { Console.WriteLine($"{d.ToString()}"); } // Employee E01 = new Employee("Ken", "Lewis"); // Console.WriteLine("\n"); // E01.printEmployee(); // Console.WriteLine("\n"); // Console.WriteLine("\n------------------------------------"); // Console.WriteLine("\n------------------------------------"); // HumanResourcesEmployee E02 = new HumanResourcesEmployee("Ted", "Nugent", "fT", 24.50); // E02.printEmployee(); // Console.WriteLine("\n"); // HumanResourcesEmployee E03 = new HumanResourcesEmployee(); // E03.printEmployee(); // Console.WriteLine("\n------------------------------------"); // Console.WriteLine("\n------------------------------------"); // SalesEmployee E04 = new SalesEmployee("Teddy", "Nugenty", "pt", 24.50); // E04.printEmployee(); // Console.WriteLine("\n"); // SalesEmployee E05 = new SalesEmployee(); // E05.printEmployee(); // Console.WriteLine("\n------------------------------------"); // Console.WriteLine("\n------------------------------------"); // AccountingEmployee E06 = new AccountingEmployee("Teddyyy", "Nugent", "FT", 2400.50); // E06.printEmployee(); // Console.WriteLine("\n"); // AccountingEmployee E07 = new AccountingEmployee(); // E07.printEmployee(); Console.WriteLine("\n------------------------------------"); Console.WriteLine("------------------------------------"); Employee hre01 = new Employee("Ted", "Nugent"); Employee hre02 = new Employee("Eddy", "Van Halen"); Employee hre03 = new Employee("Alice", "Cooper"); Employee sae01 = new Employee("Johnny", "Appleseed"); Employee sae02 = new Employee("Jack", "Ripper"); Employee sae03 = new Employee("George", "Washington"); Employee ace01 = new Employee("Theodore", "huxtable"); Employee ace02 = new Employee("Peter", "Griffin"); Employee ace03 = new Employee("Glen", "Quigmire"); hr01.AddEmployee(hre01); hr01.AddEmployee(hre02); hr01.AddEmployee(hre03); sa01.AddEmployee(sae01); sa01.AddEmployee(sae02); sa01.AddEmployee(sae03); ac01.AddEmployee(ace01); ac01.AddEmployee(ace02); ac01.AddEmployee(ace03); hr01.printEmployeeList(); sa01.printEmployeeList(); ac01.printEmployeeList(); }
public void AddAccounting(AccountingVM accounting) { //Logic #region logic var _accounting = new Accounting() { senderAccountNumber = accounting.senderAccountNumber, receiverAccountNumber = accounting.receiverAccountNumber, amount = accounting.amount }; int sender = accounting.senderAccountNumber; int receiver = accounting.receiverAccountNumber; int amount = accounting.amount; var isSenderValid = _context.Accounts.Where(x => x.accountNumber == sender).FirstOrDefault(); var isReceiverValid = _context.Accounts.Where(x => x.accountNumber == receiver).FirstOrDefault(); bool senderOK = false; bool receiverOK = false; bool balanceOK = false; bool currencyOK = false; if (isSenderValid.accountNumber == sender) { senderOK = true; } else { NotFoundSender(sender); } if (isReceiverValid.accountNumber == receiver) { receiverOK = true; } else { NotFoundReceiver(receiver); } if (isSenderValid.currencyCode == isReceiverValid.currencyCode) { currencyOK = true; } else { NotFoundCurrency(isReceiverValid.currencyCode); } if (isSenderValid.balance >= amount) { balanceOK = true; isSenderValid.balance = isSenderValid.balance - amount; isReceiverValid.balance = isReceiverValid.balance + amount; } else { NotFoundBalance(sender); } #endregion if (senderOK && receiverOK && currencyOK && balanceOK) { _context.Add(_accounting); _context.SaveChanges(); } else { NotFound(); } }
public async Task <ActionResult <DebitNote> > Insert([FromBody] DebitNote _DebitNote) { DebitNote _DebitNoteq = new DebitNote(); try { using (var transaction = _context.Database.BeginTransaction()) { try { _DebitNoteq = _DebitNote; if (!_DebitNote.Fiscal) { DebitNote _debitnote = await _context.DebitNote.Where(q => q.BranchId == _DebitNote.BranchId) .Where(q => q.IdPuntoEmision == _DebitNote.IdPuntoEmision) .FirstOrDefaultAsync(); if (_debitnote != null) { _DebitNoteq.NúmeroDEI = _context.DebitNote.Where(q => q.BranchId == _DebitNote.BranchId) .Where(q => q.IdPuntoEmision == _DebitNote.IdPuntoEmision).Max(q => q.NúmeroDEI); } _DebitNoteq.NúmeroDEI += 1; // Int64 puntoemision = _context.Users.Where(q=>q.Email==_DebitNoteq.UsuarioCreacion).Select(q=>q.) Int64 IdCai = await _context.NumeracionSAR .Where(q => q.BranchId == _DebitNoteq.BranchId) .Where(q => q.IdPuntoEmision == _DebitNoteq.IdPuntoEmision) .Where(q => q.Estado == "Activo").Select(q => q.IdCAI).FirstOrDefaultAsync(); if (IdCai == 0) { return(BadRequest("No existe un CAI activo para el punto de emisión")); } // _DebitNoteq.Sucursal = await _context.Branch.Where(q => q.BranchId == _DebitNote.BranchId).Select(q => q.BranchCode).FirstOrDefaultAsync(); // _DebitNoteq.Caja = await _context.PuntoEmision.Where(q=>q.IdPuntoEmision== _Invoice.IdPuntoEmision).Select(q => q.PuntoEmisionCod).FirstOrDefaultAsync(); _DebitNoteq.CAI = await _context.CAI.Where(q => q.IdCAI == IdCai).Select(q => q._cai).FirstOrDefaultAsync(); } Numalet let; let = new Numalet(); let.SeparadorDecimalSalida = "Lempiras"; let.MascaraSalidaDecimal = "00/100 "; let.ApocoparUnoParteEntera = true; _DebitNoteq.TotalLetras = let.ToCustomCardinal((_DebitNoteq.Total)).ToUpper(); _DebitNoteq = _DebitNote; _context.DebitNote.Add(_DebitNoteq); foreach (var item in _DebitNote.DebitNoteLine) { item.DebitNoteId = _DebitNote.DebitNoteId; _context.DebitNoteLine.Add(item); } await _context.SaveChangesAsync(); JournalEntry _je = new JournalEntry { Date = _DebitNoteq.DebitNoteDate, Memo = "Nota de débito de clientes", DatePosted = _DebitNoteq.DebitNoteDueDate, ModifiedDate = DateTime.Now, CreatedDate = DateTime.Now, ModifiedUser = _DebitNoteq.UsuarioModificacion, CreatedUser = _DebitNoteq.UsuarioCreacion, DocumentId = _DebitNoteq.DebitNoteId, VoucherType = 4, }; Accounting account = new Accounting(); foreach (var item in _DebitNoteq.DebitNoteLine) { account = await _context.Accounting.Where(acc => acc.AccountId == item.AccountId).FirstOrDefaultAsync(); _je.JournalEntryLines.Add(new JournalEntryLine { AccountId = Convert.ToInt32(item.AccountId), AccountName = account.AccountName, Description = account.AccountName, Credit = item.Total, Debit = 0, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now, CreatedUser = _DebitNoteq.UsuarioCreacion, ModifiedUser = _DebitNoteq.UsuarioModificacion, Memo = "Nota de débito", }); } _context.JournalEntry.Add(_je); await _context.SaveChangesAsync(); BitacoraWrite _write = new BitacoraWrite(_context, new Bitacora { IdOperacion = _DebitNote.DebitNoteId, DocType = "DebitNote", ClaseInicial = Newtonsoft.Json.JsonConvert.SerializeObject(_DebitNote, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }), ResultadoSerializado = Newtonsoft.Json.JsonConvert.SerializeObject(_DebitNote, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }), Accion = "Insert", FechaCreacion = DateTime.Now, FechaModificacion = DateTime.Now, }); await _context.SaveChangesAsync(); transaction.Commit(); } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); throw ex; } } } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); return(await Task.Run(() => BadRequest($"Ocurrio un error:{ex.Message}"))); } return(await Task.Run(() => Ok(_DebitNoteq))); }
/// <summary> /// Runs a benchmark comparing two different AIs against each other on a fixed map. /// </summary> public static void CompareAi() { var dna = new DNA(2, 2); dna.Randomize(); var map = Map.Load(@"data/map.json"); var game = GameSetup.GenerateFromDna(dna, dna, map); game.PrepareEverything(); GameInvariants.AssertMobsNotStandingOnEachother(game); IMobController c1, c2; switch (Constants.MctsBenchType) { case 0: c1 = new MctsController(game, Constants.MctsBenchIterations); c2 = new AiRandomController(game); break; case 1: c1 = new MctsController(game, Constants.MctsBenchIterations); c2 = new AiRuleBasedController(game); break; case 2: c1 = new AiRuleBasedController(game); c2 = new AiRandomController(game); break; default: throw new ArgumentException($"Invalid value of {Constants.MctsBenchType} for --MctsBenchType"); } var iterationStopwatch = new Stopwatch(); int c1Wins = 0; int c2Wins = 0; for (int i = 0; i < 1000; i++) { dna.Randomize(); iterationStopwatch.Restart(); GameSetup.OverrideGameDna(game, dna, dna); var r1 = GameEvaluator.Playout(game, c1, c2); GameSetup.OverrideGameDna(game, dna, dna); var r2 = GameEvaluator.Playout(game, c2, c1); iterationStopwatch.Stop(); Console.WriteLine(Accounting.GetStats()); c1Wins += r1.RedWins + r2.BlueWins; c2Wins += r1.BlueWins + r2.RedWins; Console.WriteLine($"{i.ToString("0000")} STATS: M2: {c1Wins}, M5: {c2Wins}, winrate: {((double)c1Wins/(c1Wins+c2Wins)).ToString("0.000")}"); } }
public static List <Accounting> ReadExcel(string fileName) { try { List <Accounting> lstAccounting = new List <Accounting>(); Boolean bCheck = true; FileInfo existingFile = new FileInfo(fileName); using (ExcelPackage package = new ExcelPackage(existingFile)) { //get the first worksheet in the workbook ExcelWorksheet worksheet = package.Workbook.Worksheets[1]; int colCount = worksheet.Dimension.End.Column; //get Column Count int rowCount = worksheet.Dimension.End.Row; //get row count for (int row = Constants.StartRow + 1; row <= rowCount; row++) { try { if (string.IsNullOrEmpty(worksheet.Cells[row, 2].Value.ToString())) { bCheck = false; } ; } catch (Exception ex) { return(lstAccounting); } if (bCheck) { var objAccounting = new Accounting(); objAccounting.Mid = worksheet.Cells[row, 2].Value?.ToString().Trim(); objAccounting.OrgName = worksheet.Cells[row, 3].Value?.ToString().Trim(); objAccounting.TxDate = worksheet.Cells[row, 4].Value?.ToString().Trim(); objAccounting.Acctno = worksheet.Cells[row, 5].Value?.ToString().Trim(); objAccounting.Qtty = worksheet.Cells[row, 6].Value?.ToString().Trim(); objAccounting.Amt = worksheet.Cells[row, 7].Value?.ToString().Trim(); objAccounting.Fee = worksheet.Cells[row, 8].Value?.ToString().Trim(); objAccounting.Vat = worksheet.Cells[row, 9].Value?.ToString().Trim(); objAccounting.OrgAmt = worksheet.Cells[row, 10].Value?.ToString().Trim(); objAccounting.FeePercent = worksheet.Cells[row, 11].Value?.ToString().Trim(); objAccounting.BranchID = worksheet.Cells[row, 12].Value?.ToString().Trim(); objAccounting.FeeMaster = worksheet.Cells[row, 13].Value?.ToString().Trim(); objAccounting.FeeJCB = worksheet.Cells[row, 14].Value?.ToString().Trim(); objAccounting.TranType = worksheet.Cells[row, 15].Value?.ToString().Trim(); objAccounting.CifNo = worksheet.Cells[row, 16].Value?.ToString().Trim(); objAccounting.TranDate = worksheet.Cells[row, 17].Value?.ToString().Trim(); objAccounting.Description = worksheet.Cells[row, 18].Value?.ToString().Trim(); objAccounting.Parameters = worksheet.Cells[row, 19].Value?.ToString().Trim(); objAccounting.CardNo = worksheet.Cells[row, 20].Value?.ToString().Trim(); objAccounting.FeeAndVat = worksheet.Cells[row, 21].Value?.ToString().Trim(); objAccounting.Currency = worksheet.Cells[row, 22].Value?.ToString().Trim(); objAccounting.PosEximNo = worksheet.Cells[row, 23].Value?.ToString().Trim(); objAccounting.PosVrbNo = worksheet.Cells[row, 24].Value?.ToString().Trim(); lstAccounting.Add(objAccounting); } } } return(lstAccounting); } catch (Exception ex) { ErrorUtils.WriteLog(ex.Message); return(null); } }