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);
        }
Ejemplo n.º 2
0
        public bool calculateOrdersToRejectList()
        {
            List <ZV04HNProperty>       zvhList = dcSap.getZV04HNList(salesOrg, IDAEnum.Task.rejections);
            List <CustomerDataProperty> cdList  = dcServer.getCustomerDataList(salesOrg);

            ordersToRejectList = (
                from z in zvhList
                join c in cdList
                on new { key0 = z.soldto, key1 = z.shipto } equals new { key0 = c.shipTo, key1 = c.shipTo }
                where z.delBlock.ToUpper() == belowMOQBlock
                select new RejectionFullOrderProperty(id,
                                                      c.salesOrg,
                                                      c.country,
                                                      z.soldto,
                                                      z.shipto,
                                                      z.shiptoName,
                                                      z.order,
                                                      z.pONumber,
                                                      "ZK",
                                                      z.orderQty,
                                                      z.ordNetValue,
                                                      "Failed to reach MOQ & MOV")
                ).ToList();

            if (ordersToRejectList.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
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);
        }
        /// <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);
        }
        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);
        }
Ejemplo n.º 8
0
        public List <GenericDistressProperty> getDistressList(string salesOrg)
        {
            List <ZV04IProperty> zvIList = dataCollectorSap.getZV04IList(salesOrg, IDAEnum.Task.distress);

            if (zvIList is null)
            {
                return(null);
            }
            else
            {
                zvIList = zvIList.Where(x => (x.orderQty > x.confirmedQty || x.confirmedQty == 0) && x.rejReason != "ZR").ToList();
            }

            List <ZV04HNProperty>            zvHNList = dataCollectorSap.getZV04HNList(salesOrg, IDAEnum.Task.distress) ?? new List <ZV04HNProperty>();
            List <ZV04PProperty>             zvPList  = dataCollectorSap.getZV04PList(salesOrg, IDAEnum.Task.distress) ?? new List <ZV04PProperty>();
            List <CriticalItemsDataProperty> ciList   = dataCollectorServer.getCriticalItemsDataList(salesOrg) ?? new List <CriticalItemsDataProperty>();
            List <CustomerDataProperty>      cdList   = dataCollectorServer.getCustomerDataList(salesOrg) ?? new List <CustomerDataProperty>();
            List <RejectionsProperty>        rdList   = dataCollectorServer.getRejectionsLogList(salesOrg) ?? new List <RejectionsProperty>();
            List <SwitchesProperty>          sdList   = dataCollectorServer.getSwitchesLogList(salesOrg) ?? new List <SwitchesProperty>();
            List <MM03Property>    mmList             = dataCollectorServer.getMM03List(salesOrg) ?? new List <MM03Property>();
            List <SkuDataProperty> skuList            = dataCollectorServer.getSkuDataList(salesOrg) ?? new List <SkuDataProperty>();


            //Left outer join in linq done through "into group" giving a default value for objects that are null joined
            List <GenericDistressProperty> list = getGenericDistressList(salesOrg: salesOrg, zv04iObj: zvIList,
                                                                         zv04hnObj: zvHNList, zv04pObj: zvPList,
                                                                         criticalItemObj: ciList, customerDataObj: cdList,
                                                                         rejectionDataObj: rdList, switchesDataObj: sdList,
                                                                         materialMasterObj: mmList, skuObj: skuList);

            List <GenericDistressProperty> finalListWithStock = getFinalListWithStockDetails(list: list, salesOrg: salesOrg);

            finalListWithStock.OrderBy(x => x.order).ThenBy(x => x.item);

            return(list);
        }
Ejemplo n.º 9
0
 private List <CustomerDataProperty> getCdList(string salesOrg)
 {
     return(dataCollectorServer.getCustomerDataList(salesOrg));
 }