Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommercialDocumentLine"/> class with a specified xml root element.
 /// </summary>
 /// <param name="parent">Parent <see cref="CommercialDocumentHeader"/>.</param>
 public CommercialDocumentLine(CommercialDocumentBase parent)
     : base(parent, BusinessObjectType.CommercialDocumentLine)
 {
     this.CommercialWarehouseValuations = new CommercialWarehouseValuations(this);
     this.CommercialWarehouseRelations  = new CommercialWarehouseRelations(this);
     this.IncomeOutcomeRelations        = new IncomeOutcomeRelations(this);
     this.Attributes = new DocumentLineAttrValues(this);
 }
Esempio n. 2
0
        /// <summary>
        /// Creates new <see cref="CommercialDocumentLine"/> according to the CommercialDocument's defaults and attaches it to the parent <see cref="CommercialDocument"/>.
        /// </summary>
        /// <returns>A new <see cref="CommercialDocumentLine"/>.</returns>
        public override CommercialDocumentLine CreateNew()
        {
            CommercialDocumentBase parent = (CommercialDocumentBase)this.Parent;

            //create new object and attach it to the element
            CommercialDocumentLine line = new CommercialDocumentLine(parent);

            line.Order = this.Children.Count + 1;

            DocumentCategory dc = parent.DocumentType.DocumentCategory;

            if (!parent.IsBeforeSystemStart)
            {
                if ((dc == DocumentCategory.Sales || dc == DocumentCategory.SalesCorrection) && parent.DocumentType.CommercialDocumentOptions.SimulatedInvoice == null)
                {
                    line.CommercialDirection = -1;
                }
                else if (dc == DocumentCategory.Purchase || dc == DocumentCategory.PurchaseCorrection)
                {
                    line.CommercialDirection = 1;
                }
                else if (dc == DocumentCategory.Order)
                {
                    line.OrderDirection = 1;
                }
                else if (dc == DocumentCategory.Reservation)
                {
                    line.OrderDirection = -1;
                }
                else
                {
                    line.CommercialDirection = 0;
                    line.OrderDirection      = 0;
                }
            }
            else
            {
                line.CommercialDirection = 0;
                line.OrderDirection      = 0;
            }

            //add object to the collection
            this.Children.Add(line);

            return(line);
        }
Esempio n. 3
0
        }                                                                               //for save object reflection purposes

        public CommercialDocumentVatTableEntry(CommercialDocumentBase parent)
            : base(parent)
        {
        }
Esempio n. 4
0
        /// <summary>
        /// Validates the <see cref="BusinessObject"/>.
        /// </summary>
        public override void Validate()
        {
            base.Validate();

            CommercialDocumentBase parent           = this.Parent as CommercialDocumentBase;
            CommercialDocument     commercialParent = this.Parent as CommercialDocument;
            string minusPosition;

            try
            {
                if (parent.DocumentType.Options.Element("commercialDocument").Attribute("exchangeDoublePosition") != null)
                {
                    minusPosition = parent.DocumentType.Options.Element("commercialDocument").Attribute("exchangeDoublePosition").Value;
                }
                else
                {
                    minusPosition = "true";
                }
            } catch (Exception ex)
            {
                RoboFramework.Tools.RandomLogHelper.GetLog().Debug("FractusRefactorTraceCatch:3" + ex.Message + ex.StackTrace);
                minusPosition = "false";
            }

            if (commercialParent != null && commercialParent.IsCorrectiveDocument())
            {
                //mozemy korygowac na + jezeli korygujemy pozycje z naszego dokumentu
                //czyli jest to wybranie opcji w panelu "Stworz pozycje korygujaca"
                if (this.Quantity > 0 && this.CorrectedLine.Parent.Id.Value != commercialParent.Id.Value)
                {
                    throw new ClientException(ClientExceptionId.QuantityOnCorrectionAboveZero);
                }
            }
            else if (commercialParent != null && commercialParent.DocumentType.DocumentCategory == DocumentCategory.Technology)
            {
                DocumentLineAttrValue attr = this.Attributes[DocumentFieldName.LineAttribute_ProductionItemType];

                if (attr == null || attr.Value == null || attr.Value.Value.Length == 0)
                {
                    throw new ClientException(ClientExceptionId.MissingProductionItemType, null, "ordinalNumber:" + this.OrdinalNumber.ToString(CultureInfo.InvariantCulture));
                }
            }
            else if (commercialParent != null && commercialParent.DocumentType.DocumentCategory == DocumentCategory.ProductionOrder)
            {
                DocumentLineAttrValue attr = this.Attributes[DocumentFieldName.LineAttribute_ProductionTechnologyName];

                if (attr == null || attr.Value == null || attr.Value.Value.Length == 0)
                {
                    throw new ClientException(ClientExceptionId.MissingProductionTechnologyName, null, "ordinalNumber:" + this.OrdinalNumber.ToString(CultureInfo.InvariantCulture));
                }
            }
            else
            {
                if (this.Quantity <= 0 && minusPosition != "true")
                {
                    throw new ClientException(ClientExceptionId.QuantityBelowOrEqualZero, null, "itemName:" + this.ItemName);
                }

                DocumentCategory dc = parent.DocumentType.DocumentCategory;

                //jezeli jest to pozycja sprzedazowa na zamowieniu sprzedazowym (zdefiniowany atrybut rodzaju sprzedaży) to NIE dopusczamy
                if (dc == DocumentCategory.SalesOrder && this.NetPrice <= 0)
                {
                    if (this.Attributes != null)
                    {
                        var attr = this.Attributes[DocumentFieldName.LineAttribute_SalesOrderGenerateDocumentOption];

                        if (attr != null)
                        {
                            if (attr.Value.Value == "1" || attr.Value.Value == "3") //sprzedazowe
                            {
                                throw new ClientException(ClientExceptionId.LinePriceBelowOrEqualZero);
                            }
                        }
                    }
                }

                if (dc == DocumentCategory.Sales || dc == DocumentCategory.Purchase)
                {
                    if (this.NetPrice <= 0)
                    {
                        throw new ClientException(ClientExceptionId.LinePriceBelowOrEqualZero);
                    }
                }
                else if (dc == DocumentCategory.Reservation || dc == DocumentCategory.Order || dc == DocumentCategory.SalesOrder)
                {
                    if (this.NetPrice < 0 && minusPosition != "true")
                    {
                        throw new ClientException(ClientExceptionId.LinePriceBelowZero);
                    }
                }
            }
            //Sprawdzenie czy pozycja jest na magazyn lokalny
            Warehouse warehouse = DictionaryMapper.Instance.GetWarehouse(this.WarehouseId.Value);

            if (this.WarehouseId.HasValue && !warehouse.IsLocal)
            {
                throw new ClientException(ClientExceptionId.WarehouseNotLocal, null, "warehouse:" + warehouse.Symbol);
            }

            if (this.CommercialWarehouseValuations != null)
            {
                this.CommercialWarehouseValuations.Validate();
            }

            if (this.CommercialWarehouseRelations != null)
            {
                this.CommercialWarehouseRelations.Validate();
            }

            if (this.Attributes != null)
            {
                this.Attributes.Validate();
            }
        }
 public CommercialDocumentVatTableEntries(CommercialDocumentBase parent)
     : base(parent, "vtEntry")
 {
 }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommercialDocumentLines"/> class with a specified <see cref="CommercialDocument"/> to attach to.
 /// </summary>
 /// <param name="parent"><see cref="CommercialDocument"/> to attach to.</param>
 public CommercialDocumentLines(CommercialDocumentBase parent)
     : base(parent, "line")
 {
 }