public void Create(InvoiceViewModel model) { var entity = mapper.Map(model, new Invoice()); invoiceRepository.Add(entity); invoiceRepository.SaveChanges(); }
private void button1_Click(object sender, EventArgs e) { var cursor = Cursor; Cursor = Cursors.WaitCursor; string Edi = "UNH+1+INVOIC:D:96A:UN:EAN008'BGM+380+432097+9'DTM+137:19971008:102'NAD+SU+4012345500004::9++Firma ABC:::::+ul. Baby Jagi 1:::+Poznań++60–250+PL'RFF+VA:7770020410'NAD+BY+4012345500004::9++Firma ABC:::::+ul. Baby Jagi 1:::+Poznań++60–250+PL'RFF+VA:7770020410'NAD+DP+4012345500004::9++Firma ABCD:::::+ul. Baby Jagi 1:::+Poznań++60–250+PL'PAT+1'DTM+13:19970831:102'LIN+1++4000862141404:EU'IMD+C+name+RC::9:nazwa towaru/uslugi'QTY+47:40'MOA+66:580:PLN'PRI+AAA:14,50'TAX+7+VAT+++:::21+S'LIN+2++4000862141404:EU'IMD+C+name2+RC::9:nazwa towaru/uslugi'QTY+47:40'MOA+66:580:PLN'PRI+AAA:14,50'TAX+7+VAT+++:::21+S'UNS+S'CNT+2:120'MOA+77:45612,20'MOA+79:45612,20'MOA+124:45612,20'MOA+125:45612,20'TAX+7+VAT+++:::22+S'MOA+79:15243,32'MOA+124:3353,53'TAX+7+VAT+++:::21+S'UNT+84+1'"; InvoiceModel m = _invoice.EdiDecode(Edi); _invoice.Add(m); Cursor = cursor; }
public int CreateInvoice(Invoice invoice, ref Error error) { _validateInvoiceForm(invoice, ref error); if (error.ErrorCode != ErrorCode.OKAY) { return(-1); } var invoiceId = _invoiceRepository.Add(invoice.MapToEntity()); return(invoiceId); }
[ProducesResponseType(StatusCodes.Status500InternalServerError)] // if something unexpectedly went wrong with the database or http request/response public async Task <ActionResult <Furs2Feathers.Domain.Models.Invoice> > PostInvoice(Furs2Feathers.Domain.Models.Invoice invoice) { invoiceRepo.Add(invoice); await invoiceRepo.SaveChangesAsync(); return(CreatedAtAction("GetInvoice", new { id = invoice.InvoiceId }, invoice)); }
private async Task HandleCreateInvoice(Infrastructure.Commands.V1.Invoice.CreateInvoice c) { Invoice newInvoice = null; try { newInvoice = new Invoice(c.InvoiceNumber, c.ClientName, c.TaxPayerIdentificationNumber, c.AuthorizationId); } catch (Exception e) { if (newInvoice == null) { throw new ArgumentException("There was a problem creating the Invoice"); } } try { await _invoiceRepository.Add(newInvoice); await _unitOfWork.Commit(); } catch (Exception e) { throw new Exception("Could not save the new Invoice", e); } }
public void ExecuteBillCycleRun(BillCycle billCycle) { var noOfCustomersInvoiced = 0; decimal totalInvoiced = 0.0m; OnBillCycleRunChanged(true, 0); var customers = GetCustomersToInvoice(); foreach (var customer in customers) { var invoice = CreateInvoice(billCycle, customer); AddCustomerActiveContractsToInvoiceAndUpdateAccounts(invoice, customer); var prevBal = _transactionsService.GetBalanceForCustomer(invoice.CustomerId); if (invoice.InvoiceItems.Count > 0 || prevBal != 0) { invoice.PreviousBalance = prevBal; _invoiceRepository.Add(invoice); totalInvoiced += invoice.InvoicedTotal; noOfCustomersInvoiced++; OnBillCycleRunChanged(true, noOfCustomersInvoiced); } } AddBillCycleRun(billCycle, noOfCustomersInvoiced, totalInvoiced); UpdateLastBillCycle(billCycle); OnBillCycleRunChanged(false, noOfCustomersInvoiced); }
public int Add(InvoiceRegisterCommand command) { var invoice = Mapper.Map <InvoiceRegisterCommand, Invoice>(command); var newInvoice = _invoiceRepository.Add(invoice); return(newInvoice.Id); }
public async Task <IActionResult> CreateInvoice([FromBody] InvoiceSaveResource invoiceResource) { if (!ModelState.IsValid) { return(BadRequest()); } var invoice = mapper.Map <InvoiceSaveResource, Invoice>(invoiceResource); invoice.User = userManager.GetUserAsync(HttpContext.User).Result; invoice.TimeIssued = DateTime.Now; try { repository.Add(invoice); await unitOfWork.CompleteAsync(); invoice = await repository.GetInvoice(invoice.ID); var result = mapper.Map <Invoice, InvoiceResource>(invoice); return(Created(nameof(GetInvoice), result)); } catch { return(BadRequest()); } }
public List <Invoice> GetAllInvoices(long citizenServiceNumber) { HttpResponseMessage response = RestHelper.AasHttpClient().GetAsync($"invoices/" + citizenServiceNumber).Result; response.EnsureSuccessStatusCode(); var foundInvoices = response.Content.ReadAsStringAsync().Result; var invoiceModels = JsonConvert.DeserializeObject <List <RestInvoiceModel> >(foundInvoices); List <Invoice> foundInvoicesJson = new List <Invoice>(); invoiceModels.ForEach(i => foundInvoicesJson.Add(new Invoice() { invoiceNr = i.invoiceNr, paymentStatus = (PaymentStatus)Enum.Parse(typeof(PaymentStatus), i.paymentStatus), period = i.date, totalAmount = i.totalAmount })); foundInvoicesJson.ForEach(i => { if (_repo.GetSpecificInvoice(i.invoiceNr) == null) { _repo.Add(i); } }); return(foundInvoicesJson); }
/// <summary> /// Add new invoice /// </summary> /// <param name="obj">invoice</param> /// <returns></returns> public ApiResponseViewModel Add(Invoice obj) { var result = new Invoice(); var response = new ApiResponseViewModel { Code = CommonConstants.ApiResponseSuccessCode, Message = null, Result = null }; try { var currentDate = DateTime.Now; obj.InvoiceCode = "HD" + currentDate.Year + "" + currentDate.Month + "" + currentDate.Day + "" + currentDate.Hour + "" + currentDate.Minute; obj.CreatedDate = DateTime.Now; result = _InvoiceRepository.Add(obj); _unitOfWork.Commit(); response.Message = CommonConstants.AddSuccess; response.Result = result; } catch (Exception ex) { response.Code = CommonConstants.ApiResponseExceptionCode; response.Message = CommonConstants.ErrorMessage + " " + ex.Message; } return(response); }
public void AddInvoice(Invoice invoice) { if (invoice == null) { throw new ArgumentException("invoice"); } ValidateInvoice(invoice); _invoiceRepository.Add(invoice); }
public Task <Unit> Handle(InvoiceCreatedEvent @event, CancellationToken cancellationToken) { var invoice = Invoice.CreateEmpty(); invoice.Apply(@event); invoiceRepository.Add(invoice); Save(@event); return(Unit.Task); }
public int AddInvoiceRecord(DLModel.Invoice modelInvoice) { if (_invoiceRepostory.GetAll(Inv => Inv.FileID == modelInvoice.FileID && Inv.InvoiceNumber == modelInvoice.InvoiceNumber).Count() > 0) { return(0); // means Invoice number allready exist for same file Id } else { return(_invoiceRepostory.Add((DLModel.Invoice) new DLModel.Invoice().InjectFrom(modelInvoice)).InvoiceID); } }
public Task <object> Handle(AddNewInvoiceCommand command, CancellationToken cancellationToken) { if (!command.IsValid()) { NotifyValidationErrors(command); } else { List <InvoiceItem> items = new List <InvoiceItem>(); foreach (InvoiceItemModel invoiceItem in command.Items) { InvoiceItem item = new InvoiceItem ( null, new Entities.Product(new Identity((uint)invoiceItem.ProductID), null, null, null, null, null, null, null), new Entities.Unit(new Identity((uint)invoiceItem.UnitID), null), new Price(invoiceItem.Price), new Note(invoiceItem.Note), new Quantity(invoiceItem.Quantity), new Weight(invoiceItem.Weight), new Price(invoiceItem.TotalPrice), new Deliveried(false), new Quantity(0) ); items.Add(item); } Entities.Invoice Invoice = new Entities.Invoice ( null, new Entities.Customer((uint)command.CustomerID, null, null, null, null, null, null, null, null), new DeliveryTime(command.DeliveryTime), new Price(command.TotalPrice), new Note(command.Note), new Weight(command.WeightTotal), new Code(command.Code), items ); InvoiceModel model = _InvoiceRepository.Add(Invoice); if (model != null) { //send sms CustomerModel customer = _CustomerRepository.Get(command.CustomerID); if (customer != null) { string message = "Bạn vừa đặt hàng thành công trên avita. Mã đơn hàng của bạn là: " + Invoice.Code + ". Vui lòng truy cập fanpage để xem tình trạng đơn hàng"; SendSMS.SendSMSCommon.SendSMS(message, "+84" + customer.PhoneNumber.Substring(1)); } return(Task.FromResult(model.ID as object)); } _bus.RaiseEvent(new DomainNotification("Invoice", "Server error", NotificationCode.Error)); } return(Task.FromResult(null as object)); }
public void AddInvoice(Invoice invoice) { string YY = DateTime.Now.Year.ToString().Substring(2, 2); invoice.requestID = "IN" + YY + (_invoiceRepository.GetAll().LastOrDefault().Id + 1).ToString("0000"); invoice.isDelete = false; invoice.IsCDS = false; invoice.URL = ""; invoice.MsscID = _msscRepository.GetAll().FirstOrDefault().Id; _invoiceRepository.Add(invoice); _unitOfWork.Commit(); }
public ActionResult Create(InvoiceEditModel model) { if (ModelState.IsValid) { model.CompanyID = 1; Mapper.CreateMap <InvoiceEditModel, Invoice>(); var dbModel = Mapper.Map <Invoice>(model); _invoices.Add(dbModel); _unitOfWork.Save(); return(RedirectToAction("Index")); } return(View(model)); }
public InvoiceViewModel InsertInvoiceView([FromBody] InvoiceViewModel invoiceViewModel) { var result = _invoiceRepository.Add(invoiceViewModel.Invoice); foreach (var product in invoiceViewModel.Products) { product.InvoiceId = result; _invoiceProductRepository.Add(product); } return(new InvoiceViewModel()); }
public IActionResult AddInvoice([FromBody, Required] InvoiceCreateDto invoiceCreateDto) { invoiceRepository.Add(invoiceCreateDto); return(Ok()); //if (!_InvoiceRepository.Save()) //{ // throw new Exception("Creating a Invoiceitem failed on save."); //} //Invoice newInvoiceItem = _InvoiceRepository.GetSingle(toAdd.Id); //return CreatedAtRoute(nameof(GetSingleInvoice), new { id = newInvoiceItem.Id }, // Mapper.Map<InvoiceDto>(newInvoiceItem)); }
public async Task <IActionResult> CreateEditInvoice(Invoice model, List <IFormFile> files, string submit, string filename) { if (!ModelState.IsValid) { return(View()); } switch (submit) { case "CreateEditInvoice": break; case "RemoveFile": var fileName = filename; this.RemoveFile(model.InvoiceId, filename); return(View(model)); } var emailSubj = string.Empty; if (model.InvoiceId == 0) { model.CreatedBy = User.Identity.Name; model.DateCreated = DateTime.UtcNow; _invoiceRepo.Add(model); _invoiceRepo.SaveAll(); await UploadFiles(files, model.InvoiceId); emailSubj = "New Invoice"; } else { model.UpdatedBy = User.Identity.Name; model.DateUpdated = DateTime.UtcNow; _invoiceRepo.Update(model); _invoiceRepo.SaveAll(); await UploadFiles(files, model.InvoiceId); emailSubj = "Invoice Update"; } //Send Email string body = this.createEmailBody(model); await _emailSender.SendEmailAsync("", emailSubj, body); return(RedirectToAction("index", "invoice", new { area = "" })); }
public ActionResult Create([Bind(Include = "Number,DueDateTime,Vat,Receiver")] Invoice invoice) { if (!ModelState.IsValid) { return(View(invoice)); } var user = _userManager.FindById(User.Identity.GetUserId()); invoice.Id = Guid.NewGuid(); invoice.DateCreated = DateTime.Now; invoice.Creator = user; _invoiceRepository.Add(invoice); return(RedirectToAction("Index")); }
public IHttpActionResult Post([FromBody] InvoiceDTO value) { try { if (value == null) { return(BadRequest()); } string userName = null; if (HttpContext.Current != null && HttpContext.Current.User != null && HttpContext.Current.User.Identity.Name != null) { userName = HttpContext.Current.User.Identity.Name; } if (value.Amount != value.InvoiceItems.Sum(it => it.Amount)) { return(BadRequest("Invocie Amount Miss Match with total Invoice Item Amount")); } if (value.GST != value.InvoiceItems.Sum(it => it.GST)) { return(BadRequest("Invocie GST Miss Match with total Invoice Item GST")); } var invoice = value.ToDomain(); invoice.CreateUser = userName; invoice.ChangeUser = userName; invoice.Concurrency = Guid.NewGuid(); _InvoiceRepo.Add(invoice); _uow.SaveChanges(); if (invoice.ID > 0) { return(Created <InvoiceDTO>(Request.RequestUri + "/" + invoice.ID, invoice.ToDTO())); } return(BadRequest()); } catch (Exception ex) { return(InternalServerError()); } }
public ActionResult Create(Invoice model) { if (ModelState.IsValid) { try { invoiceRepository.Add(model); return(RedirectToAction(nameof(Index))); } catch { return(View()); } } ModelState.AddModelError("", "You have to fill all the required fields!"); return(View(model)); }
private void buttonGenerujEDI_Click(object sender, EventArgs e) { InvoiceModel invoice = this.getFromForm(); if (invoice != null) { } if (invoice != null) { string edi = _invoice.EdiEncode(invoice); if (ediSaveFileDialog.ShowDialog() == DialogResult.OK) { _invoice.Add(invoice); File.WriteAllText(ediSaveFileDialog.FileName, edi); MessageBox.Show("Zapisano do pliku edi."); } } }
public async Task <IActionResult> PostInvoice(SaveInvoiceResource resource, IFormFile file) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var awsServiceclientSettings = new AwsServiceClientSettings(file, _awsAppSettings.BucketName, _awsAppSettings.SubFolderW9, _awsAppSettings.BucketLocation, _awsAppSettings.PublicDomain); var documentUrl = ""; if (file != null) { if (file.Length > _photoAppSettings.MaxBytes) { return(BadRequest("Maximum file size exceeded")); } else { if (!_photoAppSettings.IsSupported(file.FileName)) { return(BadRequest("Invalid file type")); } else { documentUrl = await _awsServiceClient.UploadAsync(awsServiceclientSettings); } } } var invoice = _mapper.Map <SaveInvoiceResource, Invoices>(resource); invoice.FilePath = documentUrl; invoice.BankId = await GetUserId(); _repository.Add(invoice); await _unitOfWork.CompleteAsync(); var result = _mapper.Map(invoice, resource); return(Ok(result)); }
public JsonResult AddUpdateData(InvoiceCustomerWrapper_VM Model) { if (ModelState.IsValid) { try { IeCustomerRepository ff = new eCustomerRepository(); GetUserInfo(Model.Customer); GetUserInfo(Model.Invoice); if (Model.Customer.CustomerID == null) { short result = Convert.ToInt16(ff.Add(Model.Customer)); Model.Invoice.CustomerID = result; } else { ff.Update(Model.Customer); } if (Model.Invoice.InvoiceID == 0 || Model.Invoice.InvoiceID == null) { var data = _InvoiceRepo.Add(Model.Invoice); return(GetAddEditDeleteResponse(data, "Add")); } else if (Model.Invoice.InvoiceID > 0) { var data = _InvoiceRepo.Update(Model.Invoice); return(GetAddEditDeleteResponse(data, "Update")); } } catch (Exception ex) { logger.Error("InvoiceController_AddUpdateData Error: ", ex); return(GetAddEditErrorException(ex)); } } return(GetModelStateIsValidException(ViewData)); }
public void Insert_should_Save_New_Invoice() { //arrange IInvoiceRepository repository = CreateRepository(); var invoice = new Invoice { nroinvoice = "I0005", company = 1, customer = "Jorge Vargas", ammount = 380.75m, nroproducts = 2, datecreate = DateTime.Now }; //act repository.Add(invoice); //asserts invoice.id.Should().NotBe(0, "because the id will be assigned by identity"); Console.WriteLine("New id: " + invoice.id); id = invoice.id; }
public void ProcessMessage(IHandlerContext <CreateInvoiceCommand> context) { // simulate slow processing Thread.Sleep(1000); var message = context.Message; var invoice = new Invoice(message.OrderId) { AccountContact = new InvoiceAccountContact(message.AccountContactName, message.AccountContactEMail) }; foreach (var item in message.Items) { invoice.AddItem(item.Description, item.Price); } invoice.GenerateInvoiceNumber(); using (_databaseContextFactory.Create(InvoicingData.ConnectionStringName)) { _repository.Add(invoice); } var orderCreatedEvent = new InvoiceCreatedEvent { InvoiceId = invoice.Id, InvoiceNumber = invoice.InvoiceNumber, InvoiceDate = invoice.InvoiceDate, AccountContactName = message.AccountContactName, AccountContactEMail = message.AccountContactEMail }; orderCreatedEvent.Items.AddRange(message.Items); context.Publish(orderCreatedEvent); }
public JsonResult CreateJson(Invoice invoice, List <InvoiceProduct> Details) { string errorMessage = ""; if (ModelState.IsValid) { invoice.UserCreate = User.Identity.GetUserName(); invoiceRepository.Add(invoice, Details); invoiceRepository.Save(); return(Json(true)); } else { foreach (ModelState modelState in ModelState.Values) { foreach (ModelError error in modelState.Errors) { errorMessage += " \r\n " + error.ErrorMessage; } } return(Json(errorMessage)); } }
public void CreateInvoice(Invoice invoice) { invoicesRepository.Add(invoice); }
/// <summary> /// /// </summary> /// <param name="objInvoice"></param> public void InsertInvoice(Invoice objInvoice) { _roleRepository.Add(objInvoice); _unitOfWork.Commit(); }