public static List <DeliveryBlocksProperty> getDelBlockListCZ01(IDataCollectorServer dataCollectorServer, IDataCollectorSap dataCollectorSap, string salesOrg, string id)
        {
            List <ZV04HNProperty>       zvHNList = dataCollectorSap.getZV04HNList(salesOrg, IDAEnum.Task.deliveryBlocks);
            List <CustomerDataProperty> cdList   = dataCollectorServer.getCustomerDataList(salesOrg);

            List <DeliveryBlocksProperty> joinedList = getJoinedList(id, zvHNList, cdList)
                                                       .Where(x => (x.orderStatus.ToLower() == "open order" || x.orderStatus.ToLower() == "credit hold"))
                                                       .ToList();

            List <DeliveryBlocksProperty> blockList = getBlockList(joinedList);

            //get previously blocked orders from log
            List <DeliveryBlocksProperty> prevDelBlockList = dataCollectorServer.getDelBlockLogList(salesOrg);
            List <int> preOrdersBlockedList = prevDelBlockList.Select(x => x.orderNumber).ToList();

            //remove previously blocked orders that have been unblocked by users in order to not reapply blocks
            blockList.RemoveAll(x => preOrdersBlockedList.Contains(x.orderNumber));

            List <DeliveryBlocksProperty> unBlockList = getUnBlockList(joinedList);

            List <DeliveryBlocksProperty> finalList = new List <DeliveryBlocksProperty>();

            finalList.AddRange(blockList);
            finalList.AddRange(unBlockList);

            return(finalList);
        }
예제 #2
0
        private static List <DeliveryBlocksProperty> getJoinedList(IDataCollectorServer dataCollectorServer, IDataCollectorSap dataCollectorSap, string salesOrg, string id)
        {
            List <ZV04HNProperty> zvHNList = dataCollectorSap.getZV04HNList(salesOrg, IDAEnum.Task.deliveryBlocks);

            if (zvHNList is null)
            {
                return(null);
            }

            //remove shipTo's from zv04HNList that have at least 1 promotion order
            var listOfPromoShipTos = zvHNList.Where(x => x.deliveryInstructions.ToUpper().Contains("PROMO")).Select(y => y.shipto).ToList();

            zvHNList.RemoveAll(x => listOfPromoShipTos.Contains(x.shipto));

            List <CustomerDataProperty> cdList = dataCollectorServer.getCustomerDataList(salesOrg);

            List <DeliveryBlocksProperty> list = (
                from zvhn in zvHNList
                join cd in cdList on new { key0 = zvhn.soldto, key1 = zvhn.shipto } equals new { key0 = cd.soldTo, key1 = cd.shipTo }
                select getDelBlockProperty(id, zvhn, cd)
                ).Where(x =>
                        (x.orderStatus.ToLower() != "not invoice" && x.orderStatus.ToLower() != "invoiced") &&
                        (x.minQty > 0 || x.minVal > 0)
                        ).ToList();

            return(list);
        }
 public DataCollectorServiceDeliveryBlocks(IDataCollectorServer dataCollectorServer, IDataCollectorSap dataCollectorSap, string salesOrg, string id)
 {
     this.dataCollectorServer = dataCollectorServer;
     this.dataCollectorSap    = dataCollectorSap;
     this.salesOrg            = salesOrg;
     this.id = id;
 }
