public static InvoiceItem ConvertToInvoiceItem(this InvoiceItemViewModel invoiceItemViewModel) { InvoiceItem invoiceItem = new InvoiceItem() { Id = invoiceItemViewModel.Id, Identifier = invoiceItemViewModel.Identifier, InvoiceId = invoiceItemViewModel.Invoice?.Id ?? null, Code = invoiceItemViewModel.Code, Name = invoiceItemViewModel.Name, UnitOfMeasure = invoiceItemViewModel.UnitOfMeasure, Quantity = invoiceItemViewModel.Quantity, PriceWithPDV = invoiceItemViewModel.PriceWithPDV, PriceWithoutPDV = invoiceItemViewModel.PriceWithoutPDV, Discount = invoiceItemViewModel.Discount, PDVPercent = invoiceItemViewModel.PDVPercent, PDV = invoiceItemViewModel.PDV, Amount = invoiceItemViewModel.Amount, ItemStatus = invoiceItemViewModel.ItemStatus, CurrencyCode = invoiceItemViewModel.CurrencyCode, ExchangeRate = invoiceItemViewModel.ExchangeRate, CurrencyPriceWithPDV = invoiceItemViewModel.CurrencyPriceWithPDV, CreatedById = invoiceItemViewModel.CreatedBy?.Id ?? null, CompanyId = invoiceItemViewModel.Company?.Id ?? null, CreatedAt = invoiceItemViewModel.CreatedAt, UpdatedAt = invoiceItemViewModel.UpdatedAt }; return(invoiceItem); }
public async Task <IActionResult> GetByNumber(int?number) { if (!number.HasValue) { return(StatusCode(400, "Invalid parameter(s).")); } //Get data var data = await _repo.GetById(number.Value); if (data == null) { return(StatusCode(500, "Invoice item with item number '" + number.Value + "' could not be found.")); } //Convert to viewmodel var result = new InvoiceItemViewModel { InvoiceNumber = data.InvoiceNumber, Name = data.Name, Price = data.Price, Description = data.Description, Tax = data.Tax, Quantity = data.Quantity, ItemNumber = data.ItemNumber }; return(Ok(result)); }
private static InvoiceItemViewModel Read(SqliteDataReader query) { int counter = 0; InvoiceItemViewModel dbEntry = new InvoiceItemViewModel(); dbEntry.Id = SQLiteHelper.GetInt(query, ref counter); dbEntry.Identifier = SQLiteHelper.GetGuid(query, ref counter); dbEntry.Invoice = SQLiteHelper.GetInvoice(query, ref counter); dbEntry.Code = SQLiteHelper.GetString(query, ref counter); dbEntry.Name = SQLiteHelper.GetString(query, ref counter); dbEntry.UnitOfMeasure = SQLiteHelper.GetString(query, ref counter); dbEntry.Quantity = SQLiteHelper.GetDecimal(query, ref counter); dbEntry.PriceWithPDV = SQLiteHelper.GetDecimal(query, ref counter); dbEntry.PriceWithoutPDV = SQLiteHelper.GetDecimal(query, ref counter); dbEntry.Discount = SQLiteHelper.GetDecimal(query, ref counter); dbEntry.PDVPercent = SQLiteHelper.GetDecimal(query, ref counter); dbEntry.PDV = SQLiteHelper.GetDecimal(query, ref counter); dbEntry.Amount = SQLiteHelper.GetDecimal(query, ref counter); dbEntry.ItemStatus = SQLiteHelper.GetInt(query, ref counter); dbEntry.CurrencyCode = SQLiteHelper.GetString(query, ref counter); dbEntry.ExchangeRate = SQLiteHelper.GetDoubleNullable(query, ref counter); dbEntry.CurrencyPriceWithPDV = SQLiteHelper.GetDoubleNullable(query, ref counter); dbEntry.IsSynced = SQLiteHelper.GetBoolean(query, ref counter); dbEntry.UpdatedAt = SQLiteHelper.GetDateTime(query, ref counter); dbEntry.CreatedBy = SQLiteHelper.GetCreatedBy(query, ref counter); dbEntry.Company = SQLiteHelper.GetCompany(query, ref counter); return(dbEntry); }
public Invoice_Item_AddEdit(InvoiceViewModel invoice) { invoiceService = DependencyResolver.Kernel.Get <IInvoiceService>(); InitializeComponent(); this.DataContext = this; CurrentInvoice = invoice; CurrentInvoiceItemForm = new InvoiceItemViewModel(); CurrentInvoiceItemForm.Identifier = Guid.NewGuid(); CurrentInvoiceItemForm.ItemStatus = ItemStatus.Added; if (CurrentInvoice.Vat?.Amount != null) { CurrentInvoiceItemForm.PDVPercent = CurrentInvoice.Vat.Amount; } if (CurrentInvoice.Discount?.Amount != null) { CurrentInvoiceItemForm.Discount = CurrentInvoice.Discount.Amount; } if (CurrentInvoice.CurrencyExchangeRate != null) { CurrentInvoiceItemForm.ExchangeRate = CurrentInvoice.CurrencyExchangeRate; } Thread displayThread = new Thread(() => DisplayInvoiceItemData()); displayThread.IsBackground = true; displayThread.Start(); btnAddNote.Focus(); }
public InvoiceItemViewModel Map(InvoiceItem invoice_item) { var invoice_item_data = new InvoiceItemViewModel() { InvoiceKey = invoice_item.InvoiceKey, InvoiceItemSeq = invoice_item.InvoiceItemSeq, ProductKey = invoice_item.ProductKey, ProductName = invoice_item.ProductName, ProductDesc = invoice_item.ProductDesc, Quantity = invoice_item.InvoiceItemQuantity, InvoiceItemShipAddress = Map(invoice_item.OrderItemShipToAddress), InvoiceItemBillAddress = Map(invoice_item.OrderItemBillToAddress), //InvoiceItemShipDate = invoice_item.InvoiceItemShipDate, //InvoiceItemCompleteDate = invoice_item.InvoiceItemCompleteDate, InvoiceItemPrice = invoice_item.ItemPricePer, InvoiceLineTotal = invoice_item.InvoiceItemLineSum, InvoiceItemStatus = invoice_item.InvoiceItemStatus.ToString(), //Account Rep AccountRepName = invoice_item.AccountRep.PersonFullNameFML, SalesRepName = invoice_item.SalesRep.PersonFullNameFML }; //Console.WriteLine("MapInvoiceItemToInvoiceItemData"); return(invoice_item_data); }
public InvoiceItemWindow(InvoiceItemViewModel viewModel) { InitializeComponent(); ViewModel = viewModel; DataContext = ViewModel; }
public InvoiceItemResponse Create(InvoiceItemViewModel InvoiceItem) { InvoiceItemResponse response = new InvoiceItemResponse(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); SqliteCommand insertCommand = db.CreateCommand(); insertCommand.CommandText = SqlCommandInsertPart; try { insertCommand = AddCreateParameters(insertCommand, InvoiceItem); insertCommand.ExecuteNonQuery(); } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; return(response); } db.Close(); response.Success = true; return(response); } }
private SqliteCommand AddCreateParameters(SqliteCommand insertCommand, InvoiceItemViewModel InvoiceItem) { insertCommand.Parameters.AddWithValue("@ServerId", InvoiceItem.Id); insertCommand.Parameters.AddWithValue("@Identifier", InvoiceItem.Identifier); insertCommand.Parameters.AddWithValue("@InvoiceId", ((object)InvoiceItem.Invoice?.Id) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@InvoiceIdentifier", ((object)InvoiceItem.Invoice?.Identifier) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@InvoiceCode", ((object)InvoiceItem.Invoice?.Code) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@Code", ((object)InvoiceItem.Code) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@Name", ((object)InvoiceItem.Name) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@UnitOfMeasure", ((object)InvoiceItem.UnitOfMeasure) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@Quantity", ((object)InvoiceItem.Quantity) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@PriceWithPDV", ((object)InvoiceItem.PriceWithPDV) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@PriceWithoutPDV", ((object)InvoiceItem.PriceWithoutPDV) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@Discount", ((object)InvoiceItem.Discount) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@PDVPercent", ((object)InvoiceItem.PDVPercent) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@PDV", ((object)InvoiceItem.PDV) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@Amount", ((object)InvoiceItem.Amount) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@ItemStatus", ((object)InvoiceItem.ItemStatus) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@CurrencyCode", ((object)InvoiceItem.CurrencyCode) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@ExchangeRate", ((object)InvoiceItem.ExchangeRate) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@CurrencyPriceWithPDV", ((object)InvoiceItem.CurrencyPriceWithPDV) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@IsSynced", InvoiceItem.IsSynced); insertCommand.Parameters.AddWithValue("@UpdatedAt", ((object)InvoiceItem.UpdatedAt) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@CreatedById", MainWindow.CurrentUser.Id); insertCommand.Parameters.AddWithValue("@CreatedByName", MainWindow.CurrentUser.FirstName + " " + MainWindow.CurrentUser.LastName); insertCommand.Parameters.AddWithValue("@CompanyId", MainWindow.CurrentCompany.Id); insertCommand.Parameters.AddWithValue("@CompanyName", MainWindow.CurrentCompany.CompanyName); return(insertCommand); }
public async Task <IActionResult> GetByName(string name) { if (String.IsNullOrEmpty(name)) { return(StatusCode(400, "Invalid parameter(s).")); } //Get data var data = await _repo.GetByName(name); if (data == null) { return(StatusCode(500, "Invoice item named '" + name + "' could not be found.")); } //Convert to viewmodel var result = new InvoiceItemViewModel { InvoiceNumber = data.InvoiceNumber, Name = data.Name, Price = data.Price, Description = data.Description, Tax = data.Tax, Quantity = data.Quantity, ItemNumber = data.ItemNumber }; return(Ok(result)); }
public static InvoiceItemViewModel ConvertToInvoiceItemViewModelLite(this InvoiceItem invoiceItem) { InvoiceItemViewModel invoiceItemViewModel = new InvoiceItemViewModel() { Id = invoiceItem.Id, Identifier = invoiceItem.Identifier, Code = invoiceItem.Code, Name = invoiceItem.Name, UnitOfMeasure = invoiceItem.UnitOfMeasure, Quantity = invoiceItem.Quantity, PriceWithPDV = invoiceItem.PriceWithPDV, PriceWithoutPDV = invoiceItem.PriceWithoutPDV, Discount = invoiceItem.Discount, PDVPercent = invoiceItem.PDVPercent, PDV = invoiceItem.PDV, Amount = invoiceItem.Amount, ItemStatus = invoiceItem.ItemStatus, CurrencyCode = invoiceItem.CurrencyCode, ExchangeRate = invoiceItem.ExchangeRate, CurrencyPriceWithPDV = invoiceItem.CurrencyPriceWithPDV, IsActive = invoiceItem.Active, UpdatedAt = invoiceItem.UpdatedAt, CreatedAt = invoiceItem.CreatedAt }; return(invoiceItemViewModel); }
public async Task <IActionResult> Create(int id, [Bind] InvoiceItemViewModel item) { var result = await _service.CreateInvoiceItem(id, item); if (result != null) { return(RedirectToAction("Index", "Item", new { id = id })); } return(null); }
public async Task <IActionResult> Details(int id) { InvoiceItem invoiceItem = await _context.InvoiceItems.Include(o => o.Invoice).FirstOrDefaultAsync(o => o.Id == id); if (invoiceItem == null) { return(NotFound()); } InvoiceItemViewModel invoiceItemVM = _mapper.Map <InvoiceItemViewModel>(invoiceItem); return(View(invoiceItemVM)); }
public bool SendApprovedInvoice(InvoiceItemViewModel model) { try { var subject = "Reminder for Payment of Insurance Policy Balance"; var message = "Dear " + @model.ClientName + "," + "<br /><br /><br />" + "<strong>Re: REMINDER FOR PAYMENT OF INSURANCE POLICY BALANCE</strong><br />" + "<p>We are contacting you with regards to a new invoice that has been created " + "on your account.</p>" + "<p>Please pay the balance of Php " + @model.TotalAmountDue + " as soon as you receive this notice.</p>" + "<p>The details of the invoice are as follows:<br /><br />" + "<strong>Invoice Issue Date: </strong>" + @model.IssueDate.ToString("MMMM dd, yyyy") + "<br />" + "<strong>Invoice Number: </strong>" + @model.InvoiceNumber + "<br />" + "<strong>Policy Number: </strong>" + @model.PolicyNumber + "<br />" + "<strong>Company: </strong>" + @model.CompanyName + "</p>" + "<strong>Particulars</strong><br />"; foreach (var item in model.Particulars) { message += (@item.ParticularTypeName + ": Php" + @item.ParticularAmount + "<br />"); } message += "<br /><strong>TOTAL AMOUNT DUE: </strong> Php" + @model.TotalAmountDue + "<br />" + "<p>If you have sent your payment, please ignore this letter.</p>" + "<p>We look forward to conducting future business with you.</p>" + "<p>Thank you.</p>" + "<br />MANILA OVERSEAS COMMERCIAL, INC." + "<p>201 Capt. Roja St., Addition Hills<br />" + "San Juan City<br />" + "Email: [email protected]<br />" + "Tels. 570-4578; 570-4579 & 570-4580; 463-7871<br />" + "Fax No. 570-5191" + "</p>"; var destinations = GetEmailAddresses(model.ClientEmail); Send(destinations, subject, message, null); return(true); } catch (Exception) { return(false); } }
private void btnCancelNote_Click(object sender, RoutedEventArgs e) { CurrentInvoiceItemForm = new InvoiceItemViewModel(); CurrentInvoiceItemForm.Identifier = Guid.NewGuid(); CurrentInvoiceItemForm.ItemStatus = ItemStatus.Added; if (CurrentInvoice.Vat?.Amount != null) { CurrentInvoiceItemForm.PDVPercent = CurrentInvoice.Vat.Amount; } if (CurrentInvoice.Discount?.Amount != null) { CurrentInvoiceItemForm.Discount = CurrentInvoice.Discount.Amount; } if (CurrentInvoice.CurrencyExchangeRate != null) { CurrentInvoiceItemForm.ExchangeRate = CurrentInvoice.CurrencyExchangeRate; } }
public InvoiceItemListResponse GetInvoiceItemsByInvoice(int companyId, Guid InvoiceIdentifier) { InvoiceItemListResponse response = new InvoiceItemListResponse(); List <InvoiceItemViewModel> InvoiceItems = new List <InvoiceItemViewModel>(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); try { SqliteCommand selectCommand = new SqliteCommand( SqlCommandSelectPart + "FROM InvoiceItems " + "WHERE InvoiceIdentifier = @InvoiceIdentifier " + "AND CompanyId = @CompanyId " + "ORDER BY IsSynced, Id DESC;", db); selectCommand.Parameters.AddWithValue("@InvoiceIdentifier", InvoiceIdentifier); selectCommand.Parameters.AddWithValue("@CompanyId", companyId); SqliteDataReader query = selectCommand.ExecuteReader(); while (query.Read()) { InvoiceItemViewModel dbEntry = Read(query); InvoiceItems.Add(dbEntry); } } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; response.InvoiceItems = new List <InvoiceItemViewModel>(); return(response); } db.Close(); } response.Success = true; response.InvoiceItems = InvoiceItems; return(response); }
private void BtnDelete_Click(object sender, RoutedEventArgs e) { var response = new InvoiceItemSQLiteRepository().SetStatusDeleted(CurrentInvoiceItemDG.Identifier); if (response.Success) { MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Stavka_je_uspešno_obrisanaUzvičnik")); CurrentInvoiceItemForm = new InvoiceItemViewModel() { Discount = CurrentInvoice?.Discount?.Amount ?? 0 }; CurrentInvoiceItemForm.Identifier = Guid.NewGuid(); CurrentInvoiceItemForm.ItemStatus = ItemStatus.Added; CurrentInvoiceItemForm.IsSynced = false; if (CurrentInvoice.Vat?.Amount != null) { CurrentInvoiceItemForm.PDVPercent = CurrentInvoice.Vat.Amount; } if (CurrentInvoice.Discount?.Amount != null) { CurrentInvoiceItemForm.Discount = CurrentInvoice.Discount.Amount; } if (CurrentInvoice.CurrencyExchangeRate != null) { CurrentInvoiceItemForm.ExchangeRate = CurrentInvoice.CurrencyExchangeRate; } CurrentInvoiceItemDG = null; InvoiceCreatedUpdated(); Thread displayThread = new Thread(() => DisplayInvoiceItemData()); displayThread.IsBackground = true; displayThread.Start(); } else { MainWindow.ErrorMessage = response.Message; } }
public InvoiceItem Map(InvoiceItemViewModel invoice_item_vm) { var address_proxy = _service_fact.CreateClient <IAddressService>(); var product_proxy = _service_fact.CreateClient <IProductService>(); var invoice_proxy = _service_fact.CreateClient <IInvoiceService>(); var employee_service = _service_fact.CreateClient <IEmployeeService>(); var type_service = _service_fact.CreateClient <ITypeService>(); var orderItem = new InvoiceItem() { InvoiceItemKey = invoice_item_vm.InvoiceItemKey, InvoiceKey = invoice_item_vm.InvoiceKey, InvoiceItemSeq = invoice_item_vm.InvoiceItemSeq, ProductKey = invoice_item_vm.ProductKey, ProductName = invoice_item_vm.ProductName, ProductDesc = invoice_item_vm.ProductDesc, InvoiceItemQuantity = invoice_item_vm.Quantity, //InvoiceItemShipToAddress = order_item_data.ShiptoAddrKey, OrderItemShipToAddress = address_proxy.GetAddress(invoice_item_vm.InvoiceItemShipAddress.AddressKey), //InvoiceItemBillToAddress = order_item_data.BilltoAddrKey, OrderItemBillToAddress = address_proxy.GetAddress(invoice_item_vm.InvoiceItemBillAddress.AddressKey), //InvoiceItemShipDate = invoice_item_vm.InvoiceItemShipDate, //InvoiceItemCompleteDate = invoice_item_vm.InvoiceItemCompleteDate, ItemPricePer = invoice_item_vm.InvoiceItemPrice, InvoiceItemLineSum = invoice_item_vm.InvoiceLineTotal, InvoiceItemStatus = (QIQOInvoiceItemStatus)type_service.GetInvoiceItemStatusList() .Where(key => key.InvoiceItemStatusName == invoice_item_vm.InvoiceItemStatus) .FirstOrDefault().InvoiceItemStatusKey, //Product InvoiceItemProduct = product_proxy.GetProduct(invoice_item_vm.ProductKey), //Account Rep AccountRep = employee_service.GetAccountRepsByCompany(1)[0], //Sales Rep SalesRep = employee_service.GetSalesRepsByCompany(1)[0] }; return(orderItem); }
public async Task <IActionResult> Create(InvoiceItemViewModel invoiceItemVM) { if (!ModelState.IsValid) { return(View(invoiceItemVM)); } Invoice invoice = await _context.Invoices.FirstOrDefaultAsync(o => o.Id == invoiceItemVM.InvoiceId); if (invoice.GetInvoiceIsPaid()) { return(ErrorInvoicePaid()); } InvoiceItem invoiceItem = _mapper.Map <InvoiceItem>(invoiceItemVM); invoiceItem.Invoice = invoice; _context.InvoiceItems.Add(invoiceItem); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(HomeController.Index), new { invoiceId = invoiceItemVM.InvoiceId })); }
public InvoiceItemResponse GetInvoiceItem(Guid identifier) { InvoiceItemResponse response = new InvoiceItemResponse(); InvoiceItemViewModel InvoiceItem = new InvoiceItemViewModel(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); try { SqliteCommand selectCommand = new SqliteCommand( SqlCommandSelectPart + "FROM InvoiceItems " + "WHERE Identifier = @Identifier;", db); selectCommand.Parameters.AddWithValue("@Identifier", identifier); SqliteDataReader query = selectCommand.ExecuteReader(); if (query.Read()) { InvoiceItemViewModel dbEntry = Read(query); InvoiceItem = dbEntry; } } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; response.InvoiceItem = new InvoiceItemViewModel(); return(response); } db.Close(); } response.Success = true; response.InvoiceItem = InvoiceItem; return(response); }
public async Task <IActionResult> Edit(int id, InvoiceItemViewModel invoiceItemVM) { if (id != invoiceItemVM.Id) { return(NotFound()); } if (!ModelState.IsValid) { return(View(invoiceItemVM)); } Invoice invoice = await _context.Invoices.FirstOrDefaultAsync(o => o.Id == invoiceItemVM.InvoiceId); if (invoice.GetInvoiceIsPaid()) { return(ErrorInvoicePaid()); } try { InvoiceItem invoiceItem = _mapper.Map <InvoiceItem>(invoiceItemVM); invoiceItem.Invoice = invoice; _context.InvoiceItems.Update(invoiceItem); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!await InvoiceItemExistsAsync(invoiceItemVM.Id)) { return(NotFound()); } throw; } return(RedirectToAction(nameof(HomeController.Index), new { invoiceId = invoiceItemVM.InvoiceId })); }
public async Task <IActionResult> Update([FromBody] InvoiceItemViewModel model) { if (model == null) { return(StatusCode(400, "Invalid parameter(s).")); } InvoiceItem invoiceItem = new InvoiceItem { InvoiceNumber = model.InvoiceNumber, ItemNumber = model.ItemNumber, Name = model.Name, Description = model.Description, Tax = model.Tax, Price = model.Price, Quantity = model.Quantity }; //Swap comma with dots var priceString = invoiceItem.Price.ToString().Replace(".", ","); invoiceItem.Price = Convert.ToDecimal(priceString); //Update invoice item var data = await _repo.Update(invoiceItem); if (data == null) { return(StatusCode(500, "A problem occured while updating the record. Please try again!")); } var result = new InvoiceItemViewModel(); result.SetProperties(data); return(Ok(result)); }
private void btnEditItem_Click(object sender, RoutedEventArgs e) { CurrentInvoiceItemForm = new InvoiceItemViewModel(); CurrentInvoiceItemForm.Identifier = CurrentInvoiceItemDG.Identifier; CurrentInvoiceItemForm.ItemStatus = ItemStatus.Edited; CurrentInvoiceItemForm.IsSynced = CurrentInvoiceItemDG.IsSynced; CurrentInvoiceItemForm.Code = CurrentInvoiceItemDG.Code; CurrentInvoiceItemForm.Name = CurrentInvoiceItemDG.Name; CurrentInvoiceItemForm.UnitOfMeasure = CurrentInvoiceItemDG.UnitOfMeasure; CurrentInvoiceItemForm.Quantity = CurrentInvoiceItemDG.Quantity; CurrentInvoiceItemForm.PriceWithPDV = CurrentInvoiceItemDG.PriceWithPDV; CurrentInvoiceItemForm.PriceWithoutPDV = CurrentInvoiceItemDG.PriceWithoutPDV; CurrentInvoiceItemForm.Discount = CurrentInvoiceItemDG.Discount; CurrentInvoiceItemForm.CurrencyCode = CurrentInvoiceItemDG.CurrencyCode; CurrentInvoiceItemForm.PDVPercent = CurrentInvoiceItemDG.PDVPercent; CurrentInvoiceItemForm.PDV = CurrentInvoiceItemDG.PDV; CurrentInvoiceItemForm.Amount = CurrentInvoiceItemDG.Amount; CurrentInvoiceItemForm.CurrencyPriceWithPDV = CurrentInvoiceItemDG.CurrencyPriceWithPDV; CurrentInvoiceItemForm.ExchangeRate = CurrentInvoice?.CurrencyExchangeRate; CurrentInvoiceItemForm.UpdatedAt = CurrentInvoiceItemDG.UpdatedAt; }
private InvoiceItemViewModel GetInvoiceItemModel(Invoice invoice) { var itemModel = new InvoiceItemViewModel(invoice); return(itemModel); }
private void btnAddNote_Click(object sender, RoutedEventArgs e) { #region Validation //if (CurrentInvoiceItemForm.Note == null) //{ // MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Napomena")); // return; //} #endregion Thread th = new Thread(() => { SubmitButtonEnabled = false; CurrentInvoiceItemForm.Invoice = CurrentInvoice; CurrentInvoiceItemForm.Company = new CompanyViewModel() { Id = MainWindow.CurrentCompanyId }; CurrentInvoiceItemForm.CreatedBy = new UserViewModel() { Id = MainWindow.CurrentUserId }; new InvoiceItemSQLiteRepository().Delete(CurrentInvoiceItemForm.Identifier); var response = new InvoiceItemSQLiteRepository().Create(CurrentInvoiceItemForm); if (!response.Success) { MainWindow.ErrorMessage = response.Message; CurrentInvoiceItemForm = new InvoiceItemViewModel(); CurrentInvoiceItemForm.Identifier = Guid.NewGuid(); CurrentInvoiceItemForm.ItemStatus = ItemStatus.Added; CurrentInvoiceItemForm.IsSynced = false; if (CurrentInvoice.Vat?.Amount != null) { CurrentInvoiceItemForm.PDVPercent = CurrentInvoice.Vat.Amount; } if (CurrentInvoice.Discount?.Amount != null) { CurrentInvoiceItemForm.Discount = CurrentInvoice.Discount.Amount; } if (CurrentInvoice.CurrencyExchangeRate != null) { CurrentInvoiceItemForm.ExchangeRate = CurrentInvoice.CurrencyExchangeRate; } return; } CurrentInvoiceItemForm = new InvoiceItemViewModel() { Discount = CurrentInvoice?.Discount?.Amount ?? 0 }; CurrentInvoiceItemForm.Identifier = Guid.NewGuid(); CurrentInvoiceItemForm.ItemStatus = ItemStatus.Added; CurrentInvoiceItemForm.IsSynced = false; if (CurrentInvoice.Vat?.Amount != null) { CurrentInvoiceItemForm.PDVPercent = CurrentInvoice.Vat.Amount; } if (CurrentInvoice.Discount?.Amount != null) { CurrentInvoiceItemForm.Discount = CurrentInvoice.Discount.Amount; } if (CurrentInvoice.CurrencyExchangeRate != null) { CurrentInvoiceItemForm.ExchangeRate = CurrentInvoice.CurrencyExchangeRate; } //PriceWithPDV * Discount / 100 InvoiceCreatedUpdated(); DisplayInvoiceItemData(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { txtName.Focus(); }) ); SubmitButtonEnabled = true; }); th.IsBackground = true; th.Start(); }
public InvoiceItemView() { InitializeComponent(); DataContext = new InvoiceItemViewModel(); }
public ActionResult CreateEdit(int?id, int?policyId, string returnUrl) { InvoiceItemViewModel vm; if (id != null) //Edit { vm = Uow.Invoices.GetAll() .Where(i => i.Id == (int)id) .Include(i => i.Particulars) .ProjectTo <InvoiceItemViewModel>() .FirstOrDefault(); if (vm.DueDate.Year < 1980) { vm.DueDate = DateTime.Now; } if (!(vm.StatusName.ToLower() == "pending" || vm.StatusName.ToLower() == "rejected")) { //Invoice has been approved. Premium and Endorsement Number are fixed at this point. var premiumFromParticular = vm.Particulars.Where(p => p.ParticularTypeName.ToLower() == "premium") .FirstOrDefault(); if (premiumFromParticular != null) { vm.Premium = premiumFromParticular.ParticularAmount; } //For Particular Readonly Values vm.IsReadOnlyState = true; } else { //Invoice not yet approved. Endorsement Number can still be modified. var policy = Uow.Policies.GetAll() .Where(p => p.Id == vm.PolicyId) .Include(p => p.Endorsements) .FirstOrDefault(); if (policy != null && policy.Endorsements != null && policy.Endorsements.Count > 0) { var latestEndorsementNumber = policy.Endorsements .OrderByDescending(e => e.EffectiveDate) .FirstOrDefault() .EndorsementNumber; vm.EndorsementNumber = latestEndorsementNumber; } //For Particular Readonly Values vm.IsReadOnlyState = false; } if (vm.StatusName.ToLower() == "unpaid") { vm.PaidDate = DateTime.Now; } var policies = Uow.Policies.GetAll() .Where(p => p.ClientId == vm.ClientId) .ProjectTo <ClientPoliciesListModel>() .ToList(); vm.Policies = policies; vm.Clients = ListProviderSvc.GetClientsWithPoliciesSimpleList(); vm.IsFromPolicy = false; } else //Create { vm = new InvoiceItemViewModel { StatusName = "New", IssueDate = DateTime.Now, DueDate = DateTime.Now.AddMonths(1), IsFromPolicy = false }; if (policyId != null) { vm.IsFromPolicy = true; vm.Policies = Uow.Policies.GetAll() .Where(p => p.Id == policyId) .ProjectTo <ClientPoliciesListModel>() .ToList(); vm.PolicyId = vm.Policies[0].Id; vm.CompanyName = vm.Policies[0].CompanyName; vm.EndorsementNumber = vm.Policies[0].LatestEndorsementNumber; vm.Premium = vm.Policies[0].Premium; vm.Rebate = vm.Policies[0].Rebate; var item = Uow.Policies.GetAll() .Where(p => p.Id == policyId) .Select(p => p.Client) .FirstOrDefault(); var client = new ClientSimple { Id = item.Id, Email = item.Email, AccountNumber = item.AccountNumber }; if (item.IsOrganization) { client.ClientName = item.OrganizationName; } else { client.ClientName = item.LastName + ", " + item.FirstName; } vm.Clients = new List <ClientSimple>(); vm.Clients.Add(client); vm.ClientId = client.Id; vm.ClientName = client.ClientName; vm.AccountNumber = client.AccountNumber; } else { vm.Clients = ListProviderSvc.GetClientsWithPoliciesSimpleList(); } } vm.ReturnUrl = returnUrl; vm.ParticularTypesList = ListProviderSvc.GetParticularTypes(); return(View(vm)); }