Exemplo n.º 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);
Exemplo n.º 2
0
        private static void SetUserDefinedFields(OrderTransactionType orderTransactionType, OrderDetail orderLine, IWineMsTransactionLine transactionLine)
        {
            switch (orderTransactionType)
            {
            case OrderTransactionType.SalesOrder:
                orderLine.SetUserField("ucIDSOrdTxCMwineMSGuid", $"{transactionLine.Guid}");
                break;

            case OrderTransactionType.PurchaseOrder:
                orderLine.SetUserField("ucIDPOrdTxCMwineMSGuid", $"{transactionLine.Guid}");
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(orderTransactionType), orderTransactionType, null);
            }
        }
Exemplo n.º 3
0
        private static void CreateOrderTransactionType(QuiltContext ctx, string orderTransactionTypeCode, string name)
        {
            Console.WriteLine("CreateOrderTransactionType {0}", orderTransactionTypeCode);

            var dbOrderTransactionType = ctx.OrderTransactionTypes.Where(r => r.OrderTransactionTypeCode == orderTransactionTypeCode).SingleOrDefault();

            if (dbOrderTransactionType == null)
            {
                dbOrderTransactionType = new OrderTransactionType()
                {
                    OrderTransactionTypeCode = orderTransactionTypeCode,
                    Name = name
                };
                _ = ctx.OrderTransactionTypes.Add(dbOrderTransactionType);
            }
            else
            {
                dbOrderTransactionType.Name = name;
            }
        }
Exemplo n.º 4
0
 public Secure3dBuilder WithOrderTransactionType(OrderTransactionType orderTransactionType)
 {
     OrderTransactionType = orderTransactionType;
     return(this);
 }