/*<ControllerActionImplementation:ImportLekosCSV:1/>*/
        public ActionResult ExecuteImportLekosCSV()
        {
            ActionResult _result = null;
            string       pathCSV = zAppDev.DotNet.Framework.Utilities.Web.MapPath(System.IO.Path.Combine("~/App_Data/Uploads", @model.LekosPath));

            if ((pathCSV?.Contains("LEKOS") ?? false))
            {
                zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "DeveloperTools", DSS5_SupplyChainFinancialsOptimisation.Hubs.EventsHub.RaiseDebugMessage, "LEKOS File Import");
                int?     rowCount       = 0;
                string[] entries        = null;
                string[] productEntries = null;
                int?     test           = 0;
                DSS5_SupplyChainFinancialsOptimisation.BO.CommercialAgreement commercialAgreement = new DSS5_SupplyChainFinancialsOptimisation.BO.CommercialAgreement();
                DSS5_SupplyChainFinancialsOptimisation.BO.Order newOrder = new DSS5_SupplyChainFinancialsOptimisation.BO.Order();
                System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.OrderProduct> products = new System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.OrderProduct>();
                commercialAgreement.Supplier = new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().GetAsQueryable <DSS5_SupplyChainFinancialsOptimisation.BO.Supplier>((a) => a.UserName == "Supplier25")?.FirstOrDefault();
                System.Collections.Generic.List <string> delim = new System.Collections.Generic.List <string>();
                delim.Add("\r");
                delim.Add("\n");
                foreach (var row in System.IO.File.ReadAllText(pathCSV).SplitExtended(delim.ToArray(), true) ?? Enumerable.Empty <string>())
                {
                    if (((((row == null || row == "")) == false) && (((row == null || row.Trim() == "")) == false)))
                    {
                        entries = row?.SplitExtended(';', false);
                        if ((entries.Length > 0))
                        {
                            if (zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 0).StartsWith("Α-ΔΑ"))
                            {
                                zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "DeveloperTools", DSS5_SupplyChainFinancialsOptimisation.Hubs.EventsHub.RaiseDebugMessage, "Found Delivery Note");
                                newOrder.PaymentTerms = "";
                                DSS5_SupplyChainFinancialsOptimisation.BO.DeliveryNote newDeliveryNote = new DSS5_SupplyChainFinancialsOptimisation.BO.DeliveryNote();
                                newDeliveryNote.DeliveryNoteNumber = zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 0);
                                newDeliveryNote.Description        = zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 1);
                                newDeliveryNote.DateIssued         = zAppDev.DotNet.Framework.Utilities.Common.ParseExactDate(zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 2), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture).GetValueOrDefault(System.Data.SqlTypes.SqlDateTime.MinValue.Value);
                                newDeliveryNote.Amount             = zAppDev.DotNet.Framework.Utilities.Common.ConvertToDecimal(zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 14));
                                newOrder?.AddDeliveryNotes(newDeliveryNote);
                                commercialAgreement?.AddOrders(newOrder);
                            }
                            else if (zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 0).StartsWith("Α-ΠΑ"))
                            {
                                zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "DeveloperTools", DSS5_SupplyChainFinancialsOptimisation.Hubs.EventsHub.RaiseDebugMessage, "Found Order");
                                newOrder.OrderNumber  = zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 0);
                                newOrder.DateOfOrder  = zAppDev.DotNet.Framework.Utilities.Common.ParseExactDate(zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 2), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture).GetValueOrDefault(System.Data.SqlTypes.SqlDateTime.MinValue.Value);
                                newOrder.PaymentTerms = zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 10);
                                commercialAgreement?.AddOrders(newOrder);
                            }
                            else if (zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 0).StartsWith("Α-ΤΔ"))
                            {
                                zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "DeveloperTools", DSS5_SupplyChainFinancialsOptimisation.Hubs.EventsHub.RaiseDebugMessage, "Found Delivery Note & Invoice");
                                newOrder.PaymentTerms = "";
                                DSS5_SupplyChainFinancialsOptimisation.BO.DeliveryNote newDeliveryNote = new DSS5_SupplyChainFinancialsOptimisation.BO.DeliveryNote();
                                newDeliveryNote.DeliveryNoteNumber = zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 0);
                                newDeliveryNote.Description        = zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 1);
                                newDeliveryNote.DateIssued         = zAppDev.DotNet.Framework.Utilities.Common.ParseExactDate(zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 2), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture).GetValueOrDefault(System.Data.SqlTypes.SqlDateTime.MinValue.Value);
                                newDeliveryNote.Amount             = zAppDev.DotNet.Framework.Utilities.Common.ConvertToDecimal(zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 14));
                                newOrder?.AddDeliveryNotes(newDeliveryNote);
                                DSS5_SupplyChainFinancialsOptimisation.BO.Invoice newInvoice = new DSS5_SupplyChainFinancialsOptimisation.BO.Invoice();
                                newInvoice.InvoiceNumber = zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 0);
                                newInvoice.Description   = zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 1);
                                newInvoice.DateIssued    = zAppDev.DotNet.Framework.Utilities.Common.ParseExactDate(zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 2), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture).GetValueOrDefault(System.Data.SqlTypes.SqlDateTime.MinValue.Value);
                                newInvoice.Amount        = zAppDev.DotNet.Framework.Utilities.Common.ConvertToDecimal(zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 14));
                                newOrder?.AddInvoices(newInvoice);
                                commercialAgreement?.AddOrders(newOrder);
                            }
                            else if (zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 0).StartsWith("Α-ΤΠ"))
                            {
                                zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "DeveloperTools", DSS5_SupplyChainFinancialsOptimisation.Hubs.EventsHub.RaiseDebugMessage, "Found Invoice");
                                newOrder.PaymentTerms = "";
                                DSS5_SupplyChainFinancialsOptimisation.BO.Invoice newInvoice = new DSS5_SupplyChainFinancialsOptimisation.BO.Invoice();
                                newInvoice.InvoiceNumber = zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 0);
                                newInvoice.Description   = zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 1);
                                newInvoice.DateIssued    = zAppDev.DotNet.Framework.Utilities.Common.ParseExactDate(zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 2), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture).GetValueOrDefault(System.Data.SqlTypes.SqlDateTime.MinValue.Value);
                                newInvoice.Amount        = zAppDev.DotNet.Framework.Utilities.Common.ConvertToDecimal(zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 14));
                                newOrder?.AddInvoices(newInvoice);
                                commercialAgreement?.AddOrders(newOrder);
                            }
                            else if (zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 0).StartsWith("Χ-Α"))
                            {
                                zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "DeveloperTools", DSS5_SupplyChainFinancialsOptimisation.Hubs.EventsHub.RaiseDebugMessage, "Found Cancelled Order");
                                newOrder.PaymentTerms = "";
                                DSS5_SupplyChainFinancialsOptimisation.BO.CreditNote crNote = new DSS5_SupplyChainFinancialsOptimisation.BO.CreditNote();
                                crNote.CreditNoteNumber = zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 0);
                                crNote.Description      = zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 1);
                                crNote.DateIssued       = zAppDev.DotNet.Framework.Utilities.Common.ParseExactDate(zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 2), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture).GetValueOrDefault(System.Data.SqlTypes.SqlDateTime.MinValue.Value);
                                crNote.TotalPrice       = zAppDev.DotNet.Framework.Utilities.Common.ConvertToDecimal(zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 14));
                                newOrder?.AddCreditNotes(crNote);
                                commercialAgreement?.AddOrders(newOrder);
                            }
                            else if (zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 0).StartsWith("Ε-ΤΠ"))
                            {
                                zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "DeveloperTools", DSS5_SupplyChainFinancialsOptimisation.Hubs.EventsHub.RaiseDebugMessage, "Found EU Invoice");
                                newOrder.PaymentTerms = "";
                                DSS5_SupplyChainFinancialsOptimisation.BO.Invoice newInvoice = new DSS5_SupplyChainFinancialsOptimisation.BO.Invoice();
                                newInvoice.InvoiceNumber = zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 0);
                                newInvoice.Description   = zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 1);
                                newInvoice.DateIssued    = zAppDev.DotNet.Framework.Utilities.Common.ParseExactDate(zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 2), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture).GetValueOrDefault(System.Data.SqlTypes.SqlDateTime.MinValue.Value);
                                newInvoice.Amount        = zAppDev.DotNet.Framework.Utilities.Common.ConvertToDecimal(zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(entries, 14));
                                newInvoice.CustomerType  = "EU Customer";
                                newOrder?.AddInvoices(newInvoice);
                                commercialAgreement?.AddOrders(newOrder);
                            }
                        }
                        else
                        {
                            zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Info, "DeveloperTools", DSS5_SupplyChainFinancialsOptimisation.Hubs.EventsHub.RaiseDebugMessage, "Row: " + (rowCount?.ToString() ?? "") + "does not have 2 entries.");
                        }
                    }
                    else
                    {
                        zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Info, "DeveloperTools", DSS5_SupplyChainFinancialsOptimisation.Hubs.EventsHub.RaiseDebugMessage, "Row " + (rowCount?.ToString() ?? "") + " did not have value.");
                    }
                    if (rowCount > 0)
                    {
                        zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Info, "DeveloperTools", DSS5_SupplyChainFinancialsOptimisation.Hubs.EventsHub.RaiseDebugMessage, "product----> " + row);
                        productEntries = row?.SplitExtended(';', false);
                        DSS5_SupplyChainFinancialsOptimisation.BO.OrderProduct product = new DSS5_SupplyChainFinancialsOptimisation.BO.OrderProduct();
                        product.Code            = zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(productEntries, 0);
                        product.Description     = zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(productEntries, 1);
                        product.MeasurementUnit = zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(productEntries, 2);
                        products?.Add(product);
                        product.Quantity = zAppDev.DotNet.Framework.Utilities.Common.ConvertToDecimal(zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(productEntries, 3));
                    }
                    rowCount = rowCount.GetValueOrDefault(0) + 1;
                    commercialAgreement?.AddOrders(newOrder);
                    new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().Save <DSS5_SupplyChainFinancialsOptimisation.BO.CommercialAgreement>(commercialAgreement);
                }
                zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "DeveloperTools", DSS5_SupplyChainFinancialsOptimisation.Hubs.EventsHub.RaiseDebugMessage, "Rowcount " + (rowCount?.ToString() ?? ""));
            }
            return(_result);
        }
        public void DeliveryNote_persistence_test()
        {
            DateTime now = DateTime.Now;

            // Get datetime without milliseconds
            now = new DateTime(now.Ticks - (now.Ticks % TimeSpan.TicksPerSecond), now.Kind);
            var _deliverynote_products_deliverynote = new DSS5_SupplyChainFinancialsOptimisation.BO.OrderProduct
            {
                Code            = "OrderProduct_Code",
                Quantity        = 222222.22M,
                Description     = "OrderProduct_Description",
                UnitValue       = "OrderProduct_UnitValue",
                MeasurementUnit = "OrderProduct_MeasurementUnit",
                Price           = 222222.22M,
                LineTotalPrice  = 222222.22M,
            };
            var _deliverynote_products_deliverynote2 = new DSS5_SupplyChainFinancialsOptimisation.BO.OrderProduct
            {
                Code            = "OrderProduct_Code",
                Quantity        = 222222.22M,
                Description     = "OrderProduct_Description",
                UnitValue       = "OrderProduct_UnitValue",
                MeasurementUnit = "OrderProduct_MeasurementUnit",
                Price           = 222222.22M,
                LineTotalPrice  = 222222.22M,
            };
            var _deliverynote_deliverynoteproducts_deliverynote = new DSS5_SupplyChainFinancialsOptimisation.BO.DeliveryNoteProduct
            {
                Code            = "DeliveryNoteProduct_Code",
                Quantity        = 222222.22M,
                Description     = "DeliveryNoteProduct_Description",
                UnitValue       = "DeliveryNoteProduct_UnitValue",
                MeasurementUnit = "DeliveryNoteProduct_MeasurementUnit",
                Price           = 222222.22M,
                LineTotalPrice  = 222222.22M,
            };
            var _deliverynote_deliverynoteproducts_deliverynote2 = new DSS5_SupplyChainFinancialsOptimisation.BO.DeliveryNoteProduct
            {
                Code            = "DeliveryNoteProduct_Code",
                Quantity        = 222222.22M,
                Description     = "DeliveryNoteProduct_Description",
                UnitValue       = "DeliveryNoteProduct_UnitValue",
                MeasurementUnit = "DeliveryNoteProduct_MeasurementUnit",
                Price           = 222222.22M,
                LineTotalPrice  = 222222.22M,
            };
            var _order_orders_deliverynotes = new DSS5_SupplyChainFinancialsOptimisation.BO.Order
            {
                OrderNumber             = "Order_OrderNumber",
                EstimatedDateOfDelivery = now,
                PaymentTerms            = "Order_PaymentTerms",
                IntermediateParty       = true,
                IsCancelled             = true,
                DateOfOrder             = now,
                OrderAmount             = 2222222222.22222M,
                TotalPrice      = 2222222222.22222M,
                From            = "Order_From",
                DeliveryTo      = "Order_DeliveryTo",
                OrderAttachment = "Order_OrderAttachment",
            };
            var _order_orders_deliverynotes2 = new DSS5_SupplyChainFinancialsOptimisation.BO.Order
            {
                OrderNumber             = "Order_OrderNumber",
                EstimatedDateOfDelivery = now,
                PaymentTerms            = "Order_PaymentTerms",
                IntermediateParty       = true,
                IsCancelled             = true,
                DateOfOrder             = now,
                OrderAmount             = 2222222222.22222M,
                TotalPrice      = 2222222222.22222M,
                From            = "Order_From",
                DeliveryTo      = "Order_DeliveryTo",
                OrderAttachment = "Order_OrderAttachment",
            };
            var _transaction_transaction_deliverynotes = new DSS5_SupplyChainFinancialsOptimisation.BO.Transaction
            {
                TransactionDateOccured = now,
                TransactionValue       = 2222222222.22222M,
                FundedAmount           = 2222222222.22222M,
                ToBePaidAmount         = 2222222222.22222M,
                InvoicedDate           = now,
                PaymentStatus          = "Transaction_PaymentStatus",
                PaymentDate            = now,
                RestPaymentAmount      = 2222222222.22222M,
                PaidByBuyer            = true,
            };

            new PersistenceSpecification <DSS5_SupplyChainFinancialsOptimisation.BO.DeliveryNote>(Session)
            .CheckProperty(p => p.DeliveryNoteNumber, "DeliveryNote_DeliveryNoteNumber")
            .CheckProperty(p => p.Description, "DeliveryNote_Description")
            .CheckProperty(p => p.DateIssued, now)
            .CheckProperty(p => p.Amount, 2222222222222.22M)
            .CheckProperty(p => p.TotalPrice, 222222.22M)
            .CheckProperty(p => p.DNoteAttachment, "DeliveryNote_DNoteAttachment")
            .CheckBag(p => p.Products, (new List <DSS5_SupplyChainFinancialsOptimisation.BO.OrderProduct>
            {
                _deliverynote_products_deliverynote,
                _deliverynote_products_deliverynote2
            }))
            .CheckBag(p => p.DeliveryNoteProducts, (new List <DSS5_SupplyChainFinancialsOptimisation.BO.DeliveryNoteProduct>
            {
                _deliverynote_deliverynoteproducts_deliverynote,
                _deliverynote_deliverynoteproducts_deliverynote2
            }))
            .CheckBag(p => p.Orders, (new List <DSS5_SupplyChainFinancialsOptimisation.BO.Order>
            {
                _order_orders_deliverynotes,
                _order_orders_deliverynotes2
            }))
            .CheckReference(p => p.Transaction, _transaction_transaction_deliverynotes)
            .VerifyTheMappings();
        }
