private static void CalculateLineAfterCorrection(CommercialDocumentLine line) { if (line.CorrectedLine != null) { CommercialDocument parent = (CommercialDocument)line.Parent; //if the corrected line is in the same document so it already has been corrected so dont do it again if (parent.Lines.Children.Where(l => l.Id.Value == line.CorrectedLine.Id.Value).FirstOrDefault() == null) { CommercialCorrectiveDocumentFactory.CalculateLineAfterCorrection(line.CorrectedLine); } line.DiscountGrossValue += line.CorrectedLine.DiscountGrossValue; line.DiscountNetValue += line.CorrectedLine.DiscountNetValue; line.DiscountRate += line.CorrectedLine.DiscountRate; line.GrossPrice += line.CorrectedLine.GrossPrice; line.GrossValue += line.CorrectedLine.GrossValue; line.InitialGrossPrice += line.CorrectedLine.InitialGrossPrice; line.InitialGrossValue += line.CorrectedLine.InitialGrossValue; line.InitialNetPrice += line.CorrectedLine.InitialNetPrice; line.InitialNetValue += line.CorrectedLine.InitialNetValue; line.NetPrice += line.CorrectedLine.NetPrice; line.NetValue += line.CorrectedLine.NetValue; line.VatValue += line.CorrectedLine.VatValue; line.Quantity += line.CorrectedLine.Quantity; } }
/// <summary> /// Creates new <see cref="Payment"/> according to the document's defaults and attaches it to the parent <see cref="Document"/>. /// </summary> /// <returns>A new <see cref="Payment"/>.</returns> public override Payment CreateNew() { //create new Payment object and attach it to the element Document parent = (Document)this.Parent; Payment payment = new Payment(parent); payment.Order = this.Children.Count + 1; DocumentCategory dc = parent.DocumentType.DocumentCategory; CommercialDocument commercialDocument = this.Parent as CommercialDocument; FinancialDocument financialDocument = this.Parent as FinancialDocument; if (dc == DocumentCategory.Sales || dc == DocumentCategory.SalesCorrection) { payment.Direction = -1; } else if (dc == DocumentCategory.Purchase || dc == DocumentCategory.PurchaseCorrection) { payment.Direction = 1; } else if (dc == DocumentCategory.Financial) { FinancialDirection fdc = parent.DocumentType.FinancialDocumentOptions.FinancialDirection; if (fdc == FinancialDirection.Income) { payment.Direction = 1; } else { payment.Direction = -1; } } //Copy payment contractor from source if exists if (this.PaymentContainingSourceDocument != null && this.PaymentContainingSourceDocument.Payments != null && this.PaymentContainingSourceDocument.Payments.Children.Count >= payment.Order) { Payment sourcePayment = this.PaymentContainingSourceDocument.Payments[payment.Order - 1]; payment.Contractor = sourcePayment.Contractor; payment.ContractorAddressId = sourcePayment.ContractorAddressId; } else if (commercialDocument != null) { payment.Contractor = commercialDocument.Contractor; payment.ContractorAddressId = commercialDocument.ContractorAddressId; } else if (financialDocument != null) { payment.Contractor = financialDocument.Contractor; payment.ContractorAddressId = financialDocument.ContractorAddressId; } //add the attribute to the collection this.Children.Add(payment); return(payment); }
internal void UpdateIssueDateForCorrectiveDocument(CommercialDocument correctiveDocument) { if (correctiveDocument != null && correctiveDocument.IsCorrectiveDocument()) { this.issueDate = correctiveDocument.InitialCorrectedDocument.IssueDate; } }
private void ValidateServicesLines(CommercialDocument document) { this.mapper.AddItemsToItemTypesCache(document); //Zamówienie sprzedazowe nie może posiadać więcej niż jednej pozycji zawierającej usługę na ilość 1. Ponadto pozycja ta nie może generować kosztu. //pomijamy te linie, które posiadają nieaktualną stawkę VAT - istotne dla FVR gdy zmieniają się obowiązujace stawki VAT IEnumerable <CommercialDocumentLine> relevantServicesLines = document.Lines.Where(line => !DictionaryMapper.Instance.GetItemType(SessionManager.VolatileElements.ItemTypesCache[line.ItemId]).IsWarehouseStorable); int servicesSalesLinesCount = 0; foreach (CommercialDocumentLine line in relevantServicesLines) { string sogdOption = SalesOrderGenerateDocumentOption.GetOption(line); if (SalesOrderGenerateDocumentOption.IsSales(sogdOption) && line.Quantity <= 1) { if (DictionaryMapper.Instance.GetVatRate(line.VatRateId).IsEventDateValid(document.EventDate)) { servicesSalesLinesCount++; } } else { throw new ClientException(ClientExceptionId.SalesOrderMoreThanOneServiceLineError); } } if (servicesSalesLinesCount > 1) { throw new ClientException(ClientExceptionId.SalesOrderMoreThanOneServiceLineError); } }
private void CheckDateDifference(CommercialDocument document) { if (document.AlternateVersion != null) { CommercialDocument alternate = (CommercialDocument)document.AlternateVersion; if (document.IssueDate > alternate.IssueDate) //zmieniono date na przyszlosc { document.IssueDate = new DateTime(document.IssueDate.Year, document.IssueDate.Month, document.IssueDate.Day, 0, 0, 0, 0); } else if (document.IssueDate < alternate.IssueDate) { document.IssueDate = new DateTime(document.IssueDate.Year, document.IssueDate.Month, document.IssueDate.Day, 23, 59, 59, 500); } if (document.EventDate > alternate.EventDate) //zmieniono date na przyszlosc { document.EventDate = new DateTime(document.EventDate.Year, document.EventDate.Month, document.EventDate.Day, 0, 0, 0, 0); } else if (document.EventDate < alternate.EventDate) { document.EventDate = new DateTime(document.EventDate.Year, document.EventDate.Month, document.EventDate.Day, 23, 59, 59, 500); } } }
/// <summary> /// Creates new <see cref="CommercialWarehouseRelation"/> and attaches it to the parent <see cref="WarehouseDocumentLine"/> or <see cref="CommercialDocumentLine"/>. /// </summary> /// <returns>A new <see cref="CommercialWarehouseRelation"/>.</returns> public override CommercialWarehouseRelation CreateNew() { //create new CommercialWarehouseRelation object and attach it to the element CommercialWarehouseRelation relation = new CommercialWarehouseRelation(this.Parent); CommercialDocument parent = this.Parent as CommercialDocument; if (parent != null) { DocumentCategory dc = parent.DocumentType.DocumentCategory; if (dc == DocumentCategory.Sales || dc == DocumentCategory.SalesCorrection || dc == DocumentCategory.Purchase || dc == DocumentCategory.PurchaseCorrection) { relation.IsCommercialRelation = true; } if (dc == DocumentCategory.Reservation || dc == DocumentCategory.Order) { relation.IsOrderRelation = true; } if (dc == DocumentCategory.Service) { relation.IsServiceRelation = true; } } //add the CommercialWarehouseRelation to the CommercialWarehouseRelation's collection this.Children.Add(relation); return(relation); }
private static FinancialDirection GetFinancialDirectionForPayment(CommercialDocument document, Payment payment) { DocumentCategory category = document.DocumentType.DocumentCategory; if (category == DocumentCategory.Sales || category == DocumentCategory.SalesCorrection) { if (payment.Amount > 0) { return(FinancialDirection.Income); } else { return(FinancialDirection.Outcome); } } else if (category == DocumentCategory.Purchase || category == DocumentCategory.PurchaseCorrection) { if (payment.Amount > 0) { return(FinancialDirection.Outcome); } else { return(FinancialDirection.Income); } } throw new InvalidOperationException("Unknown financial direction to choose"); }
/// <summary> /// Wiąże dwa dokumenty, z których conajmniej jeden może być korektą. /// </summary> /// <param name="previousDocument"></param> /// <param name="nextDocument"></param> /// <param name="last">true jeśli jest to próba powiązania z korygowanym dokumentem - wtedy już musimy powiązanie stworzyć</param> /// <returns>true jeśli udało się powiązać dokumenty, false jeśli nie</returns> public static bool RelateTwoCorrectiveDocuments(CommercialDocument previousDocument, CommercialDocument nextDocument, bool last) { nextDocument.CorrectedDocument = previousDocument; foreach (CommercialDocumentLine line in nextDocument.Lines.Children) { CommercialDocumentLine correctedLine = previousDocument.Lines.Children.Where(l => l.Id.Value == line.CorrectedLine.Id.Value).FirstOrDefault(); if (correctedLine != null) { line.CorrectedLine = correctedLine; } else { correctedLine = nextDocument.Lines.Children.Where(l => l.Id.Value == line.CorrectedLine.Id.Value).FirstOrDefault(); if (correctedLine != null) { line.CorrectedLine = correctedLine; } else if (last) { throw new InvalidOperationException("Cannot find corrected line"); } else { return(false); } } } return(true); }
private void ExecuteCustomLogic(FinancialDocument document) { List <Guid> salesOrders = new List <Guid>(); foreach (var payment in document.Payments) { if (payment.SalesOrderId != null) { var relation = document.Relations.CreateNew(BusinessObjectStatus.New); relation.RelationType = DocumentRelationType.SalesOrderToOutcomeFinancialDocument; relation.RelatedDocument = new CommercialDocument() { Id = payment.SalesOrderId.Value }; relation.DecimalValue = payment.Amount; if (!salesOrders.Contains(payment.SalesOrderId.Value)) { salesOrders.Add(payment.SalesOrderId.Value); CommercialDocument salesOrder = (CommercialDocument)this.mapper.LoadBusinessObject(BusinessObjectType.CommercialDocument, payment.SalesOrderId.Value); DuplicableAttributeFactory.DuplicateAttributes(salesOrder, document); } } } this.MergePayments(document); this.CreateOrUpdateNegativePayment(document); }
private CorrectionInfo[] GetCorrectionInfo(CommercialDocument document) { if (document.Definition.Category == DocumentCategory.InvoiceCorrection) { var correctionInfo = new CorrectionInfo(); var correctionDiff = Math.Abs(document.TotalValueWithoutTax); var taxCorrectionDiff = Math.Abs(document.TotalValueTax); correctionInfo.CorrectionTitle = "Zwrot towaru"; if (document.TotalValueWithoutTax < 0) { correctionInfo.TotalValueCorrectionInfo = $"Kwota zmniejszenia wartości bez podatku: {correctionDiff:N2} PLN"; correctionInfo.TotalTaxCorrectionInfo = $"Kwota zmniejszenia podatku należnego: {taxCorrectionDiff:N2} PLN"; } else if (document.TotalValueWithoutTax > 0) { correctionInfo.TotalValueCorrectionInfo = $"Kwota zwiększenia wartości bez podatku: {correctionDiff:N2} PLN"; correctionInfo.TotalTaxCorrectionInfo = $"Kwota zwiększenia podatku należnego: {taxCorrectionDiff:N2} PLN"; } return(new[] { correctionInfo }); } return(null); }
/// <summary> /// Check if name of technology name is unique /// </summary> /// <param name="document"></param> private void _CheckTechnologyNameExistence(CommercialDocument document) { if (document.DocumentType.DocumentCategory == DocumentCategory.Technology) { DocumentAttrValue technologyNameAttribute = document.Attributes[DocumentFieldName.Attribute_ProductionTechnologyName]; if (technologyNameAttribute != null) { //gdy nowy to walidujemy, gdy edytowany będziemy walidować tylko gdy nazwa się zmieniła bool validateTechnologyName = document.IsNew; string technologyName = technologyNameAttribute.Value.Value; if (!document.IsNew && document.AlternateVersion != null) { DocumentAttrValue altTechnologyNameAttribute = ((CommercialDocument)document.AlternateVersion).Attributes[DocumentFieldName.Attribute_ProductionTechnologyName]; if (altTechnologyNameAttribute != null && technologyName == altTechnologyNameAttribute.Value.Value) { validateTechnologyName = false; } } if (validateTechnologyName) { XDocument xml = XDocument.Parse(String.Format("<root><name>{0}</name></root>", technologyName)); xml = this.mapper.ExecuteStoredProcedure(StoredProcedure.document_p_checkTechnologyNameExistence, true, xml); string result = xml.Root.Value; if (result == "TRUE") { throw new ClientException(ClientExceptionId.ExistingTechnologyName, null, "name:" + technologyName); } } } } }
public void Execute(Document document) { CommercialDocument commercialDocument = (CommercialDocument)document; if (commercialDocument != null) { bool hasSystemCurrency = commercialDocument.HasSystemCurrency; using (ItemCoordinator coordinator = new ItemCoordinator(false, false)) { List <Item> items = new List <Item>(); foreach (CommercialDocumentLine line in commercialDocument.Lines) { Item item = (Item)coordinator.LoadBusinessObject(BusinessObjectType.Item, line.ItemId); decimal lineInitialNetPrice = commercialDocument.GetValueInSystemCurrency(line.InitialNetPrice); if (item.DefaultPrice != lineInitialNetPrice) { item.DefaultPrice = lineInitialNetPrice; items.Add(item); } } if (items.Count > 0) { coordinator.SaveLargeQuantityOfBusinessObjects <Item>(false, items.ToArray()); } } } }
/// <summary> /// Validates the object's consistency. Checks whether the object has all necessary xml nodes. /// </summary> public override void ValidateConsistency() { if (this.PaymentCurrencyId == Guid.Empty) { throw new ClientException(ClientExceptionId.FieldValidationError, null, "fieldName:paymentCurrencyId"); } if (this.SystemCurrencyId == Guid.Empty || this.SystemCurrencyId != ConfigurationMapper.Instance.SystemCurrencyId) { throw new ClientException(ClientExceptionId.FieldValidationError, null, "fieldName:systemCurrencyId"); } bool allowZero = false; CommercialDocument comParent = this.Parent as CommercialDocument; if (comParent != null) { if (comParent.Relations.Where(r => r.RelationType == DocumentRelationType.SalesOrderToInvoice).FirstOrDefault() != null) { allowZero = true; //przepuscmy teraz ten payment, a i tak logika zapisu faktury go wywali } var attrWithProtocole = comParent.Attributes[DocumentFieldName.Attribute_IsSimulateSettlementInvoiceWithProtocole]; if (attrWithProtocole != null && attrWithProtocole.Value != null && attrWithProtocole.Value.Value == "1") { allowZero = true; } } if (this.Amount == 0 && !allowZero) { throw new ClientException(ClientExceptionId.PaymentAmountEqualToZero); } }
public static void CreateCorrectiveDocument(XElement source, CommercialDocument destination) { Guid sourceDocumentId = new Guid(source.Element("correctedDocumentId").Value); DocumentMapper mapper = DependencyContainerManager.Container.Get <DocumentMapper>(); ICollection <Guid> previousDocumentsId = mapper.GetCommercialCorrectiveDocumentsId(sourceDocumentId); CommercialDocument sourceDocument = (CommercialDocument)mapper.LoadBusinessObject(BusinessObjectType.CommercialDocument, sourceDocumentId); CommercialDocument lastDoc = sourceDocument; foreach (Guid corrId in previousDocumentsId) { CommercialDocument correctiveDoc = (CommercialDocument)mapper.LoadBusinessObject(BusinessObjectType.CommercialDocument, corrId); CommercialCorrectiveDocumentFactory.RelateTwoCorrectiveDocuments(lastDoc, correctiveDoc, true); lastDoc = correctiveDoc; } CommercialCorrectiveDocumentFactory.CalculateDocumentsAfterCorrection(lastDoc); CommercialCorrectiveDocumentFactory.CreateNextCorrectiveDocument(lastDoc, destination); DuplicableAttributeFactory.DuplicateAttributes(lastDoc, destination); var salesOrderRelation = sourceDocument.Relations.Where(r => r.RelationType == DocumentRelationType.SalesOrderToInvoice).FirstOrDefault(); if (salesOrderRelation != null) //dokument jest do ZS wiec korekte tez tam podpinamy { var relation = destination.Relations.CreateNew(); relation.RelationType = DocumentRelationType.SalesOrderToCorrectiveCommercialDocument; relation.RelatedDocument = salesOrderRelation.RelatedDocument; } }
private void ExecuteDocumentOptions(CommercialDocument document) { foreach (IDocumentOption option in document.DocumentOptions) { option.Execute(document); } }
public static bool TryCloseSalesOrder(CommercialDocument salesOrder) { if (salesOrder.DocumentType.DocumentCategory != DocumentCategory.SalesOrder) { return(false); } DocumentMapper mapper = DependencyContainerManager.Container.Get <DocumentMapper>(); mapper.AddItemsToItemTypesCache(salesOrder); var dict = SessionManager.VolatileElements.ItemTypesCache; //sprawdzamy czy zamowienie ma wszelkie wz-ty i rw na pozycjach z towarami (pomijamy uslugi) foreach (var line in salesOrder.Lines) { if (!DictionaryMapper.Instance.GetItemType(dict[line.ItemId]).IsWarehouseStorable) { continue; } decimal relQuantity = line.CommercialWarehouseRelations.Sum(r => r.Quantity); if (line.Quantity != relQuantity) { return(false); } } SalesOrderFactory.CloseSalesOrder(salesOrder); salesOrder.DocumentStatus = DocumentStatus.Committed; return(true); }
private static bool IsFinancialToCommercialRelationOneToOne(CommercialDocument document) { foreach (Payment pt in document.Payments.Children.Where(p => p.Status == BusinessObjectStatus.Modified)) { Payment payment = (Payment)pt.AlternateVersion; //dla zmienionych paymentow sprawdzamy czy maja powiazania 1:1 //ale dla ich pierwotnej postaci jaka jest w bazie if (DictionaryMapper.Instance.IsPaymentMethodSupportedByRegister(payment.PaymentMethodId.Value, SessionManager.User.BranchId)) { PaymentSettlement settlement = payment.Settlements.Children.FirstOrDefault(); //sprawdzamy czy ma powiazanie z finansowym if (payment.Settlements.Children.Count != 1) { return(false); } if (settlement.Amount != Math.Abs(payment.Amount)) { return(false); } if (Math.Abs(settlement.RelatedPayment.Amount) != Math.Abs(payment.Amount)) { return(false); } //if (settlement.RelatedPayment.Date != document.IssueDate) if (!settlement.IsAutoGenerated) { return(false); } int allPaymentsCount = 0; if (settlement.RelatedPayment.Parent.BOType == BusinessObjectType.FinancialDocument) { allPaymentsCount = ((FinancialDocument)settlement.RelatedPayment.Parent).Payments.Children.Count; } else { return(false); } // Daje komentarz bo wywala się zawsze dla karty rozliczanej na minus automatycznie. // Suma paymentów sie zgadza wiec pozostaje kwestia automatycznej aktualizacji // if (allPaymentsCount != 1) // return false; } else //rejestry nieobslugiwane musza byc nierozliczone { if (payment.Settlements.Children.Count != 0) { return(false); } } } return(true); }
public static void ConfigureMappings(IMapperConfigurationExpression cfg) { Common.ConfigureMappings(cfg); Address.ConfigureMappings(cfg); Customer.ConfigureMappings(cfg); CommercialDocument.ConfigureMappings(cfg); Product.ConfigureMappings(cfg); }
public static void GenerateSalesOrderFromBill(XElement source, CommercialDocument destination) { Guid docId = new Guid(source.Element("salesDocumentId").Value); DocumentMapper mapper = DependencyContainerManager.Container.Get <DocumentMapper>(); CommercialDocument doc = (CommercialDocument)mapper.LoadBusinessObject(BusinessObjectType.CommercialDocument, docId); SalesOrderFactory.CopyLinesToSalesOrder(doc, destination); }
private AttachmentData CreateDocumentPdfAttachment(CommercialDocument document) { return(new AttachmentData { Content = DependencyProvider.Resolve <IEnovaService>().ExportDocumentToPdf(document), FileName = document.DocumentNumber.Replace('/', '_') + ".pdf" }); }
public static void CalculateDocumentsAfterCorrection(CommercialDocument lastCorrectiveDocument) { foreach (CommercialDocumentLine line in lastCorrectiveDocument.Lines.Children) { CommercialCorrectiveDocumentFactory.CalculateLineAfterCorrection(line); } CommercialCorrectiveDocumentFactory.CalculateHeaderAndVatTableAfterCorrection(lastCorrectiveDocument); }
private void ProcessShiftOrder(WarehouseDocument document) { var attr = document.Attributes[DocumentFieldName.Attribute_IncomeShiftOrderId]; if (attr != null && document.IsNew) { CommercialDocument shiftOrder = (CommercialDocument)this.mapper.LoadBusinessObject(BusinessObjectType.CommercialDocument, new Guid(attr.Value.Value)); foreach (var whLine in document.Lines) { decimal quantityToGo = whLine.Quantity; foreach (var comLine in shiftOrder.Lines) { if (quantityToGo == 0) { break; } if (whLine.ItemId == comLine.ItemId) { decimal unrealizedQty = comLine.Quantity - comLine.CommercialWarehouseRelations.Sum(r => r.Quantity); if (unrealizedQty > quantityToGo) { var relation = whLine.CommercialWarehouseRelations.CreateNew(); relation.RelatedLine = comLine; relation.IsOrderRelation = true; relation.Quantity = quantityToGo; relation = comLine.CommercialWarehouseRelations.CreateNew(); relation.RelatedLine = whLine; relation.IsOrderRelation = true; relation.Quantity = quantityToGo; relation.DontSave = true; quantityToGo = 0; } else if (unrealizedQty > 0) //unrealizedQty <= quantityToGo { var relation = whLine.CommercialWarehouseRelations.CreateNew(); relation.RelatedLine = comLine; relation.IsOrderRelation = true; relation.Quantity = unrealizedQty; relation = comLine.CommercialWarehouseRelations.CreateNew(); relation.RelatedLine = whLine; relation.IsOrderRelation = true; relation.Quantity = unrealizedQty; relation.DontSave = true; quantityToGo -= unrealizedQty; } } } } } }
private string GetTemplateNameForPrepaidInvoice(CommercialDocument salesOrder) { XElement process = this.GetProcess(salesOrder); if (process.Element("configuration") == null || process.Element("configuration").Element("prepaidTemplate") == null) { throw new InvalidOperationException("No prepaid template"); } return(process.Element("configuration").Element("prepaidTemplate").Value); }
private MailData PrepareMailData(CommercialDocument document) { var mailData = new MailData(); mailData.MailTo = document.Customer.Email; mailData.MailToName = document.Customer.Code; mailData.MailSubject = "ABAK DOKUMENTY"; mailData.Attachments.Add(CreateDocumentPdfAttachment(document)); return(mailData); }
public byte[] ExportDocumentToPdf(CommercialDocument document) { if (document != null) { return(_documentPrinterService.ExportToPdf( GetDocumentTemplatePath(document), GetDataSources(document), GetParameters(document))); } return(null); }
public static void GenerateFinancialDocumentToCommercialDocument(CommercialDocument document) { if (document == null) { return; } foreach (Payment payment in document.Payments.Children) { FinancialDocumentFactory.GenerateFinancialDocumentToPayment(payment, document); } }
private void CheckIsInvoiceCorrectionSupported(CommercialDocument document) { foreach (var row in document.Rows) { if (row.CorrectionType != PositionCorrectionType.None) { if (!(row.CorrectionType == PositionCorrectionType.Quantity || row.CorrectionType == PositionCorrectionType.Return)) { throw new NotSupportedException("Faktura korygująca z korektą ceny nie jest obsługiwana w wydrukach Tools-ów. Musisz wydrukować ją w Enova-ej."); } } } }
public decimal GetMaxSettlementDifference(CommercialDocument document) { XElement process = this.GetProcess(document); XElement element = process.Element("configuration").Element("maxSettlementDifference"); if (element != null && element.Value.Length != 0) { return(Convert.ToDecimal(element.Value, CultureInfo.InvariantCulture)); } else { return(0); } }
private static void CopyLinesToSalesOrder(CommercialDocument salesOrder, CommercialDocument destination) { List <Guid> items = new List <Guid>(); foreach (var srcLine in salesOrder.Lines) { items.Add(srcLine.ItemId); var dstLine = destination.Lines.CreateNew(); dstLine.Tag = srcLine.Id.ToUpperString(); dstLine.DiscountGrossValue = srcLine.DiscountGrossValue; dstLine.DiscountNetValue = srcLine.DiscountNetValue; dstLine.DiscountRate = srcLine.DiscountRate; dstLine.GrossPrice = srcLine.GrossPrice; dstLine.GrossValue = srcLine.GrossValue; dstLine.InitialGrossPrice = srcLine.InitialGrossPrice; dstLine.InitialGrossValue = srcLine.InitialGrossValue; dstLine.InitialNetPrice = srcLine.InitialNetPrice; dstLine.InitialNetValue = srcLine.InitialNetValue; dstLine.ItemCode = srcLine.ItemCode; dstLine.ItemId = srcLine.ItemId; dstLine.ItemName = srcLine.ItemName; dstLine.ItemVersion = srcLine.ItemVersion; dstLine.NetPrice = srcLine.NetPrice; dstLine.NetValue = srcLine.NetValue; dstLine.Quantity = srcLine.Quantity; dstLine.UnitId = srcLine.UnitId; dstLine.VatRateId = srcLine.VatRateId; dstLine.VatValue = srcLine.VatValue; dstLine.ItemTypeId = srcLine.ItemTypeId; dstLine.WarehouseId = srcLine.WarehouseId; dstLine.Calculate(dstLine.Quantity, dstLine.InitialNetPrice, dstLine.DiscountRate, dstLine.InitialGrossPrice); //CommercialDocumentFactory.TryAddRealizedSalesOrderLineId(srcLine, dstLine, isSalesOrderRealization); } destination.Calculate(); XDocument xml = new XDocument(new XElement("root")); foreach (var line in destination.Lines) { XElement item = xml.Root.Elements().Where(x => x.Attribute("id").Value == line.ItemId.ToUpperString()).FirstOrDefault(); if (item != null) { line.ItemVersion = new Guid(item.Attribute("version").Value); } } }
private Dictionary <string, object> GetDataSources(CommercialDocument document) { return(new Dictionary <string, object> { { "Document", new[] { document } }, { "Definition", new [] { document.Definition } }, { "Customer", new[] { document.Customer } }, { "CustomerAddress", new[] { document.Customer.MainAddress } }, { "Rows", document.Rows }, { "Taxes", document.TaxesSummary }, { "Payments", document.PaymentSummary }, { "CorrectionInfo", GetCorrectionInfo(document) }, { "CorrectedDocument", document.CorrectedDocument != null ? new[] { document.CorrectedDocument } : Array.Empty <CommercialDocument>() } }); }