예제 #4
0
 public RejectionExecutor(IDataCollectorSap dcSap, IDataCollectorServer dcServer, string salesOrg, string id, IdaLog idaLog)
 {
     this.dcSap    = dcSap;
     this.dcServer = dcServer;
     this.salesOrg = salesOrg;
     this.idaLog   = idaLog;
     this.id       = id;
 }
        /// <summary>
        /// Delivery blocks in France are applied on orders that either dont meet the minimum order value or quantity per all orders currently available for each individual ship to
        /// Those orders are blocked wih delivery block code ZF
        /// Exception to this rule is if the order has a promote sku. Those sku's are marked as "REPACK" in the skuData table
        /// List has to be ordered by rdd
        /// </summary>
        /// <param name="dataCollectorServer"></param>
        /// <param name="dataCollectorSap"></param>
        /// <param name="salesOrg"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        ///

        public static List <DeliveryBlocksProperty> getDelBlockListFR01(IDataCollectorServer dataCollectorServer, IDataCollectorSap dataCollectorSap, string salesOrg, string id)
        {
            List <DeliveryBlocksProperty> joinedList = getJoinedList(dataCollectorServer, dataCollectorSap, salesOrg, id);

            if (joinedList is null)
            {
                return(null);
            }

            return(CalculatorSupport.getFinalListShipToAndRequestedDeliveryDateCriteria(joinedList).OrderBy(x => x.rdd).ToList());
        }
        /// <summary>
        /// Delivery blocks in Germany are applied on orders that either dont meet the minimum order value or quantity
        /// Orders on block Y2 & Z9 are ignored
        /// Those orders are blocked wih delivery block code ZF
        /// Exception to this rule is if the order has a display sku. Those sku's had "DP" or "DISPLAY" in the description. ZF block for them is removed
        /// If the order is already blocked with ZF but has had it quantiy or/and value changed to the qualifying amount the delivery block is lifted
        /// Also checks if the block has been lifted previously by user and does not reapply blocks 2nd time
        /// </summary>
        /// <param name="dataCollectorServer"></param>
        /// <param name="dataCollectorSap"></param>
        /// <param name="salesOrg"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public static List <DeliveryBlocksProperty> getDelBlockListDE01(IDataCollectorServer dataCollectorServer, IDataCollectorSap dataCollectorSap, string salesOrg, string id)
        {
            List <ZV04IProperty> zvIList = dataCollectorSap.getZV04IList(salesOrg, IDAEnum.Task.deliveryBlocks);

            List <ZV04HNProperty> zvHNList = dataCollectorSap.getZV04HNList(salesOrg, IDAEnum.Task.deliveryBlocks);

            if (zvIList is null)
            {
                return(null);
            }

            zvHNList = zvHNList
                       .Where(x => (x.status.ToLower() == "open order" || x.status.ToLower() == "credit hold") &&
                              x.delBlock != IDAConsts.DelBlocks.investigationPendingBlock &&
                              x.delBlock != IDAConsts.DelBlocks.leadTimeBlock)
                       .ToList();

            List <CustomerDataProperty> cdList = dataCollectorServer.getCustomerDataList(salesOrg);

            List <DeliveryBlocksProperty> joinedList = getJoinedList(id, zvIList, zvHNList, cdList);

            List <DeliveryBlocksProperty> groupedList = getGroupedList(joinedList);

            List <DeliveryBlocksProperty> blockList = getBlockList(groupedList);

            //get previously blocked orders from log
            List <DeliveryBlocksProperty> blockedOrdersFromFromLogList = dataCollectorServer.getDelBlockLogList(salesOrg);
            List <int> previouslyBlockedOrderList = blockedOrdersFromFromLogList.Select(x => x.orderNumber).ToList();

            //remove previously blocked orders that have been unblocked by users in order to not reapply blocks
            blockList.RemoveAll(x => previouslyBlockedOrderList.Contains(x.orderNumber));

            List <OrderWithDisplays> orderWithDisplaysList = (from zvi in zvIList
                                                              where (zvi.materialDescription.ToUpper().Contains("DP") || zvi.materialDescription.ToUpper().Contains("DISPLAY")) &&
                                                              (zvi.status.ToLower() == "open order" || zvi.status.ToLower() == "credit hold") &&
                                                              zvi.delBlock == IDAConsts.DelBlocks.belowMOQDelBlock
                                                              group zvi by zvi.order into g
                                                              select new OrderWithDisplays(g.Key)
                                                              )
                                                             .Distinct()
                                                             .ToList();

            //remove orders with displays from blocklist
            blockList = blockList.Where(x => orderWithDisplaysList.Any(y => y.orderNumber != x.orderNumber)).ToList();

            List <DeliveryBlocksProperty> unBlockList = getUnBlockList(groupedList, orderWithDisplaysList);

            List <DeliveryBlocksProperty> finalList = new List <DeliveryBlocksProperty>();

            finalList.AddRange(blockList);
            finalList.AddRange(unBlockList);

            return(finalList);
        }
        /// <summary>
        /// Removing all delivery blocks by conditions:
        /// RO01 - remove all blocks apart from Z9 and Y2
        /// IT01 - remove all blocks apart from  Z9, Y2 and Z4
        /// GR01 - remove all ZF blocks
        /// </summary>
        /// <param name="dataCollectorServer"></param>
        /// <param name="dataCollectorSap"></param>
        /// <param name="salesOrg"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public static List <DeliveryBlocksProperty> getDelBlockListRO01(IDataCollectorServer dataCollectorServer, IDataCollectorSap dataCollectorSap, string salesOrg, string id)
        {
            List <ZV04HNProperty> zvHNList = dataCollectorSap.getZV04HNList(salesOrg, IDAEnum.Task.deliveryBlocks);

            if (zvHNList is null)
            {
                return(null);
            }

            switch (salesOrg.ToUpper())
            {
            case "RO01":
                zvHNList = zvHNList
                           .Where(x => !string.IsNullOrEmpty(x.delBlock) &&
                                  x.delBlock.ToUpper() != IDAConsts.DelBlocks.leadTimeBlock &&
                                  x.delBlock.ToUpper() != IDAConsts.DelBlocks.investigationPendingBlock)
                           .ToList();
                break;

            case "IT01":
                zvHNList = zvHNList
                           .Where(x => !string.IsNullOrEmpty(x.delBlock) &&
                                  x.delBlock.ToUpper() != IDAConsts.DelBlocks.leadTimeBlock &&
                                  x.delBlock.ToUpper() != IDAConsts.DelBlocks.investigationPendingBlock &&
                                  x.delBlock.ToUpper() != IDAConsts.DelBlocks.exportPaperMissingBlock &&
                                  x.delBlock.ToUpper() != IDAConsts.DelBlocks.GOEBlock)
                           .ToList();
                break;

            case "GR01":
                zvHNList = zvHNList
                           .Where(x => x.delBlock.ToUpper() == IDAConsts.DelBlocks.belowMOQDelBlock)
                           .ToList();
                break;

            default:
                throw new NotImplementedException($"There is no such sales org - {salesOrg} in southern cluster");
            }

            List <CustomerDataProperty> cdList = dataCollectorServer.getCustomerDataList(salesOrg);

            List <DeliveryBlocksProperty> finalList = (from zv in zvHNList
                                                       join cd in cdList on new { key0 = zv.soldto, key1 = zv.shipto } equals new { key0 = cd.soldTo, key1 = cd.shipTo }
                                                       select getDelBlockProperty(salesOrg, id, zv, cd)
                                                       )
                                                      .ToList();

            return(finalList);
        }
        private static List <DeliveryBlocksProperty> getJoinedList(IDataCollectorServer dataCollectorServer, IDataCollectorSap dataCollectorSap, string salesOrg, string id)
        {
            List <ZV04IProperty> zvIList = dataCollectorSap.getZV04IList(salesOrg, IDAEnum.Task.deliveryBlocks);

            if (zvIList is null)
            {
                return(null);
            }

            List <SkuDataProperty> skuList = dataCollectorServer.getSkuDataList(salesOrg);

            List <PromoOrderShipTo> promoOrderShipToList = (
                from zvi in zvIList
                join skuData in skuList
                on zvi.material equals skuData.sku
                where skuData.standardOrRepack.ToUpper() == "REPACK"
                group zvi by zvi.shipTo into g
                select new PromoOrderShipTo(g.Key)
                )
                                                           .Distinct()
                                                           .ToList();

            List <ZV04HNProperty> zvHNList = dataCollectorSap.getZV04HNList(salesOrg, IDAEnum.Task.deliveryBlocks);

            //remove shipTo's from joinedList that have at least 1 promotion order
            zvHNList = zvHNList
                       .Where(x => !promoOrderShipToList
                              .Any(y => x.shipto == y.shipTo)
                              )
                       .ToList();

            List <CustomerDataProperty> cdList = dataCollectorServer.getCustomerDataList(salesOrg);

            List <DeliveryBlocksProperty> list = (
                from zvh in zvHNList
                join cd in cdList on new { key0 = zvh.soldto, key1 = zvh.shipto } equals new { key0 = cd.soldTo, key1 = cd.shipTo }
                select getDelBlockProperty(id, zvh, cd)
                )
                                                 .Where(x =>
                                                        (x.orderStatus.ToLower() != "Not Invoice" || x.orderStatus.ToLower() != "Invoiced") &&
                                                        (x.minQty > 0 || x.minVal > 0)
                                                        )
                                                 .ToList();

            return(list);
        }
