Пример #1
0
 public virtual void RemoveCreditNoteProducts(CreditNoteProduct __item)
 {
     if (__item != null)
     {
         __item.CreditNote = null;
     }
 }
Пример #2
0
 public virtual void InternalRemoveCreditNoteProducts(CreditNoteProduct __item)
 {
     if (__item == null)
     {
         return;
     }
     creditNoteProducts?.Remove(__item);
 }
Пример #3
0
 public virtual void InternalAddCreditNoteProducts(CreditNoteProduct __item)
 {
     if (__item == null || disableInternalAdditions)
     {
         return;
     }
     creditNoteProducts?.Add(__item);
 }
Пример #4
0
 public virtual void AddCreditNoteProducts(CreditNoteProduct __item)
 {
     if (__item == null)
     {
         return;
     }
     if (__item.CreditNote != this)
     {
         __item.CreditNote = this;
     }
 }
Пример #5
0
 public virtual void SetCreditNoteProductsAt(CreditNoteProduct __item, int __index)
 {
     if (__item == null)
     {
         creditNoteProducts[__index].CreditNote = null;
     }
     else
     {
         creditNoteProducts[__index] = __item;
         if (__item.CreditNote != this)
         {
             __item.CreditNote = this;
         }
     }
 }
Пример #6
0
 public virtual void AddAtIndexCreditNoteProducts(int index, CreditNoteProduct __item)
 {
     if (__item == null)
     {
         return;
     }
     creditNoteProducts?.Insert(index, __item);
     disableInternalAdditions = true;
     try
     {
         if (__item.CreditNote != this)
         {
             __item.CreditNote = this;
         }
     }
     finally
     {
         disableInternalAdditions = false;
     }
 }
Пример #7
0
        public void CreditNote_persistence_test()
        {
            DateTime now = DateTime.Now;

            // Get datetime without milliseconds
            now = new DateTime(now.Ticks - (now.Ticks % TimeSpan.TicksPerSecond), now.Kind);
            var _order_orders_creditnotes = 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_creditnotes2 = 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_creditnoteproducts_creditnote = new DSS5_SupplyChainFinancialsOptimisation.BO.CreditNoteProduct
            {
                Code            = "CreditNoteProduct_Code",
                Quantity        = 222222.22M,
                Description     = "CreditNoteProduct_Description",
                UnitValue       = "CreditNoteProduct_UnitValue",
                MeasurementUnit = "CreditNoteProduct_MeasurementUnit",
                Price           = 222222.22M,
                LineTotalPrice  = 222222.22M,
            };
            var _order_creditnoteproducts_creditnote2 = new DSS5_SupplyChainFinancialsOptimisation.BO.CreditNoteProduct
            {
                Code            = "CreditNoteProduct_Code",
                Quantity        = 222222.22M,
                Description     = "CreditNoteProduct_Description",
                UnitValue       = "CreditNoteProduct_UnitValue",
                MeasurementUnit = "CreditNoteProduct_MeasurementUnit",
                Price           = 222222.22M,
                LineTotalPrice  = 222222.22M,
            };
            var _transaction_transaction_creditnotes = 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.CreditNote>(Session)
            .CheckProperty(p => p.CreditNoteNumber, "CreditNote_CreditNoteNumber")
            .CheckProperty(p => p.Description, "CreditNote_Description")
            .CheckProperty(p => p.DateIssued, now)
            .CheckProperty(p => p.Amount, 2222222222.22222M)
            .CheckProperty(p => p.TotalPrice, 2222222222.22222M)
            .CheckProperty(p => p.CreditNoteDocument, "CreditNote_CreditNoteDocument")
            .CheckProperty(p => p.CNoteAttachment, "CreditNote_CNoteAttachment")
            .CheckBag(p => p.Orders, (new List <DSS5_SupplyChainFinancialsOptimisation.BO.Order>
            {
                _order_orders_creditnotes,
                _order_orders_creditnotes2
            }))
            .CheckBag(p => p.CreditNoteProducts, (new List <DSS5_SupplyChainFinancialsOptimisation.BO.CreditNoteProduct>
            {
                _order_creditnoteproducts_creditnote,
                _order_creditnoteproducts_creditnote2
            }))
            .CheckReference(p => p.Transaction, _transaction_transaction_creditnotes)
            .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(CreditNoteProduct 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 [CreditNoteProduct] instance to use as the destination.</param>
/// <returns>A copy of the object</returns>
        public virtual CreditNoteProduct Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, CreditNoteProduct copy = null)
        {
            if (copiedObjects == null)
            {
                copiedObjects = new Hashtable();
            }
            if (copy == null && copiedObjects.Contains(this))
            {
                return((CreditNoteProduct)copiedObjects[this]);
            }
            copy = copy ?? new CreditNoteProduct();
            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.creditNote != null)
            {
                if (!copiedObjects.Contains(this.creditNote))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.CreditNote = this.CreditNote;
                    }
                    else if (asNew)
                    {
                        copy.CreditNote = this.CreditNote.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.creditNote = this.creditNote.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.CreditNote = (CreditNote)copiedObjects[this.CreditNote];
                    }
                    else
                    {
                        copy.creditNote = (CreditNote)copiedObjects[this.CreditNote];
                    }
                }
            }
            return(copy);
        }