private void startRejectionsLog(RejectionsSapOrderProperty rejObj, string id, string tableName, bool isRelease)
 {
     log.update(
         tableName: tableName,
         columnNames: new[] { "startTime" },
         values: new[] { Strings.Format(DateTime.Now, "yyyyMMdd HH:mm:ss") },
         conditionName: isRelease ? new[] { "[orderNumber]", "[id]", "[isDuringRelease]" } : new[] { "[orderNumber]", "[isDuringRelease]" },
         conditionValue: isRelease ? new[] { rejObj.orderNumber.ToString(), id, "1" } : new[] { rejObj.orderNumber.ToString(), "0" },
         customCondition: isRelease ? "" : "([status] IS NULL OR [status] = 'Fail: blocked by batch job' OR [status] = 'Fail: blocked by user')"
         );
 }
 private void endLog(RejectionsSapOrderProperty rejObj, string id, string tableName, RejectionsSapLineProperty rejection, bool shouldChange, bool isRelease)
 {
     log.update(
         tableName: tableName,
         columnNames: new[] { "status", "reason" },
         values: new[] { shouldChange ? "success" : "fail", rejection.reason.Replace("'", "") },
         conditionName: isRelease ? new[] { "[orderNumber]", "[id]", "[isDuringRelease]" } : new[] { "[orderNumber]", "[isDuringRelease]" },
         conditionValue: isRelease ? new[] { rejObj.orderNumber.ToString(), id, "1" } : new[] { rejObj.orderNumber.ToString(), "0" },
         customCondition: isRelease ? "" : "([status] IS NULL OR [status] = 'Fail: blocked by batch job' OR [status] = 'Fail: blocked by user')"
         );
 }
Esempio n. 3
0
        public void runRejections_Should_SpltLineCorrectly_When_UnitsOfMeasuresAreMUN()
        {
            IVA02 va02 = new VA02(sap, idaLog);
            RejectionsSapOrderProperty rejectionsSapOrderProperty = getRejList();

            sap.enterTCode("VA02");
            va02.enterOrder(rejectionsSapOrderProperty.orderNumber);
            va02.bypassInitialPopups();
            ITable table = va02.getTable();
            var    rejectionsVA02Runner = new RejectionsVA02Runner(sap: sap, log: idaLog, va02: va02, isRelease: true, isLog: false);

            rejectionsVA02Runner.runRejections(rejectionsSapOrderProperty, "someID", "someTable");
        }
        private string executeLineChanges(RejectionsSapOrderProperty rejObj, string id, string tableName, string csrNote, List <ReplacePartialCutProperty> rpcpList, ITable table)
        {
            foreach (var rejection in rejObj.lineDetails)
            {
                int  sapLineNumber = (rejection.lineNumber / 10 - 1);
                bool shouldChange  = isForChange(table, rejection, sapLineNumber);
                //TODO: Check if order qty can be changed prior to line split
                if (shouldChange)
                {
                    if (rejection.isReplacePartialCut)
                    {
                        rpcpList.Add(getRPCProperty(table.getCellValue(sapLineNumber, "Un"), rejection));

                        rejection.reason = $"Split into rejected {rejection.orderedQty - rejection.confirmedQty} cases " +
                                           $"and confirmed {rejection.confirmedQty} cases to be sent for customer.";

                        changeQtyToConfirmedAmount(table, rejection, sapLineNumber);
                    }
                    else
                    {
                        table.setCellValue(sapLineNumber, VA02.rejectionCodeColumnIndex, rejection.rejectionCode);
                    }
                }

                sap.pressEnter();
                sap.getRidOfPopUps();

                csrNote += $"sku {rejection.sku} has{(shouldChange ? " " : " not ")}been rejected with {rejection.rejectionCode}. Reason: {rejection.reason}{Constants.vbCr}";

                if (isLog)
                {
                    endLog(rejObj, id, tableName, rejection, shouldChange, isRelease);
                }
            }

            if (rpcpList.Count > 0)
            {
                populateCutSkus(rpcpList, table);
            }

            return(csrNote);
        }
Esempio n. 5
0
        private void updateOrderLog(string tableName, RejectionsSapOrderProperty rejObj, OrderStatus status)
        {
            switch (status)
            {
            case OrderStatus.success: {
                idaLog.update(
                    tableName: tableName,
                    columnNames: new[] { "endTime" },
                    values: new[] { Strings.Format(DateTime.Now, "yyyyMMdd HH:mm:ss") },
                    conditionName: isReleaseRejections ? new[] { "orderNumber", "id", "isDuringRelease" } : new[] { "orderNumber", "isDuringRelease" },
                    conditionValue: isReleaseRejections ? new[] { rejObj.orderNumber.ToString(), id, "1" } : new[] { rejObj.orderNumber.ToString(), "0", },
                    customCondition: isReleaseRejections ? "" : "([endTime] IS NULL)"
                    );
                break;
            }

            case OrderStatus.failedToSave: {
                updateFailedOrderLog("Failed to save order", tableName, rejObj.orderNumber);
                break;
            }

            case OrderStatus.blockedByBatchJob: {
                updateFailedOrderLog("Blocked by batch job", tableName, rejObj.orderNumber);
                break;
            }

            case OrderStatus.blockedByUser: {
                updateFailedOrderLog("Blocked by user", tableName, rejObj.orderNumber);
                break;
            }

            case OrderStatus.orderMissingPaymentTerms: {
                updateFailedOrderLog("Cannot save order due to missing payment terms", tableName, rejObj.orderNumber);
                break;
            }

            default: {
                throw new NotImplementedException();
            }
            }
        }
        public OrderStatus runRejections(RejectionsSapOrderProperty rejObj, string id, string tableName)
        {
            string csrNote = "";
            List <ReplacePartialCutProperty> rpcpList = new List <ReplacePartialCutProperty>();

            if (isLog)
            {
                startRejectionsLog(rejObj, id, tableName, isRelease);
            }

            OrderStatus status = va02.enterOrder(rejObj.orderNumber);

            if (status != OrderStatus.available)
            {
                return(status);
            }

            string paymentTermsID = VA02ID.PAYMENT_TERMS_ID.Where(x => sap.idExists(x)).First();

            if ((sap.findById(paymentTermsID) as dynamic).text == "")
            {
                status = OrderStatus.orderMissingPaymentTerms;
                return(status);
            }

            va02.bypassInitialPopups();

            ITable table = va02.getTable();

            va02.moveRejectionCodeColumnToIndexEight(table);

            csrNote = executeLineChanges(rejObj, id, tableName, csrNote, rpcpList, table);

            va02.soarAction(csrNote, "Line Rejections", rejObj.orderNumber);
            va02.save();

            return(va02.getOrderStatusAfterSaving());
        }