Exemplo n.º 1
0
 public ParseOrderResult(Order order, ParseOrderResultState state = ParseOrderResultState.OK)
 {
     Order = order;
     State = state;
 }
Exemplo n.º 2
0
        public ParseOrderResult ParseOrder(string orderAsString)
        {
            if (Organisation == null)
            {
                return(new ParseOrderResult(ParseOrderResultState.OrganisationNotFound));
            }

            ParseOrderResultState state = ParseOrderResultState.OK;


            List <string> catalogIds = Catalogs.Select(c => c.Id).ToList();

            List <string> orderLineArray = orderAsString.Split(',').ToList();

            Order order = Order.CreateNew();

            //new Order()

            /*
             * {
             *  OrganisationId = this.Organisation.Id
             * };*/

            order.OrganisationId = this.Organisation.Id;

            if (this.Account != null)
            {
                order.Account   = this.Account;
                order.AccountId = this.Account.Id;
            }

            if (this.Party != null)
            {
                order.Party   = this.Party;
                order.PartyId = this.Party.Id;
            }

            order.OrderType  = OrderType.SalesOrder;
            order.OrderLines = new List <OrderLine>();

            List <ParseOrderLineResult> orderLineResults = new List <ParseOrderLineResult>();

            PersonList personList = new PersonList();

            int lineNumber = 10;

            orderLineArray.ForEach(ol =>
            {
                ParseOrderLineResult orderLineResult = ParseOrderLine(this.Organisation, catalogIds, ol.Trim());
                orderLineResults.Add(orderLineResult);

                if (orderLineResult.State == ParseOrderLineResultState.OK)
                {
                    if (lineNumber == 10)
                    {
                        //order.TaxIncluded = orderLineResult
                    }
                    var orderLine = orderLineResult.OrderLine;

                    if (!string.IsNullOrWhiteSpace(orderLine.Persons))
                    {
                        PersonCodes codes = new PersonCodes(orderLine.Persons);

                        foreach (string code in codes.Codes)
                        {
                            if (!personList.Contains(code))
                            {
                                personList.AddPerson(new Person(code, code));
                            }
                        }
                    }

                    orderLine.Order      = order;
                    orderLine.LineNumber = lineNumber;
                    order.OrderLines.Add(orderLine);

                    if (orderLine.Product.NeedsPlanning)
                    {
                        order.IsAppointment = true;
                    }

                    lineNumber += 10;
                }
                else
                {
                    state = ParseOrderResultState.AtLeastOneProblem;
                }
            });

            order.Persons     = personList.ToString();
            order.NrOfPersons = personList.Persons.Count;

            ParseOrderResult result = new ParseOrderResult(order, state);

            result.OrderLineResults = orderLineResults;

            return(result);
        }
Exemplo n.º 3
0
 public ParseOrderResult(ParseOrderResultState state)
 {
     State = state;
 }