Example #1
0
        private static Result <OrderBase> AddOrderLines(
            this OrderBase order,
            WineMsOrderTransactionDocument salesOrderTransactionDocument,
            OrderTransactionType orderTransactionType) =>
        WineMsTransactionDocumentFunctions
        .ForEachTransactionDocumentLine(
            transactionLine =>
            ExceptionWrapper
            .Wrap(
                () =>
        {
            var isGeneralLedgerLine = IsGeneralLedgerLine(transactionLine);
            var orderLine           = NewOrderDetail(order);

            if (isGeneralLedgerLine)
            {
                SetGeneralLedgerAccount(orderLine, transactionLine);
            }
            else
            {
                SetInventoryItem(orderLine, transactionLine);
            }

            orderLine.Quantity  = (double)transactionLine.Quantity;
            orderLine.ToProcess = orderLine.Quantity;
            SetUnitSellingPrice(orderLine, transactionLine);

            if (transactionLine.TaxTypeId > 0)
            {
                var result = GetOrderLineTaxType(transactionLine);
                if (result.IsFailure)
                {
                    return(Result.Fail(result.Error));
                }
                orderLine.TaxType = result.Value;
            }

            orderLine.DiscountPercent = (double)transactionLine.LineDiscountPercentage;
            orderLine.Description     = transactionLine.Description1;

            if (!transactionLine.ItemNote.IsNullOrWhiteSpace())
            {
                orderLine.Note = transactionLine.ItemNote;
            }

            SetUserDefinedFields(orderTransactionType, orderLine, transactionLine);

            return(Result.Ok());
        }),
            salesOrderTransactionDocument.TransactionLines)
        .OnSuccess(() => order);
Example #2
0
 public static Result <OrderBase> AddPurchaseOrderLines(
     this OrderBase order,
     WineMsOrderTransactionDocument salesOrderTransactionDocument) =>
 order.AddOrderLines(salesOrderTransactionDocument, OrderTransactionType.PurchaseOrder);