public ProfitReportsController(IAdditionalCostsManager additionalCostsManager, IEmployeeRateRspManager employeeRateRspManager, IEmployeesManager employeeManager, IOrdersManager orderManager, IForeignProductsManager foreignProductsManager, IMaterialDeliveryRspManager materialDeliveryRspManager, ISocialTaxesManager socialTaxesManager, IInstrumentsManager instrumentsManager, IOwnProductsManager ownProductsManager, ITermPositionsManager termPositionsManager, IPositionsManager positionsManager, ITermCostsManager termCostsManager, ITaxesManager taxesManager, IInvoicesManager invoicesManager, IInterestsManager interestsManager, ITermsManager termsManager) { this.additionalCostsManager = additionalCostsManager; this.employeeRateRspManager = employeeRateRspManager; this.employeeManager = employeeManager; this.orderManager = orderManager; this.foreignProductsManager = foreignProductsManager; this.ownProductsManager = ownProductsManager; this.materialDeliveryRspManager = materialDeliveryRspManager; this.socialTaxesManager = socialTaxesManager; this.instrumentsManager = instrumentsManager; this.interestsManager = interestsManager; this.termPositionsManager = termPositionsManager; this.positionsManager = positionsManager; this.termCostsManager = termCostsManager; this.taxesManager = taxesManager; this.invoicesManager = invoicesManager; this.termsManager = termsManager; }
public ProfitReportsController(IAdditionalCostsManager additionalCostsManager, IEmployeeRateRspManager employeeRateRspManager, IEmployeesManager employeeManager, IOrdersManager orderManager, IForeignProductsManager foreignProductsManager, IMaterialDeliveryRspManager materialDeliveryRspManager, ISocialTaxesManager socialTaxesManager, IInstrumentsManager instrumentsManager, IOwnProductsManager ownProductsManager, ITermPositionsManager termPositionsManager, IPositionsManager positionsManager, ITermCostsManager termCostsManager, ITaxesManager taxesManager, IInvoicesManager invoicesManager, IInterestsManager interestsManager, ITermsManager termsManager) { this.additionalCostsManager = additionalCostsManager; this.employeeRateRspManager = employeeRateRspManager; this.employeeManager = employeeManager; this.orderManager = orderManager; this.foreignProductsManager = foreignProductsManager; this.ownProductsManager = ownProductsManager; this.materialDeliveryRspManager = materialDeliveryRspManager; this.socialTaxesManager = socialTaxesManager; this.instrumentsManager = instrumentsManager; this.interestsManager = interestsManager; this.termPositionsManager = termPositionsManager; this.positionsManager = positionsManager; this.termCostsManager = termCostsManager; this.taxesManager = taxesManager; this.invoicesManager = invoicesManager; this.termsManager = termsManager; }
public GenerateMonthInvoicesController(IInvoicesManager invoicesManager, IOrdersManager ordersManager, ITaxesManager taxesManager, IInvoicePositionsManager invoicePositionsManager, IUniqueNumberProvider numberProvider, ITermPositionsManager termPositionsManager, IPositionsManager positionsManager, ITermCostsManager termCostsManager, IPrinterManager printerManager) : base(invoicesManager, ordersManager, taxesManager, invoicePositionsManager, numberProvider, termPositionsManager, positionsManager, termCostsManager) { this.printerManager = printerManager; }
public GenerateMonthInvoicesController(IInvoicesManager invoicesManager, IOrdersManager ordersManager, ITaxesManager taxesManager, IInvoicePositionsManager invoicePositionsManager, IUniqueNumberProvider numberProvider, ITermPositionsManager termPositionsManager, IPositionsManager positionsManager, ITermCostsManager termCostsManager, IPrinterManager printerManager) : base(invoicesManager, ordersManager, taxesManager, invoicePositionsManager, numberProvider, termPositionsManager, positionsManager, termCostsManager) { this.printerManager = printerManager; }
public ReportOrdersController(IOrdersManager manager, ITermPositionsManager termPositionsManager, IPositionsManager positionsManager, ITermCostsManager termCostsManager, ITaxesManager taxesManager, IInvoicesManager invoicesManager) : base(manager) { this.termPositionsManager = termPositionsManager; this.positionsManager = positionsManager; this.termCostsManager = termCostsManager; this.taxesManager = taxesManager; this.invoicesManager = invoicesManager; }
public AddInvoicesController(IInvoicesManager invoicesManager, IOrdersManager ordersManager, ITaxesManager taxesManager, IInvoicePositionsManager invoicePositionsManager, IUniqueNumberProvider numberProvider, ITermPositionsManager termPositionsManager, IPositionsManager positionsManager, ITermCostsManager termCostsManager) { this.invoicesManager = invoicesManager; this.numberProvider = numberProvider; this.ordersManager = ordersManager; this.taxesManager = taxesManager; this.invoicePositionsManager = invoicePositionsManager; this.termPositionsManager = termPositionsManager; this.positionsManager = positionsManager; this.termCostsManager = termCostsManager; }
public AddInvoicesController(IInvoicesManager invoicesManager, IOrdersManager ordersManager, ITaxesManager taxesManager, IInvoicePositionsManager invoicePositionsManager, IUniqueNumberProvider numberProvider, ITermPositionsManager termPositionsManager, IPositionsManager positionsManager, ITermCostsManager termCostsManager) { this.invoicesManager = invoicesManager; this.numberProvider = numberProvider; this.ordersManager = ordersManager; this.taxesManager = taxesManager; this.invoicePositionsManager = invoicePositionsManager; this.termPositionsManager = termPositionsManager; this.positionsManager = positionsManager; this.termCostsManager = termCostsManager; }
public PrintController(IOrdersManager manager, IInvoicesManager invoicesManager, IInvoiceStornosManager invoiceStornosManager, ITaxesManager taxesManager, ITransportOrdersManager transportOrdersManager, IPrinterManager printerManager, ITermsManager termsManager) : base() { this.taxesManager = taxesManager; this.invoicesManager = invoicesManager; this.invoiceStornosManager = invoiceStornosManager; this.transportOrdersManager = transportOrdersManager; this.printerManager = printerManager; this.termsManager = termsManager; Manager = manager; FilterExpressionCreator = new FilterExpressionCreator(); }
public PrintController(IOrdersManager manager, IInvoicesManager invoicesManager, IInvoiceStornosManager invoiceStornosManager, ITaxesManager taxesManager, ITransportOrdersManager transportOrdersManager, IPrinterManager printerManager, ITermsManager termsManager) : base() { this.taxesManager = taxesManager; this.invoicesManager = invoicesManager; this.invoiceStornosManager = invoiceStornosManager; this.transportOrdersManager = transportOrdersManager; this.printerManager = printerManager; this.termsManager = termsManager; Manager = manager; FilterExpressionCreator = new FilterExpressionCreator(); }
public static double CalculateTaxes(ITaxesManager taxesManager) { var taxValues = taxesManager.GetEntities(o => o.FromDate.Date <= DateTime.Now.Date && o.ToDate.Date >= DateTime.Now).ToList(); double taxValue = 19; if (taxValues.Count != 0) { var minToDate = taxValues.Min(o => o.ToDate.Date); var temp = taxValues.FirstOrDefault(o => o.ToDate.Date == minToDate); if (temp != null) { taxValue = temp.Value; } } return(taxValue); }
public MemoryStream PrepareMonthInvoicePrintData(IEnumerable<Invoices> invoices, string path, IInvoicesManager invoicesManager, ITaxesManager taxesManager, IOrdersManager ordersManager) { var result = new MemoryStream(); try { Package pkg; PackagePart part; XmlReader xmlReader; XDocument xmlMainXMLDoc; GetXmlDoc(path, result, out pkg, out part, out xmlReader, out xmlMainXMLDoc); var temp = xmlMainXMLDoc.Descendants().LastOrDefault(o => o.Value.Contains("#CustomerName")); var parentElement = GetParentElementByName(temp, "<w:body "); var bodyText = String.Join("", parentElement.Elements()); var templateBody = xmlMainXMLDoc.Root.ToString(); bool firstElem = true; foreach (var invoice in invoices) { if (!firstElem) { var index = templateBody.IndexOf("</w:body"); var pageBreak = @"<w:p w:rsidRDefault=""00C97ADC"" w:rsidR=""00C97ADC""><w:pPr><w:rPr><w:lang w:val=""en-GB""/></w:rPr></w:pPr><w:r><w:rPr><w:lang w:val=""en-GB""/> </w:rPr><w:br w:type=""page""/></w:r></w:p><w:p w:rsidRDefault=""009A5AB0"" w:rsidRPr=""00905C57"" w:rsidR=""009A5AB0"" w:rsidP=""0030272E""> <w:pPr><w:rPr><w:lang w:val=""en-GB""/></w:rPr></w:pPr><w:bookmarkStart w:name=""_GoBack"" w:id=""0""/><w:bookmarkEnd w:id=""0""/></w:p>"; templateBody = templateBody.Substring(0, index) + pageBreak + bodyText + templateBody.Substring(index); } else { firstElem = false; } //replace fields templateBody = ReplaceFields(ordersManager, 0, PrintTypes.Invoice, templateBody, invoicesManager, taxesManager, invoice); } xmlMainXMLDoc = SaveDoc(result, pkg, part, xmlReader, xmlMainXMLDoc, templateBody); } catch { } return result; }
public static void CalculateOrderPrices(Orders entity, ITaxesManager taxesManager, out double totalPriceWithoutDiscountWithoutTax, out double totalPriceWithoutTax, out double totalPrice, out double summaryPrice) { totalPriceWithoutDiscountWithoutTax = 0; totalPriceWithoutTax = 0; totalPrice = 0; var allPositions = entity.Positions.Where(o => !o.DeleteDate.HasValue).ToList(); //Product prices foreach (var position in allPositions) { totalPriceWithoutDiscountWithoutTax += CalculatePositionPrice(position.Price, position.Amount, position.Payment); } var taxValue = CalculateTaxes(taxesManager); summaryPrice = CalculateTaxesAndDiscount(entity.Discount ?? 0, taxValue, entity.Customers.WithTaxes, null, ref totalPriceWithoutDiscountWithoutTax, ref totalPriceWithoutTax, ref totalPrice); }
public static void CalculateOrderPrices(Orders entity, ITaxesManager taxesManager, out double totalPriceWithoutDiscountWithoutTax, out double totalPriceWithoutTax, out double totalPrice, out double summaryPrice) { totalPriceWithoutDiscountWithoutTax = 0; totalPriceWithoutTax = 0; totalPrice = 0; var allPositions = entity.Positions.Where(o => !o.DeleteDate.HasValue).ToList(); //Product prices foreach (var position in allPositions) { totalPriceWithoutDiscountWithoutTax += CalculatePositionPrice(position.Price, position.Amount, position.Payment); } var taxValue = CalculateTaxes(taxesManager); summaryPrice = CalculateTaxesAndDiscount(entity.Discount ?? 0, taxValue, entity.Customers.WithTaxes, null, ref totalPriceWithoutDiscountWithoutTax, ref totalPriceWithoutTax, ref totalPrice); }
public static double CalculateTotalPrice(Orders order, ITermPositionsManager termPositionsManager, IPositionsManager positionsManager, ITermCostsManager termCostsManager, ITaxesManager taxesManager, DateTime?fromDate, DateTime?toDate, ref double profit) { double result = 0; //TODO discuss with customer - take positions where proccessed amount not null (but take with 0) var termPositions = termPositionsManager.GetEntities(o => !o.DeleteDate.HasValue && o.Terms.OrderId == order.Id && o.ProccessedAmount.HasValue); if (fromDate.HasValue && toDate.HasValue) { termPositions = termPositions.Where(o => o.Terms.Date >= fromDate.Value && o.Terms.Date <= toDate.Value); } foreach (var termPosition in termPositions.ToList()) { //positions if (termPosition.ProccessedAmount.Value > 0) { var positionProfit = CalculatePositionPrice(termPosition.Positions.Price, termPosition.ProccessedAmount.Value, termPosition.Positions.Payment); result += positionProfit; //todo calculate profit profit += positionProfit; } //materials foreach (var material in termPosition.TermPositionMaterialRsps.Where(o => !o.DeleteDate.HasValue && o.Amount.HasValue)) { var amount = material.Amount.Value; if (material.Materials.MaterialAmountTypes == MaterialAmountTypes.Meter) { if (material.Materials.Length != 0) { amount = amount / (double)material.Materials.Length.Value; } else { //todo } } result += CalculatePositionPrice(material.Materials.Price, amount, PaymentTypes.Standard); var materialProfit = material.Materials.Price * amount - material.Materials.BoughtPrice * amount; profit += materialProfit; } } //material positions without terms var materialPositionsWithoutTerms = positionsManager.GetEntities(o => o.OrderId == order.Id && !o.DeleteDate.HasValue && !o.TermId.HasValue && o.MaterialId.HasValue && o.IsMaterialPosition); if (fromDate.HasValue && toDate.HasValue) { materialPositionsWithoutTerms = materialPositionsWithoutTerms.Where(o => o.ChangeDate >= fromDate.Value && o.ChangeDate <= toDate.Value); } foreach (var position in materialPositionsWithoutTerms.ToList()) { var price = CalculatePositionPrice(position.Price, position.Amount, position.Payment); result += price; profit += price - position.Materials.BoughtPrice * position.Amount; } //extra costs var termCosts = termCostsManager.GetEntities(o => !o.DeleteDate.HasValue && o.Terms.OrderId == order.Id); if (fromDate.HasValue && toDate.HasValue) { termCosts = termCosts.Where(o => o.Terms.Date >= fromDate.Value && o.Terms.Date <= toDate.Value); } foreach (var termCost in termCosts.ToList()) { var price = CalculatePositionPrice(termCost.Price, 1, PaymentTypes.Standard); result += price; profit += price - termCost.Costs; } //TODO get taxes from invoices and calculate taxes only for open positions var taxes = CalculateTaxes(taxesManager); var taxValue = (result / (double)100) * taxes; if (order.Customers.WithTaxes) { //with taxes result += taxValue; } return(result); }
private string ReplaceReminderTotalPrice(Invoices invoice, string xmlMainXMLDoc, ITaxesManager taxesManager) { if (invoice.InvoicePositions != null && invoice.InvoicePositions.Count != 0) { double totalPriceWithoutDiscountWithoutTax = 0; double totalPriceWithoutTax = 0; double totalPrice = 0; double summaryPrice = 0; CalculationHelper.CalculateInvoicePrices(invoice, out totalPriceWithoutDiscountWithoutTax, out totalPriceWithoutTax, out totalPrice, out summaryPrice); xmlMainXMLDoc = xmlMainXMLDoc.Replace("#TotalPrice", summaryPrice.ToString("N2")); } else { xmlMainXMLDoc = xmlMainXMLDoc.Replace("#TotalPrice", String.Empty); } return xmlMainXMLDoc; }
public static double CalculateTotalPrice(Orders order, ITermPositionsManager termPositionsManager, IPositionsManager positionsManager, ITermCostsManager termCostsManager, ITaxesManager taxesManager, DateTime? fromDate, DateTime? toDate, ref double profit) { double result = 0; //TODO discuss with customer - take positions where proccessed amount not null (but take with 0) var termPositions = termPositionsManager.GetEntities(o => !o.DeleteDate.HasValue && o.Terms.OrderId == order.Id && o.ProccessedAmount.HasValue); if(fromDate.HasValue && toDate.HasValue) { termPositions = termPositions.Where(o => o.Terms.Date >= fromDate.Value && o.Terms.Date <= toDate.Value); } foreach (var termPosition in termPositions.ToList()) { //positions if (termPosition.ProccessedAmount.Value > 0) { var positionProfit = CalculatePositionPrice(termPosition.Positions.Price, termPosition.ProccessedAmount.Value, termPosition.Positions.Payment); result += positionProfit; //todo calculate profit profit += positionProfit; } //materials foreach (var material in termPosition.TermPositionMaterialRsps.Where(o => !o.DeleteDate.HasValue && o.Amount.HasValue)) { var amount = material.Amount.Value; if (material.Materials.MaterialAmountTypes == MaterialAmountTypes.Meter) { if (material.Materials.Length != 0) { amount = amount / (double)material.Materials.Length.Value; } else { //todo } } result += CalculatePositionPrice(material.Materials.Price, amount, PaymentTypes.Standard); var materialProfit = material.Materials.Price * amount - material.Materials.BoughtPrice * amount; profit += materialProfit; } } //material positions without terms var materialPositionsWithoutTerms = positionsManager.GetEntities(o => o.OrderId == order.Id && !o.DeleteDate.HasValue && !o.TermId.HasValue && o.MaterialId.HasValue && o.IsMaterialPosition); if (fromDate.HasValue && toDate.HasValue) { materialPositionsWithoutTerms = materialPositionsWithoutTerms.Where(o => o.ChangeDate >= fromDate.Value && o.ChangeDate <= toDate.Value); } foreach (var position in materialPositionsWithoutTerms.ToList()) { var price = CalculatePositionPrice(position.Price, position.Amount, position.Payment); result += price; profit += price - position.Materials.BoughtPrice * position.Amount; } //extra costs var termCosts = termCostsManager.GetEntities(o => !o.DeleteDate.HasValue && o.Terms.OrderId == order.Id); if (fromDate.HasValue && toDate.HasValue) { termCosts = termCosts.Where(o => o.Terms.Date >= fromDate.Value && o.Terms.Date <= toDate.Value); } foreach (var termCost in termCosts.ToList()) { var price = CalculatePositionPrice(termCost.Price, 1, PaymentTypes.Standard); result += price; profit += price - termCost.Costs; } //TODO get taxes from invoices and calculate taxes only for open positions var taxes = CalculateTaxes(taxesManager); var taxValue = (result / (double)100) * taxes; if (order.Customers.WithTaxes) { //with taxes result += taxValue; } return result; }
public static double CalculateTaxes(ITaxesManager taxesManager) { var taxValues = taxesManager.GetEntities(o => o.FromDate.Date <= DateTime.Now.Date && o.ToDate.Date >= DateTime.Now).ToList(); double taxValue = 19; if (taxValues.Count != 0) { var minToDate = taxValues.Min(o => o.ToDate.Date); var temp = taxValues.FirstOrDefault(o => o.ToDate.Date == minToDate); if (temp != null) { taxValue = temp.Value; } } return taxValue; }
private MemoryStream PrepareCommonOrderPrintData(IOrdersManager ordersManager, int id, string path, PrintTypes type, IInvoicesManager invoicesManager, ITaxesManager taxesManager, IInvoiceStornosManager invoiceStornosManager = null, ITransportOrdersManager transportOrdersManager = null, ITermsManager termsManager = null) { var result = new MemoryStream(); try { Package pkg; PackagePart part; XmlReader xmlReader; XDocument xmlMainXMLDoc; GetXmlDoc(path, result, out pkg, out part, out xmlReader, out xmlMainXMLDoc); var images = new List<Image>(); if (type == PrintTypes.DeliveryNote) { var term = termsManager.GetById(id); for (var i = 0; i < term.DeliveryNoteSignatures.Count; i++) { var deliveryNoteSignature = term.DeliveryNoteSignatures.ElementAt(term.DeliveryNoteSignatures.Count - i - 1); //TODO doesnt work (( //pkg.CreateRelationship(uri, TargetMode.Internal, // "Http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", // "barcodeImageId"); byte[] bytes = Convert.FromBase64String(deliveryNoteSignature.Signature.Replace("data:image/png;base64,", "")); Image image; using (MemoryStream ms = new MemoryStream(bytes)) { image = Image.FromStream(ms); } images.Add(image); } } //replace fields var templateBody = ReplaceFields(ordersManager, id, type, xmlMainXMLDoc.Root.ToString(), invoicesManager, taxesManager, null, invoiceStornosManager, transportOrdersManager, termsManager, images); xmlMainXMLDoc = SaveDoc(result, pkg, part, xmlReader, xmlMainXMLDoc, templateBody); InsertImages(result, images); var doc = new Spire.Doc.Document(); doc.LoadFromStream(result, Spire.Doc.FileFormat.Docx); doc.JPEGQuality = 100; result = new MemoryStream(); doc.SaveToStream(result, Spire.Doc.FileFormat.PDF); } catch { } return result; }
private string ReplaceFields(IOrdersManager ordersManager, int id, PrintTypes printType, string xmlMainXMLDoc, IInvoicesManager invoicesManager, ITaxesManager taxesManager, Invoices invoice = null, IInvoiceStornosManager invoiceStornosManager = null, ITransportOrdersManager transportOrdersManager = null, ITermsManager termsManager = null, IEnumerable<Image> images = null) { string result = xmlMainXMLDoc; switch (printType) { case PrintTypes.Order: var order = ordersManager.GetById(id); result = ReplaceCommonFields(order, result); result = ReplaceBaseOrderFields(order, result); result = result.Replace("#SignatureDate", order.CreateDate.AddDays(2).ToShortDateString()); result = ReplaceRentPositions(order, result, taxesManager); result = ReplaceTotalPrice(order, result, taxesManager); result = ReplaceRentAdditionalCostPositions(order, result); break; case PrintTypes.Offer: order = ordersManager.GetById(id); result = ReplaceCommonFields(order, result); result = ReplaceBaseOfferFields(order, result); result = ReplaceBaseOrderFields(order, result); result = ReplaceRentPositions(order, result, taxesManager); result = ReplaceRentAdditionalCostPositions(order, result); break; case PrintTypes.Invoice: if (invoice == null) { invoice = invoicesManager.GetById(id); } order = invoice.Orders; result = ReplaceCommonFields(order, result); result = ReplaceBaseOrderFields(order, result); result = ReplaceBaseInvoiceFields(invoice, result, printType); bool manualPricePrinted = false; result = ReplaceInvoicePositions(invoice, invoice.InvoicePositions.ToList(), result, "#PositionDescription", "#PositionPrice", "Leistungen: ", ref manualPricePrinted); result = ReplaceInvoicePrices(invoice, result); break; case PrintTypes.InvoiceStorno: var invoiceStorno = invoiceStornosManager.GetById(id); invoice = invoiceStorno.Invoices; order = invoice.Orders; result = ReplaceCommonFields(order, result); result = ReplaceBaseOrderFields(order, result); result = ReplaceBaseInvoiceFields(invoice, result, printType); result = ReplaceInvoiceStornoPrices(invoiceStorno, result); result = ReplaceFieldValue(result, "#FreeText", invoiceStorno.FreeText); break; case PrintTypes.ReminderMail: invoice = invoicesManager.GetById(id); order = invoice.Orders; result = ReplaceCommonFields(order, result); result = ReplaceReminderPositions(invoice.InvoicePositions.ToList(), result); result = ReplaceReminderTotalPrice(invoice, result, taxesManager); break; case PrintTypes.DeliveryNote: var term = termsManager.GetById(id); result = ReplaceCommonFields(term.Orders, result); result = ReplaceBaseOrderFields(term.Orders, result); result = result.Replace("#DeliveryNoteType", "Lieferschein"); result = result.Replace("#DateType", "Liefertermin"); result = result.Replace("#AdressType", "Lieferanschrift"); result = result.Replace("#OrderNumber", term.Orders.OrderNumber); result = ReplacePositionWithDescription(term, result); if (term.DeliveryNoteSignatures.Count != 0) { var doc = XDocument.Parse(result); var signatureElement = doc.Descendants().FirstOrDefault(o => o.Value.Equals("#Signature", StringComparison.InvariantCultureIgnoreCase)); if (signatureElement != null && images != null && images.Count() != 0) { var currentElement = signatureElement; for (var i = 0; i < images.Count(); i++) { var image = images.ElementAt(images.Count() - i - 1); //TODO doesnt work (( //pkg.CreateRelationship(uri, TargetMode.Internal, // "Http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", // "barcodeImageId"); //insert image XmlElement tagDrawing = GetImageTag(image.Width, image.Height, term.DeliveryNoteSignatures.Count - i); signatureElement.AddAfterSelf(XDocument.Parse(tagDrawing.InnerXml).Root); } signatureElement.Remove(); result = doc.Root.ToString(); } else { result = result.Replace("#Signature", String.Empty); } } else { result = result.Replace("#Signature", String.Empty); } break; default: throw new NotImplementedException(); } return result; }
private string ReplaceTotalPrice(Orders order, string xmlMainXMLDoc, ITaxesManager taxesManager) { if (order.Positions != null && order.Positions.Count != 0) { double totalPriceWithoutDiscountWithoutTax = 0; double totalPriceWithoutTax = 0; double totalPrice = 0; double summaryPrice = 0; CalculationHelper.CalculateOrderPrices(order, taxesManager, out totalPriceWithoutDiscountWithoutTax, out totalPriceWithoutTax, out totalPrice, out summaryPrice); xmlMainXMLDoc = xmlMainXMLDoc.Replace("#TotalPrice", summaryPrice.ToString("N2")); } else { xmlMainXMLDoc = xmlMainXMLDoc.Replace("#TotalPrice", String.Empty); } return xmlMainXMLDoc; }
private string ReplaceRentPositions(Orders order, string xmlMainXMLDoc, ITaxesManager taxesManager) { var positions = order.Positions != null ? order.Positions.Where(o => !o.DeleteDate.HasValue && o.ProductId.HasValue).ToList() : new List<Positions>(); if (positions.Count != 0) { var minDate = DateTime.Now; var maxDate = DateTime.Now; var totalSellPrice = positions.Sum(o => o.Products.Price); if (positions.Any(o => o.Payment == PaymentTypes.Total)) { xmlMainXMLDoc = xmlMainXMLDoc.Replace("#RentPositionDescription", "Produkt gemäß Position 1"); xmlMainXMLDoc = xmlMainXMLDoc.Replace("#PaymentType", "Pauschal"); var totalPriceWithoutTax = positions.Sum(o => o.Price); xmlMainXMLDoc = xmlMainXMLDoc.Replace("#RentPrice", totalPriceWithoutTax.ToString("N2")); if (order.Customers.WithTaxes) { var taxes = CalculationHelper.CalculateTaxes(taxesManager); var taxValue = (totalPriceWithoutTax / (double)100) * taxes; //with taxes var totalPrice = totalPriceWithoutTax + taxValue; xmlMainXMLDoc = xmlMainXMLDoc.Replace("#BruttoPauschalPreis", totalPrice.ToString("N2")); } else { xmlMainXMLDoc = xmlMainXMLDoc.Replace("#BruttoPauschalPreis", totalPriceWithoutTax.ToString("N2")); } } else { xmlMainXMLDoc = ReplaceShortPositionDescription(positions, xmlMainXMLDoc); xmlMainXMLDoc = xmlMainXMLDoc.Replace("#BruttoPauschalPreis", String.Empty); } xmlMainXMLDoc = xmlMainXMLDoc.Replace("#FromDate", minDate.ToShortDateString()); xmlMainXMLDoc = xmlMainXMLDoc.Replace("#ToDate", maxDate.ToShortDateString()); xmlMainXMLDoc = xmlMainXMLDoc.Replace("#LastPaymentDate", maxDate.AddDays(10).ToShortDateString()); xmlMainXMLDoc = xmlMainXMLDoc.Replace("#TotalSellPrice", totalSellPrice.ToString("N2")); //todo xmlMainXMLDoc = ReplacePositionWithDescription(positions, xmlMainXMLDoc); xmlMainXMLDoc = xmlMainXMLDoc.Replace("#ProductDescription", String.Empty); } else { xmlMainXMLDoc = xmlMainXMLDoc.Replace("#ProductDescription", String.Empty); xmlMainXMLDoc = xmlMainXMLDoc.Replace("#FromDate", String.Empty); xmlMainXMLDoc = xmlMainXMLDoc.Replace("#ToDate", String.Empty); xmlMainXMLDoc = xmlMainXMLDoc.Replace("#LastPaymentDate", String.Empty); xmlMainXMLDoc = xmlMainXMLDoc.Replace("#BruttoPauschalPreis", String.Empty); xmlMainXMLDoc = xmlMainXMLDoc.Replace("#TotalSellPrice", String.Empty); xmlMainXMLDoc = xmlMainXMLDoc.Replace("#RentPositionDescription", String.Empty); xmlMainXMLDoc = xmlMainXMLDoc.Replace("#RentPrice", String.Empty); } return xmlMainXMLDoc; }
public MemoryStream PrepareOfferPrintData(int id, string path, ITaxesManager taxesManager, IOrdersManager ordersManager) { return PrepareCommonOrderPrintData(ordersManager, id, path, PrintTypes.Offer, null, taxesManager); }