Exemple #3
0
/// <summary>
///     Returns true if self and the provided entity have the same Id values
///     and the Ids are not of the default Id value
/// </summary>
        protected bool HasSameNonDefaultIdAs(OrderProduct compareTo)
        {
            return(!this.IsTransient() && !compareTo.IsTransient() && this.Id.Equals(compareTo.Id));
        }
        public void Order_persistence_test()
        {
            DateTime now = DateTime.Now;

            // Get datetime without milliseconds
            now = new DateTime(now.Ticks - (now.Ticks % TimeSpan.TicksPerSecond), now.Kind);
            var _agreement_commercialagreement_orders = new DSS5_SupplyChainFinancialsOptimisation.BO.CommercialAgreement
            {
                ProductCategory = "CommercialAgreement_ProductCategory",
                PaymentTerms    = "CommercialAgreement_PaymentTerms",
            };
            var _order_orderproducts_order = new DSS5_SupplyChainFinancialsOptimisation.BO.OrderProduct
            {
                Code            = "OrderProduct_Code",
                Quantity        = 222222.22M,
                Description     = "OrderProduct_Description",
                UnitValue       = "OrderProduct_UnitValue",
                MeasurementUnit = "OrderProduct_MeasurementUnit",
                Price           = 222222.22M,
                LineTotalPrice  = 222222.22M,
            };
            var _order_orderproducts_order2 = new DSS5_SupplyChainFinancialsOptimisation.BO.OrderProduct
            {
                Code            = "OrderProduct_Code",
                Quantity        = 222222.22M,
                Description     = "OrderProduct_Description",
                UnitValue       = "OrderProduct_UnitValue",
                MeasurementUnit = "OrderProduct_MeasurementUnit",
                Price           = 222222.22M,
                LineTotalPrice  = 222222.22M,
            };
            var _order_proofofdeliveries_orders = new DSS5_SupplyChainFinancialsOptimisation.BO.ProofOfDelivery
            {
                PODNumber      = "ProofOfDelivery_PODNumber",
                DateIssued     = now,
                QualityStatus  = "ProofOfDelivery_QualityStatus",
                QuantityStatus = "ProofOfDelivery_QuantityStatus",
                DeliveryStatus = "ProofOfDelivery_DeliveryStatus",
                PODAttachment  = "ProofOfDelivery_PODAttachment",
                Comments       = "ProofOfDelivery_Comments",
            };
            var _order_proofofdeliveries_orders2 = new DSS5_SupplyChainFinancialsOptimisation.BO.ProofOfDelivery
            {
                PODNumber      = "ProofOfDelivery_PODNumber",
                DateIssued     = now,
                QualityStatus  = "ProofOfDelivery_QualityStatus",
                QuantityStatus = "ProofOfDelivery_QuantityStatus",
                DeliveryStatus = "ProofOfDelivery_DeliveryStatus",
                PODAttachment  = "ProofOfDelivery_PODAttachment",
                Comments       = "ProofOfDelivery_Comments",
            };
            var _order_invoices_orders = new DSS5_SupplyChainFinancialsOptimisation.BO.Invoice
            {
                InvoiceNumber     = "Invoice_InvoiceNumber",
                Description       = "Invoice_Description",
                DateIssued        = now,
                Amount            = 2222222222222.22M,
                CustomerType      = "Invoice_CustomerType",
                CumulativeBalance = 222222.22M,
                TotalPrice        = 222222.22M,
                DescriptionTwo    = "Invoice_DescriptionTwo",
                Attribute         = "Invoice_Attribute",
                InvoiceAttachment = "Invoice_InvoiceAttachment",
            };
            var _order_invoices_orders2 = new DSS5_SupplyChainFinancialsOptimisation.BO.Invoice
            {
                InvoiceNumber     = "Invoice_InvoiceNumber",
                Description       = "Invoice_Description",
                DateIssued        = now,
                Amount            = 2222222222222.22M,
                CustomerType      = "Invoice_CustomerType",
                CumulativeBalance = 222222.22M,
                TotalPrice        = 222222.22M,
                DescriptionTwo    = "Invoice_DescriptionTwo",
                Attribute         = "Invoice_Attribute",
                InvoiceAttachment = "Invoice_InvoiceAttachment",
            };
            var _order_deliverynotes_orders = new DSS5_SupplyChainFinancialsOptimisation.BO.DeliveryNote
            {
                DeliveryNoteNumber = "DeliveryNote_DeliveryNoteNumber",
                Description        = "DeliveryNote_Description",
                DateIssued         = now,
                Amount             = 2222222222222.22M,
                TotalPrice         = 222222.22M,
                DNoteAttachment    = "DeliveryNote_DNoteAttachment",
            };
            var _order_deliverynotes_orders2 = new DSS5_SupplyChainFinancialsOptimisation.BO.DeliveryNote
            {
                DeliveryNoteNumber = "DeliveryNote_DeliveryNoteNumber",
                Description        = "DeliveryNote_Description",
                DateIssued         = now,
                Amount             = 2222222222222.22M,
                TotalPrice         = 222222.22M,
                DNoteAttachment    = "DeliveryNote_DNoteAttachment",
            };
            var _order_orderstatus_order = new DSS5_SupplyChainFinancialsOptimisation.BO.OrderStatus
            {
                OrderdDateOccured = now,
                Status            = "OrderStatus_Status",
                PaymentStatus     = true,
                InitialOrdered    = true,
                FinalOrdered      = true,
            };
            var _order_finalacceptancecertificate_order = new DSS5_SupplyChainFinancialsOptimisation.BO.FinalAcceptanceCertificate
            {
                Certificate = "FinalAcceptanceCertificate_Certificate",
            };
            var _order_creditnotes_orders = new DSS5_SupplyChainFinancialsOptimisation.BO.CreditNote
            {
                CreditNoteNumber   = "CreditNote_CreditNoteNumber",
                Description        = "CreditNote_Description",
                DateIssued         = now,
                Amount             = 2222222222.22222M,
                TotalPrice         = 2222222222.22222M,
                CreditNoteDocument = "CreditNote_CreditNoteDocument",
                CNoteAttachment    = "CreditNote_CNoteAttachment",
            };
            var _order_creditnotes_orders2 = new DSS5_SupplyChainFinancialsOptimisation.BO.CreditNote
            {
                CreditNoteNumber   = "CreditNote_CreditNoteNumber",
                Description        = "CreditNote_Description",
                DateIssued         = now,
                Amount             = 2222222222.22222M,
                TotalPrice         = 2222222222.22222M,
                CreditNoteDocument = "CreditNote_CreditNoteDocument",
                CNoteAttachment    = "CreditNote_CNoteAttachment",
            };
            var _order_orderpayment_order = new DSS5_SupplyChainFinancialsOptimisation.BO.OrderPayment
            {
                PaymentAmount = 2222222222.22222M,
                DateIssued    = now,
            };
            var _order_orderpayment_order2 = new DSS5_SupplyChainFinancialsOptimisation.BO.OrderPayment
            {
                PaymentAmount = 2222222222.22222M,
                DateIssued    = now,
            };
            var _order_letterofcredits_orders = new DSS5_SupplyChainFinancialsOptimisation.BO.LetterOfCredit
            {
                ValueOfLoC     = 222222.22M,
                IssuingBank    = "LetterOfCredit_IssuingBank",
                Detail         = "LetterOfCredit_Detail",
                UploadOfScan   = "LetterOfCredit_UploadOfScan",
                Calculated     = 222222.22M,
                DateOfValidity = now,
                DateOfExpiry   = now,
            };
            var _order_letterofcredits_orders2 = new DSS5_SupplyChainFinancialsOptimisation.BO.LetterOfCredit
            {
                ValueOfLoC     = 222222.22M,
                IssuingBank    = "LetterOfCredit_IssuingBank",
                Detail         = "LetterOfCredit_Detail",
                UploadOfScan   = "LetterOfCredit_UploadOfScan",
                Calculated     = 222222.22M,
                DateOfValidity = now,
                DateOfExpiry   = now,
            };
            var _order_billoflandings_orders = new DSS5_SupplyChainFinancialsOptimisation.BO.BillOfLanding
            {
                LandingPlace     = "BillOfLanding_LandingPlace",
                LandingDate      = now,
                DeliveryPlace    = "BillOfLanding_DeliveryPlace",
                DeliveryDate     = now,
                DOCNumber        = 5961,
                ReceivingPartyId = 7650,
                IsBuyerReceiving = true,
            };
            var _order_billoflandings_orders2 = new DSS5_SupplyChainFinancialsOptimisation.BO.BillOfLanding
            {
                LandingPlace     = "BillOfLanding_LandingPlace",
                LandingDate      = now,
                DeliveryPlace    = "BillOfLanding_DeliveryPlace",
                DeliveryDate     = now,
                DOCNumber        = 8301,
                ReceivingPartyId = 2374,
                IsBuyerReceiving = true,
            };
            var _order_intermediaries_orders = new DSS5_SupplyChainFinancialsOptimisation.BO.Intermediary
            {
                OtherDescription = "Intermediary_OtherDescription",
                Company          = "Intermediary_Company",
                EMail            = "Intermediary_EMail",
                GUID             = "Intermediary_GUID",
            };
            var _order_intermediaries_orders2 = new DSS5_SupplyChainFinancialsOptimisation.BO.Intermediary
            {
                OtherDescription = "Intermediary_OtherDescription",
                Company          = "Intermediary_Company",
                EMail            = "Intermediary_EMail",
                GUID             = "Intermediary_GUID",
            };
            var _transaction_transaction_orders = new DSS5_SupplyChainFinancialsOptimisation.BO.Transaction
            {
                TransactionDateOccured = now,
                TransactionValue       = 2222222222.22222M,
                FundedAmount           = 2222222222.22222M,
                ToBePaidAmount         = 2222222222.22222M,
                InvoicedDate           = now,
                PaymentStatus          = "Transaction_PaymentStatus",
                PaymentDate            = now,
                RestPaymentAmount      = 2222222222.22222M,
                PaidByBuyer            = true,
            };

            new PersistenceSpecification <DSS5_SupplyChainFinancialsOptimisation.BO.Order>(Session)
            .CheckProperty(p => p.OrderNumber, "Order_OrderNumber")
            .CheckProperty(p => p.EstimatedDateOfDelivery, now)
            .CheckProperty(p => p.PaymentTerms, "Order_PaymentTerms")
            .CheckProperty(p => p.IntermediateParty, true)
            .CheckProperty(p => p.IsCancelled, true)
            .CheckProperty(p => p.DateOfOrder, now)
            .CheckProperty(p => p.OrderAmount, 2222222222.22222M)
            .CheckProperty(p => p.TotalPrice, 2222222222.22222M)
            .CheckProperty(p => p.From, "Order_From")
            .CheckProperty(p => p.DeliveryTo, "Order_DeliveryTo")
            .CheckProperty(p => p.OrderAttachment, "Order_OrderAttachment")
            .CheckReference(p => p.CommercialAgreement, _agreement_commercialagreement_orders)
            .CheckBag(p => p.OrderProducts, (new List <DSS5_SupplyChainFinancialsOptimisation.BO.OrderProduct>
            {
                _order_orderproducts_order,
                _order_orderproducts_order2
            }))
            .CheckBag(p => p.ProofOfDeliveries, (new List <DSS5_SupplyChainFinancialsOptimisation.BO.ProofOfDelivery>
            {
                _order_proofofdeliveries_orders,
                _order_proofofdeliveries_orders2
            }))
            .CheckBag(p => p.Invoices, (new List <DSS5_SupplyChainFinancialsOptimisation.BO.Invoice>
            {
                _order_invoices_orders,
                _order_invoices_orders2
            }))
            .CheckBag(p => p.DeliveryNotes, (new List <DSS5_SupplyChainFinancialsOptimisation.BO.DeliveryNote>
            {
                _order_deliverynotes_orders,
                _order_deliverynotes_orders2
            }))
            .CheckReference(p => p.OrderStatus, _order_orderstatus_order)
            .CheckReference(p => p.FinalAcceptanceCertificate, _order_finalacceptancecertificate_order)
            .CheckBag(p => p.CreditNotes, (new List <DSS5_SupplyChainFinancialsOptimisation.BO.CreditNote>
            {
                _order_creditnotes_orders,
                _order_creditnotes_orders2
            }))
            .CheckBag(p => p.OrderPayment, (new List <DSS5_SupplyChainFinancialsOptimisation.BO.OrderPayment>
            {
                _order_orderpayment_order,
                _order_orderpayment_order2
            }))
            .CheckBag(p => p.LetterOfCredits, (new List <DSS5_SupplyChainFinancialsOptimisation.BO.LetterOfCredit>
            {
                _order_letterofcredits_orders,
                _order_letterofcredits_orders2
            }))
            .CheckBag(p => p.BillOfLandings, (new List <DSS5_SupplyChainFinancialsOptimisation.BO.BillOfLanding>
            {
                _order_billoflandings_orders,
                _order_billoflandings_orders2
            }))
            .CheckBag(p => p.Intermediaries, (new List <DSS5_SupplyChainFinancialsOptimisation.BO.Intermediary>
            {
                _order_intermediaries_orders,
                _order_intermediaries_orders2
            }))
            .CheckReference(p => p.Transaction, _transaction_transaction_orders)
            .VerifyTheMappings();
        }