예제 #9
0
        public void rejDataCalculatorWithAllAndShipToRejections_Should_ReturnListOfRejectionsForAllSkusThatHaveRejectionReasonInRejectionsData_When_ThereAreMultipleDuplicateSkusInsideSameOrders()
        {
            IDataCollectorServer dcServer = null;
            IDataCollectorSap    dcSap    = null;

            IDataCollectorServiceRejections dataCollector = new DataCollectorServiceRejections(dcServer, dcSap);

            dataCollector.rdjList = getRdListWithAllAndShipToRejectionsDuplciatedSkusInOrders();
            dataCollector.zvList  = getZvListWithAllAndShipToRejectionsDuplciatedSkusInOrders();
            dataCollector.cdList  = getCdListWithAllAndShipToRejectionsDuplciatedSkusInOrders();

            IDataCalculatorServiceRejections dataCalculator = new DataCalculatorServiceRejections(null);

            List <RejectionsProperty> list         = dataCalculator.getRejectionsList(dataCollector);
            List <RejectionsProperty> expectedList = getExpectedListWithAllAndShipToRejectionsDuplciatedSkusInOrders();
            var xyar = list[0].EqualsDiff(expectedList[0]);

            CollectionAssert.AreEqual(expectedList, list);
        }
예제 #10
0
        public void rejDataCalculatorWithOnlyAllRejections_Should_ReturnListOfRejectionsForAllSkusThatHaveRejectionReasonInRejectionsData_When_normalState()
        {
            IDataCollectorServer dcServer = null;
            IDataCollectorSap    dcSap    = null;

            IDataCollectorServiceRejections dataCollector = new DataCollectorServiceRejections(dcServer, dcSap);

            dataCollector.rdjList = getRdListOnlyAllRejections();
            dataCollector.cdList  = getCdListOnlyAllRejections();
            dataCollector.zvList  = getZvListOnlyAllRejections();

            IDataCalculatorServiceRejections dataCalculator = new DataCalculatorServiceRejections(null);

            List <RejectionsProperty> list         = dataCalculator.getRejectionsList(dataCollector);
            List <RejectionsProperty> expectedList = getExpectedListOnlyAllRejections();
            var xyar = list[0].EqualsDiff(expectedList[0]);

            CollectionAssert.AreEqual(expectedList, list);
        }
        private static List <DeliveryBlocksProperty> getJoinedList(IDataCollectorServer dataCollectorServer, IDataCollectorSap dataCollectorSap, string salesOrg, string id)
        {
            List <ZV04HNProperty> zvHNList = dataCollectorSap.getZV04HNList(salesOrg, IDAEnum.Task.deliveryBlocks);

            if (zvHNList is null)
            {
                return(null);
            }

            List <CustomerDataProperty> cdList = dataCollectorServer.getCustomerDataList(salesOrg);

            List <DeliveryBlocksProperty> list = (
                from zvhn in zvHNList
                join cd in cdList on new { key0 = zvhn.soldto, key1 = zvhn.shipto } equals new { key0 = cd.soldTo, key1 = cd.shipTo }
                select new DeliveryBlocksProperty(
                    id: id,
                    orderStatus: zvhn.status,
                    salesOrg: cd.salesOrg,
                    country: cd.country,
                    orderNumber: zvhn.order,
                    poNumber: zvhn.pONumber,
                    soldTo: zvhn.soldto,
                    soldToName: zvhn.shiptoName,
                    shipTo: zvhn.shipto,
                    shipToName: zvhn.shiptoName,
                    currentDeliveryBlock: zvhn.delBlock,
                    newDeliveryBlock: null,
                    currentQty: zvhn.orderQty,
                    minQty: cd.minimumOrderCaseQuantity,
                    currentVal: zvhn.ordNetValue,
                    minVal: cd.minimumOrderValue,
                    reason: null,
                    customerEmails: cd.belowMOQandMOVEmails,
                    poDate: zvhn.pODate,
                    rdd: zvhn.reqDelDate
                    )
                ).Where(x =>
                        (x.orderStatus.ToLower() != "not invoice" || x.orderStatus.ToLower() != "invoiced") &&
                        (x.minQty > 0 || x.minVal > 0)
                        ).ToList();

            return(list);
        }
        /// <summary>
        /// UK removes ZV delivery blocks from orders when appointment times have been filled in
        /// UK adds ZV delivery block when appointment times are not filled in
        /// </summary>
        /// <param name="dataCollectorServer"></param>
        /// <param name="dataCollectorSap"></param>
        /// <param name="salesOrg"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public static List <DeliveryBlocksProperty> getDelBlockListGB01(IDataCollectorServer dataCollectorServer, IDataCollectorSap dataCollectorSap, string salesOrg, string id)
        {
            List <ZV04HNProperty> zvHNList = dataCollectorSap.getZV04HNList(salesOrg, IDAEnum.Task.deliveryBlocks)
                                             .Where(x => x.status.ToLower() == "open order" || x.status.ToLower() == "credit hold")
                                             .ToList();

            if (zvHNList is null)
            {
                return(null);
            }

            List <AppointmentTimesSoldTo> appTimesSoldToList = dataCollectorServer.getGBAppointmentTimesCustomers();

            List <DeliveryBlocksProperty> blockList = getDeliveryBlockList(salesOrg, id, zvHNList, appTimesSoldToList, true);

            List <DeliveryBlocksProperty> unBlockList = getDeliveryBlockList(salesOrg, id, zvHNList, appTimesSoldToList, false);

            List <DeliveryBlocksProperty> finalList = new List <DeliveryBlocksProperty>();

            finalList.AddRange(blockList);
            finalList.AddRange(unBlockList);

            return(finalList);
        }
예제 #13
0
 public DataCollectorServiceDistress(IDataCollectorServer dataCollectorServer, IDataCollectorSap dataCollectorSap)
 {
     this.dataCollectorServer = dataCollectorServer;
     this.dataCollectorSap    = dataCollectorSap;
 }
예제 #14
0
 public DataCollectorServiceRejections(IDataCollectorServer dataCollectorServer, IDataCollectorSap dataCollectorSap)
 {
     this.dataCollectorServer = dataCollectorServer;
     this.dataCollectorSap    = dataCollectorSap;
 }
예제 #15
0
 public DataCollectorServiceSwitches(IDataCollectorServer dataCollectorServer, IDataCollectorSap dataCollectorSap)
 {
     this.dataCollectorServer = dataCollectorServer;
     this.dataCollectorSap    = dataCollectorSap;
 }