Exemple #1
0
        private DeliverOrderEuRequest PrepareRequestInternal(bool useIncVatRequestIfPossible)
        {
            var errors = ValidateOrder();

            if (errors.Length > 0)
            {
                throw new SveaWebPayValidationException(errors);
            }

            var formatter = new WebServiceRowFormatter <DeliverOrderBuilder>(_order, useIncVatRequestIfPossible);

            DeliverInvoiceDetails deliverInvoiceDetails = null;

            if (_order.GetOrderType() == CONST.OrderType.INVOICE)
            {
                deliverInvoiceDetails = new DeliverInvoiceDetails
                {
                    InvoiceDistributionType = ConvertInvoiceDistributionType(_order.GetInvoiceDistributionType()),
                    InvoiceIdToCredit       = _order.GetCreditInvoice(),
                    IsCreditInvoice         = _order.GetCreditInvoice().HasValue,
                    NumberOfCreditDays      = _order.GetNumberOfCreditDays(),
                    OrderRows = formatter.FormatRows().ToArray()
                };
            }

            _orderInformation = new DeliverOrderInformation
            {
                DeliverInvoiceDetails = deliverInvoiceDetails,
                OrderType             = ConvertOrderType(_order.GetOrderType()),
                SveaOrderId           = _order.GetOrderId()
            };

            _sveaDeliverOrder = new DeliverOrderEuRequest
            {
                Auth = GetStoreAuthorization(),
                DeliverOrderInformation = _orderInformation
            };

            return(_sveaDeliverOrder);
        }
        /// <summary>
        /// PrepareRequest
        /// </summary>
        /// <exception cref="SveaWebPayValidationException"></exception>
        /// <returns>SveaRequest</returns>
        public DeliverOrderEuRequest PrepareRequest()
        {
            var errors = ValidateOrder();
            if (errors.Length > 0)
            {
                throw new SveaWebPayValidationException(errors);
            }

            var formatter = new WebServiceRowFormatter<DeliverOrderBuilder>(_order);

            DeliverInvoiceDetails deliverInvoiceDetails = null;
            if (_order.GetOrderType() == OrderType.INVOICE)
            {
                deliverInvoiceDetails = new DeliverInvoiceDetails
                    {
                        InvoiceDistributionType = ConvertInvoiceDistributionType(_order.GetInvoiceDistributionType()),
                        InvoiceIdToCredit = _order.GetCreditInvoice(),
                        IsCreditInvoice = _order.GetCreditInvoice().HasValue,
                        NumberOfCreditDays = _order.GetNumberOfCreditDays(),
                        OrderRows = formatter.FormatRows().ToArray()
                    };
            }

            _orderInformation = new DeliverOrderInformation
                {
                    DeliverInvoiceDetails = deliverInvoiceDetails,
                    OrderType = ConvertOrderType(_order.GetOrderType()),
                    SveaOrderId = _order.GetOrderId()
                };

            _sveaDeliverOrder = new DeliverOrderEuRequest
                {
                    Auth = GetStoreAuthorization(),
                    DeliverOrderInformation = _orderInformation
                };

            return _sveaDeliverOrder;
        }