Exemple #5
0
/// <summary>
/// Copies the current object to a new instance
/// </summary>
/// <param name="deep">Copy members that refer to objects external to this class (not dependent)</param>
/// <param name="copiedObjects">Objects that should be reused</param>
/// <param name="asNew">Copy the current object as a new one, ready to be persisted, along all its members.</param>
/// <param name="reuseNestedObjects">If asNew is true, this flag if set, forces the reuse of all external objects.</param>
/// <param name="copy">Optional - An existing [OrderProduct] instance to use as the destination.</param>
/// <returns>A copy of the object</returns>
        public virtual OrderProduct Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, OrderProduct copy = null)
        {
            if (copiedObjects == null)
            {
                copiedObjects = new Hashtable();
            }
            if (copy == null && copiedObjects.Contains(this))
            {
                return((OrderProduct)copiedObjects[this]);
            }
            copy = copy ?? new OrderProduct();
            if (!asNew)
            {
                copy.TransientId = this.TransientId;
                copy.Id          = this.Id;
            }
            copy.Code            = this.Code;
            copy.Quantity        = this.Quantity;
            copy.Description     = this.Description;
            copy.UnitValue       = this.UnitValue;
            copy.MeasurementUnit = this.MeasurementUnit;
            copy.Price           = this.Price;
            copy.LineTotalPrice  = this.LineTotalPrice;
            if (!copiedObjects.Contains(this))
            {
                copiedObjects.Add(this, copy);
            }
            if (deep && this.order != null)
            {
                if (!copiedObjects.Contains(this.order))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.Order = this.Order;
                    }
                    else if (asNew)
                    {
                        copy.Order = this.Order.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.order = this.order.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.Order = (Order)copiedObjects[this.Order];
                    }
                    else
                    {
                        copy.order = (Order)copiedObjects[this.Order];
                    }
                }
            }
            if (deep && this.supplierProduct != null)
            {
                if (!copiedObjects.Contains(this.supplierProduct))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.SupplierProduct = this.SupplierProduct;
                    }
                    else if (asNew)
                    {
                        copy.SupplierProduct = this.SupplierProduct.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.supplierProduct = this.supplierProduct.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.SupplierProduct = (SupplierProduct)copiedObjects[this.SupplierProduct];
                    }
                    else
                    {
                        copy.supplierProduct = (SupplierProduct)copiedObjects[this.SupplierProduct];
                    }
                }
            }
            return(copy);
        }