public override void Render(PrintPageEventArgs e) { e.Graphics.FillEllipse(Brushes.Green, e.MarginBounds.Left, e.MarginBounds.Top, e.MarginBounds.Left + 100, e.MarginBounds.Top + 100); e.Graphics.DrawString(Invoice.CompanyName, InvoiceDocument.TitleFont, Brushes.Black, e.MarginBounds.Left, e.MarginBounds.Top + 30); e.HasMorePages = true; InvoiceDocument.ChangeSection(new SummmarySection(InvoiceDocument)); }
public async Task <SendInvoicesResult> SendInvoicesAsync(InvoiceDocument invoiceDocument) { var mapper = new InvoiceDocumentMapper(invoiceDocument); var responseDoc = await RestClient.SendRequestAsync(mapper.GetInvoiceDoc()); return(new SendInvoicesResult(responseDoc)); }
public void AddInvoiceToOrder(InvoiceDocument invoiceDocument) { using (ApplicationDbContext entityContext = new ApplicationDbContext()) { entityContext.InvoiceDocuments.Add(invoiceDocument); entityContext.SaveChanges(); } }
public async Task <ActionResult> printInvoice([FromBody] printInvoiceRequest printInvoiceRequest) { try { var items = await(from o in db.TbtOrder where o.DocNum == printInvoiceRequest.DocNum join g in db.TbmItemGroup on o.ItemCode.Trim().Substring(0, 1) equals g.ItemGrpPrefix.Trim() select new { o, g }).ToListAsync(); List <InvoiceItem> InvoiceItems = new List <InvoiceItem>(); items.ForEach(x => { InvoiceItem l = new InvoiceItem { Dscription = x.o.Dscription, ItemCode = x.o.ItemCode, Price = (double)x.o.Price, Qty = (double)x.o.Quantity, ItemGrpCode = x.g.ItemGrpCode, ItemGrpName = x.g.ItemGrpName }; InvoiceItems.Add(l); }); InvoiceDocumentModel invoiceDocumentModel = new InvoiceDocumentModel { Address = items.FirstOrDefault().o.Address, CardName = items.FirstOrDefault().o.CardName, CardCode = items.FirstOrDefault().o.CardCode.ToString(), DocDate = items.FirstOrDefault().o.DocDate, DocDueDate = items.FirstOrDefault().o.DocDueDate, DocNum = printInvoiceRequest.DocNum, invoiceitems = InvoiceItems, Remark = items.FirstOrDefault().o.Remark, County = items.FirstOrDefault().o.County }; InvoiceDocument pDoc = new InvoiceDocument(this._hostingEnvironment); Stream resultPDFStream = pDoc.CreatePDF(invoiceDocumentModel); resultPDFStream.Position = 0; if (resultPDFStream.Length != 0) { FileStreamResult fileStreamResult = new FileStreamResult(resultPDFStream, "application/pdf"); fileStreamResult.FileDownloadName = "Invoice_" + "" + ".pdf"; return(fileStreamResult); } else { return(NotFound()); } } catch (Exception ex) { return(StatusCode(500, ex)); } }
private InvoiceDocument createInvoiceDbDocument() { var doc = new InvoiceDocument(); doc.DateOfInvoice = DateOfInvoice; doc.InvoiceNmuber = "Faktura " + InvoiceNumber; doc.FileName = "Faktura " + InvoiceNumber + ".pdf"; doc.File = PDFFile; return(doc); }
public async Task ValidInvoiceDocumentWorks(InvoiceDocument invoiceDoc) { // Arrange var client = new AadeClient(UserId, UserSubscriptionKey, AadeEnvironment.Sandbox); // Act var response = await client.SendInvoicesAsync(invoiceDoc); // Assert Assert.NotEmpty(response.SendInvoiceResults); Assert.True(response.SendInvoiceResults.Single().Item.IsSuccess); }
public void InvoiceListNew(List <ISaleItem> list, IBuyer buyer, IVendor vendor, IInvoice invoice) { InvoiceDocument i = new InvoiceDocument(); //i.InvoiceOrder(invoice); // wyjście do numeracji, po odczycie z bazy danych i.InvoiceVendor(vendor); i.InvoiceBuyer(buyer); i.InvoiceListData(list); i.Show(); }
public ActionResult Edit(Claim C, string InvoiceType, string Quarter) { if (C != null && C.files != null) { UserAccount u = (UserAccount)Session["UserAccount"]; bool result = _claimDao.ValidateAccountCode(C != null ? C.AccountCode : ""); if (result) { C.Id = Convert.ToInt64(Security.DecodeUrlandDecrypt(C.EncryptedId)); //C.InvoiceDocuments = new List<InvoiceDocument>(); foreach (HttpPostedFileBase d in C.files) { InvoiceDocument IVD = new InvoiceDocument(); if (d != null && d.FileName != null) { IVD.Name = d.FileName; IVD.GUID = Guid.NewGuid().ToString("N"); IVD.Extension = System.IO.Path.GetExtension(IVD.Name); IVD.ReAttach = true; string location = Path.Combine(Server.MapPath("~/Resources/InvoiceDocuments/"), IVD.GUID + IVD.Extension); d.SaveAs(location); } C.InvoiceDocuments.Add(IVD); } C.SystemIp = GetRemoteIp.GetIPAddress(HttpContext); C.CreatedBy = u.Id; C.Quarter = Quarter; C.InvoiceTypeId = string.IsNullOrEmpty(InvoiceType) ? 0 : Security.Decrypt <Int64>(InvoiceType); long Id = _claimDao.SaveClaim(C); if (Id > 0) { return(RedirectToRoute("Claim_Index")); } else { ViewBag.Error = "Incorrect Date"; } } else { ViewBag.Error = "Please Enter valid Account Code"; } } return(View()); }
/// <summary> /// Update a document after editing /// </summary> public AjaxReturn DocumentSave(InvoiceDocument json) { Database.BeginTransaction(); Extended_Document document = json.header; DocType t = checkDocType(document.DocumentTypeId, InvoiceDoc, CreditDoc); JObject oldDoc = getCompleteDocument(document.idDocument); int sign = SignFor(t); Extended_Document original = getDocument(document); decimal vat = 0; decimal net = 0; if (document.idDocument == null) { allocateDocumentIdentifier(document); } foreach (InvoiceLine detail in json.detail) { if ((detail.ProductId == 0 || detail.ProductId == null) && (detail.AccountId == 0 || detail.AccountId == null)) { Utils.Check(detail.LineAmount == 0 && detail.VatAmount == 0, "All lines must be allocated to an account"); continue; } net += detail.LineAmount; vat += detail.VatAmount; } Utils.Check(document.DocumentAmount == net + vat, "Document does not balance"); decimal changeInDocumentAmount = -sign * (document.DocumentAmount - original.DocumentAmount); var lineNum = 1; fixNameAddress(document, NameType); if (SecurityOn && Settings.RequireAuthorisation && NameType == "S") { if (Admin && document.Authorised == 0) { document.Authorised = null; } else if (original.Authorised == null || original.Authorised == Session.User.idUser) { document.Authorised = document.Authorised > 0 ? Session.User.idUser : null; } else { document.Authorised = original.Authorised; } } Database.Update(document); // Find any existing VAT record Journal vatJournal = Database.QueryOne <Journal>("SELECT * FROM Journal WHERE DocumentId = " + document.idDocument + " AND AccountId = " + (int)Acct.VATControl + " ORDER BY JournalNum DESC"); Journal journal = Database.Get(new Journal() { DocumentId = (int)document.idDocument, JournalNum = lineNum }); journal.DocumentId = (int)document.idDocument; journal.JournalNum = lineNum++; journal.AccountId = (int)LedgerAccount; journal.NameAddressId = document.DocumentNameAddressId; journal.Memo = document.DocumentMemo; journal.Amount += changeInDocumentAmount; journal.Outstanding += changeInDocumentAmount; Database.Update(journal); foreach (InvoiceLine detail in json.detail) { if ((detail.ProductId == 0 || detail.ProductId == null) && (detail.AccountId == 0 || detail.AccountId == null)) { continue; } journal = Database.Get(new Journal() { DocumentId = (int)document.idDocument, JournalNum = lineNum }); journal.DocumentId = (int)document.idDocument; journal.JournalNum = lineNum++; journal.AccountId = (int)detail.AccountId; journal.NameAddressId = document.DocumentNameAddressId; journal.Memo = detail.Memo; journal.Outstanding += sign * detail.LineAmount - journal.Amount; journal.Amount = sign * detail.LineAmount; Database.Update(journal); Line line = new Line() { idLine = journal.idJournal, Qty = detail.Qty, ProductId = detail.ProductId, LineAmount = detail.LineAmount, VatCodeId = detail.VatCodeId, VatRate = detail.VatRate, VatAmount = detail.VatAmount }; Database.Update(line); } Database.Execute("DELETE FROM Line WHERE idLine IN (SELECT idJournal FROM Journal WHERE DocumentId = " + document.idDocument + " AND JournalNum >= " + lineNum + ")"); Database.Execute("DELETE FROM Journal WHERE DocumentId = " + document.idDocument + " AND JournalNum >= " + lineNum); if (vat != 0 || vatJournal.idJournal != null) { vat *= sign; decimal changeInVatAmount = vat - vatJournal.Amount; Utils.Check(document.VatPaid == null || document.VatPaid < 1 || changeInVatAmount == 0, "Cannot alter VAT on this document, it has already been declared"); vatJournal.DocumentId = (int)document.idDocument; vatJournal.AccountId = (int)Acct.VATControl; vatJournal.NameAddressId = document.DocumentNameAddressId; vatJournal.Memo = "Total VAT"; vatJournal.JournalNum = lineNum++; vatJournal.Amount = vat; vatJournal.Outstanding += changeInVatAmount; Database.Update(vatJournal); } JObject newDoc = getCompleteDocument(document.idDocument); Database.AuditUpdate("Document", document.idDocument, oldDoc, newDoc); Settings.RegisterNumber(this, document.DocumentTypeId, Utils.ExtractNumber(document.DocumentIdentifier)); Database.Commit(); return(new AjaxReturn() { message = "Document saved", id = document.idDocument }); }
/// <summary> /// Update a document after editing /// </summary> public AjaxReturn DocumentPost(InvoiceDocument json) { Database.BeginTransaction(); Extended_Document document = json.header; DocType t = checkDocType(document.DocumentTypeId, InvoiceDoc, CreditDoc); JObject oldDoc = getCompleteDocument(document.idDocument); int sign = SignFor(t); Extended_Document original = getDocument(document); decimal vat = 0; decimal net = 0; if (document.idDocument == null) allocateDocumentIdentifier(document); foreach (InvoiceLine detail in json.detail) { if ((detail.ProductId == 0 || detail.ProductId == null) && (detail.AccountId == 0 || detail.AccountId == null)) continue; net += detail.LineAmount; vat += detail.VatAmount; } Utils.Check(document.DocumentAmount == net + vat, "Document does not balance"); decimal changeInDocumentAmount = -sign * (document.DocumentAmount - original.DocumentAmount); var lineNum = 1; fixNameAddress(document, NameType); Database.Update(document); // Find any existing VAT record Journal vatJournal = Database.QueryOne<Journal>("SELECT * FROM Journal WHERE DocumentId = " + document.idDocument + " AND AccountId = " + (int)Acct.VATControl + " ORDER BY JournalNum DESC"); Journal journal = Database.Get(new Journal() { DocumentId = (int)document.idDocument, JournalNum = lineNum }); journal.DocumentId = (int)document.idDocument; journal.JournalNum = lineNum++; journal.AccountId = (int)LedgerAccount; journal.NameAddressId = document.DocumentNameAddressId; journal.Memo = document.DocumentMemo; journal.Amount += changeInDocumentAmount; journal.Outstanding += changeInDocumentAmount; Database.Update(journal); foreach (InvoiceLine detail in json.detail) { if ((detail.ProductId == 0 || detail.ProductId == null) && (detail.AccountId == 0 || detail.AccountId == null)) continue; journal = Database.Get(new Journal() { DocumentId = (int)document.idDocument, JournalNum = lineNum }); journal.DocumentId = (int)document.idDocument; journal.JournalNum = lineNum++; journal.AccountId = (int)detail.AccountId; journal.NameAddressId = document.DocumentNameAddressId; journal.Memo = detail.Memo; journal.Outstanding += sign * detail.LineAmount - journal.Amount; journal.Amount = sign * detail.LineAmount; Database.Update(journal); Line line = new Line(); line.idLine = journal.idJournal; line.Qty = detail.Qty; line.ProductId = detail.ProductId; line.LineAmount = detail.LineAmount; line.VatCodeId = detail.VatCodeId; line.VatRate = detail.VatRate; line.VatAmount = detail.VatAmount; Database.Update(line); } Database.Execute("DELETE FROM Line WHERE idLine IN (SELECT idJournal FROM Journal WHERE DocumentId = " + document.idDocument + " AND JournalNum >= " + lineNum + ")"); Database.Execute("DELETE FROM Journal WHERE DocumentId = " + document.idDocument + " AND JournalNum >= " + lineNum); if (vat != 0 || vatJournal.idJournal != null) { vat *= sign; decimal changeInVatAmount = vat - vatJournal.Amount; Utils.Check(document.VatPaid == null || changeInVatAmount == 0, "Cannot alter VAT on this document, it has already been declared"); vatJournal.DocumentId = (int)document.idDocument; vatJournal.AccountId = (int)Acct.VATControl; vatJournal.NameAddressId = document.DocumentNameAddressId; vatJournal.Memo = "Total VAT"; vatJournal.JournalNum = lineNum++; vatJournal.Amount = vat; vatJournal.Outstanding += changeInVatAmount; Database.Update(vatJournal); } JObject newDoc = getCompleteDocument(document.idDocument); Database.AuditUpdate("Document", document.idDocument, oldDoc, newDoc); Settings.RegisterNumber(this, document.DocumentTypeId, Utils.ExtractNumber(document.DocumentIdentifier)); Database.Commit(); return new AjaxReturn() { message = "Document saved", id = document.idDocument }; }
public InvoiceDocumentMapper(InvoiceDocument invoiceDocument) { InvoiceDocument = invoiceDocument; }
private void button1_Click(object sender, EventArgs e) { InvoiceDocument inv = new InvoiceDocument(); inv.Show(); }
public ActionResult Add(Claim C, string InvoiceType, string Quarter) { if (C != null && C.files != null) { UserAccount u = (UserAccount)Session["UserAccount"]; bool Amountresult = _claimDao.ValidateBudgetAmount(C != null ? C.AccountCode : "", C.ProgramType != null ? C.ProgramType.Id : 0, C.InvoiceAmount); if (Amountresult) { bool result = _claimDao.ValidateAccountCode(C != null ? C.AccountCode : ""); if (result) { C.InvoiceDocuments = new List <InvoiceDocument>(); foreach (HttpPostedFileBase d in C.files) { InvoiceDocument IVD = new InvoiceDocument(); if (d != null && d.FileName != null) { IVD.Name = d.FileName; IVD.GUID = Guid.NewGuid().ToString(); IVD.Extension = System.IO.Path.GetExtension(IVD.Name); IVD.ReAttach = true; string location = Path.Combine(Server.MapPath("~/Resources/InvoiceDocuments/"), IVD.GUID + IVD.Extension); d.SaveAs(location); } C.InvoiceDocuments.Add(IVD); } C.SystemIp = GetRemoteIp.GetIPAddress(HttpContext); C.CreatedBy = u.Id; C.Quarter = Quarter; C.InvoiceTypeId = string.IsNullOrEmpty(InvoiceType) ? 0 : Security.Decrypt <Int64>(InvoiceType); long Id = _claimDao.SaveClaim(C); if (Id > 0) { return(RedirectToRoute("Claim_Index")); } else { ViewBag.Error = "Incorrect Date"; } } else { ViewBag.Error = "Please Enter valid Account Code"; // ModelState.AddModelError("Id", "Please Enter valid Account Code"); } } else { ViewBag.Error = "The Distributor didn't have enough budget"; //ModelState.AddModelError("Id", "The Distributor didn't have enough budget"); } } else { ViewBag.Error = "Incorrect Date"; //ModelState.AddModelError("Id", "Incorrect Date"); } List <SelectListItem> listItems = new List <SelectListItem>(); listItems.Add(new SelectListItem { Text = "服务费", Value = Security.Encrypt <string>("1") }); listItems.Add(new SelectListItem { Text = "礼品费用", Value = Security.Encrypt <string>("2") }); ViewBag.InvoiceTypeList = listItems; ViewBag.ProgramTypes = _distributorDao.GetProgramTypeList(); return(View()); }
public SummmarySection(InvoiceDocument invoiceDocument) : base(invoiceDocument) { }
protected InvoiceSection(InvoiceDocument invoiceDocument) { this.InvoiceDocument = invoiceDocument; }
public MainPage(InvoiceDocument invoiceDocument) : base(invoiceDocument) { }