예제 #1
0
 public virtual void RemoveDeliveryNoteProducts(DeliveryNoteProduct __item)
 {
     if (__item != null)
     {
         __item.DeliveryNote = null;
     }
 }
예제 #2
0
 public virtual void InternalRemoveDeliveryNoteProducts(DeliveryNoteProduct __item)
 {
     if (__item == null)
     {
         return;
     }
     deliveryNoteProducts?.Remove(__item);
 }
예제 #3
0
 public virtual void InternalAddDeliveryNoteProducts(DeliveryNoteProduct __item)
 {
     if (__item == null || disableInternalAdditions)
     {
         return;
     }
     deliveryNoteProducts?.Add(__item);
 }
예제 #4
0
 public virtual void AddDeliveryNoteProducts(DeliveryNoteProduct __item)
 {
     if (__item == null)
     {
         return;
     }
     if (__item.DeliveryNote != this)
     {
         __item.DeliveryNote = this;
     }
 }
예제 #5
0
 public virtual void SetDeliveryNoteProductsAt(DeliveryNoteProduct __item, int __index)
 {
     if (__item == null)
     {
         deliveryNoteProducts[__index].DeliveryNote = null;
     }
     else
     {
         deliveryNoteProducts[__index] = __item;
         if (__item.DeliveryNote != this)
         {
             __item.DeliveryNote = this;
         }
     }
 }
예제 #6
0
 public virtual void AddAtIndexDeliveryNoteProducts(int index, DeliveryNoteProduct __item)
 {
     if (__item == null)
     {
         return;
     }
     deliveryNoteProducts?.Insert(index, __item);
     disableInternalAdditions = true;
     try
     {
         if (__item.DeliveryNote != this)
         {
             __item.DeliveryNote = this;
         }
     }
     finally
     {
         disableInternalAdditions = false;
     }
 }
        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();
        }
/// <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(DeliveryNoteProduct compareTo)
        {
            return(!this.IsTransient() && !compareTo.IsTransient() && this.Id.Equals(compareTo.Id));
        }
/// <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 [DeliveryNoteProduct] instance to use as the destination.</param>
/// <returns>A copy of the object</returns>
        public virtual DeliveryNoteProduct Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, DeliveryNoteProduct copy = null)
        {
            if (copiedObjects == null)
            {
                copiedObjects = new Hashtable();
            }
            if (copy == null && copiedObjects.Contains(this))
            {
                return((DeliveryNoteProduct)copiedObjects[this]);
            }
            copy = copy ?? new DeliveryNoteProduct();
            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.deliveryNote != null)
            {
                if (!copiedObjects.Contains(this.deliveryNote))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.DeliveryNote = this.DeliveryNote;
                    }
                    else if (asNew)
                    {
                        copy.DeliveryNote = this.DeliveryNote.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.deliveryNote = this.deliveryNote.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.DeliveryNote = (DeliveryNote)copiedObjects[this.DeliveryNote];
                    }
                    else
                    {
                        copy.deliveryNote = (DeliveryNote)copiedObjects[this.DeliveryNote];
                    }
                }
            }
            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);
        }