diff --git a/src/main/java/org/spin/base/util/RecordUtil.java b/src/main/java/org/spin/base/util/RecordUtil.java index 6db4023e0..9b5f54f68 100644 --- a/src/main/java/org/spin/base/util/RecordUtil.java +++ b/src/main/java/org/spin/base/util/RecordUtil.java @@ -63,12 +63,15 @@ public static int getPageSize(int pageSize) { * @return */ public static int getPageNumber(String sessionUuid, String pageToken) { - int page = 0; + int page = 1; String pagePrefix = getPagePrefix(sessionUuid); if(!Util.isEmpty(pageToken)) { if(pageToken.startsWith(pagePrefix)) { try { page = Integer.parseInt(pageToken.replace(pagePrefix, "")); + if (page < 1) { + page = 1; + } } catch (Exception e) { // } diff --git a/src/main/java/org/spin/grpc/service/AccessServiceImplementation.java b/src/main/java/org/spin/grpc/service/AccessServiceImplementation.java index 751a61556..25527eb81 100644 --- a/src/main/java/org/spin/grpc/service/AccessServiceImplementation.java +++ b/src/main/java/org/spin/grpc/service/AccessServiceImplementation.java @@ -256,7 +256,7 @@ private ListRolesResponse.Builder convertRolesList(ListRolesRequest request) { String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); Query query = new Query(Env.getCtx(), I_AD_Role.Table_Name, "EXISTS(SELECT 1 FROM AD_User_Roles ur WHERE ur.AD_Role_ID = AD_Role.AD_Role_ID AND ur.AD_User_ID = ?)", null) .setParameters(session.getCreatedBy()); diff --git a/src/main/java/org/spin/grpc/service/BusinessDataServiceImplementation.java b/src/main/java/org/spin/grpc/service/BusinessDataServiceImplementation.java index 981f9560d..955bdae89 100644 --- a/src/main/java/org/spin/grpc/service/BusinessDataServiceImplementation.java +++ b/src/main/java/org/spin/grpc/service/BusinessDataServiceImplementation.java @@ -659,7 +659,7 @@ private ListEntitiesResponse.Builder convertEntitiesList(Properties context, Lis String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); int count = 0; ListEntitiesResponse.Builder builder = ListEntitiesResponse.newBuilder(); // diff --git a/src/main/java/org/spin/grpc/service/CoreFunctionalityImplementation.java b/src/main/java/org/spin/grpc/service/CoreFunctionalityImplementation.java index 7a43df66d..23a5bfd45 100644 --- a/src/main/java/org/spin/grpc/service/CoreFunctionalityImplementation.java +++ b/src/main/java/org/spin/grpc/service/CoreFunctionalityImplementation.java @@ -315,7 +315,7 @@ private ListBusinessPartnersResponse.Builder getBusinessPartnerList(ListBusiness ListBusinessPartnersResponse.Builder builder = ListBusinessPartnersResponse.newBuilder(); String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); int limit = (pageNumber + 1) * RecordUtil.getPageSize(request.getPageSize()); // Get business partner list // Dynamic where clause @@ -764,7 +764,7 @@ private ListOrganizationsResponse.Builder convertOrganizationsList(ListOrganizat // Get page and count String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); int limit = (pageNumber + 1) * RecordUtil.getPageSize(request.getPageSize()); Query query = new Query(Env.getCtx(), I_AD_Org.Table_Name, whereClause, null) .setParameters(parameters) @@ -798,7 +798,7 @@ private ListWarehousesResponse.Builder convertWarehousesList(ListWarehousesReque // Get page and count String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); int limit = (pageNumber + 1) * RecordUtil.getPageSize(request.getPageSize()); int id = request.getOrganizationId(); if(id <= 0) { diff --git a/src/main/java/org/spin/grpc/service/LogsServiceImplementation.java b/src/main/java/org/spin/grpc/service/LogsServiceImplementation.java index f11996293..4dc15d536 100644 --- a/src/main/java/org/spin/grpc/service/LogsServiceImplementation.java +++ b/src/main/java/org/spin/grpc/service/LogsServiceImplementation.java @@ -346,7 +346,7 @@ private ListWorkflowLogsResponse.Builder convertWorkflowLogs(ListWorkflowLogsReq String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); Query query = new Query(Env.getCtx(), I_AD_WF_Process.Table_Name, whereClause.toString(), null) .setParameters(parameters); int count = query.count(); @@ -405,7 +405,7 @@ private ListEntityLogsResponse.Builder convertEntityLogs(ListEntityLogsRequest r String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); Query query = new Query(Env.getCtx(), I_AD_ChangeLog.Table_Name, whereClause.toString(), null) .setParameters(parameters); int count = query.count(); @@ -867,7 +867,7 @@ private ListChatEntriesResponse.Builder convertChatEntries(ListChatEntriesReques String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); int id = request.getId(); if(id <= 0) { id = RecordUtil.getIdFromUuid(I_CM_Chat.Table_Name, request.getUuid(), null); @@ -929,7 +929,7 @@ private ListEntityChatsResponse.Builder convertEntityChats(ListEntityChatsReques String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); Query query = new Query(Env.getCtx(), I_CM_Chat.Table_Name, whereClause.toString(), null) .setParameters(parameters); int count = query.count(); diff --git a/src/main/java/org/spin/grpc/service/PointOfSalesServiceImplementation.java b/src/main/java/org/spin/grpc/service/PointOfSalesServiceImplementation.java index ad1783195..838a4fb5c 100644 --- a/src/main/java/org/spin/grpc/service/PointOfSalesServiceImplementation.java +++ b/src/main/java/org/spin/grpc/service/PointOfSalesServiceImplementation.java @@ -1212,7 +1212,7 @@ public void listCustomerBankAccounts(ListCustomerBankAccountsRequest request, St String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); // Dynamic where clause // Get Product list Query query = new Query(Env.getCtx(), I_C_BP_BankAccount.Table_Name, I_C_BP_BankAccount.COLUMNNAME_C_BPartner_ID + " = ?", null) @@ -1648,7 +1648,7 @@ private ListAvailableSellersResponse.Builder listAvailableSellers(ListAvailableS String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); int posId = RecordUtil.getIdFromUuid(I_C_POS.Table_Name, request.getPosUuid(), null); // StringBuffer whereClause = new StringBuffer(); @@ -1798,7 +1798,7 @@ private ListCashSummaryMovementsResponse.Builder listCashSummaryMovements(ListCa String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); int count = 0; try { // Get Bank statement @@ -2183,7 +2183,7 @@ private ListShipmentLinesResponse.Builder listShipmentLines(ListShipmentLinesReq String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); int shipmentId = RecordUtil.getIdFromUuid(I_M_InOut.Table_Name, request.getShipmentUuid(), null); // Get Product list Query query = new Query(Env.getCtx(), I_M_InOutLine.Table_Name, I_M_InOutLine.COLUMNNAME_M_InOut_ID + " = ?", null) @@ -2225,7 +2225,7 @@ private ListPaymentReferencesResponse.Builder listPaymentReferencesLines(ListPay String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); List parameters = new ArrayList(); StringBuffer whereClause = new StringBuffer("IsPaid = 'N' AND Processed = 'N'"); if(!Util.isEmpty(request.getOrderUuid())) { @@ -2921,7 +2921,7 @@ private ListAvailableWarehousesResponse.Builder listWarehouses(ListAvailableWare String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); // Aisle Seller int posId = RecordUtil.getIdFromUuid(I_C_POS.Table_Name, request.getPosUuid(), null); // Get Product list @@ -2971,7 +2971,7 @@ private ListAvailablePriceListResponse.Builder listPriceList(ListAvailablePriceL String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); // Dynamic where clause // Aisle Seller int posId = RecordUtil.getIdFromUuid(I_C_POS.Table_Name, request.getPosUuid(), null); @@ -3028,7 +3028,7 @@ private ListAvailablePaymentMethodsResponse.Builder listPaymentMethods(ListAvail String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); // Dynamic where clause // Aisle Seller int posId = RecordUtil.getIdFromUuid(I_C_POS.Table_Name, request.getPosUuid(), null); @@ -3092,7 +3092,7 @@ private ListAvailableDocumentTypesResponse.Builder listDocumentTypes(ListAvailab String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); // Dynamic where clause // Aisle Seller int posId = RecordUtil.getIdFromUuid(I_C_POS.Table_Name, request.getPosUuid(), null); @@ -3137,7 +3137,7 @@ private ListAvailableCurrenciesResponse.Builder listCurrencies(ListAvailableCurr String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); // Dynamic where clause String whereClause = "EXISTS(SELECT 1 FROM C_Conversion_Rate cr " + "WHERE (cr.C_Currency_ID = C_Currency.C_Currency_ID OR cr.C_Currency_ID_To = C_Currency.C_Currency_ID) " @@ -3709,7 +3709,7 @@ private ListOrdersResponse.Builder listOrders(ListOrdersRequest request) { String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); // Dynamic where clause int posId = RecordUtil.getIdFromUuid(I_C_POS.Table_Name, request.getPosUuid(), null); int salesRepresentativeId = RecordUtil.getIdFromUuid(I_AD_User.Table_Name, request.getSalesRepresentativeUuid(), null); @@ -3830,7 +3830,7 @@ private ListPaymentsResponse.Builder listPayments(ListPaymentsRequest request) { String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); // Dynamic where clause StringBuffer whereClause = new StringBuffer(); // Parameters @@ -3897,7 +3897,7 @@ private ListOrderLinesResponse.Builder listOrderLines(ListOrderLinesRequest requ String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); StringBuffer whereClause = new StringBuffer(I_C_OrderLine.COLUMNNAME_C_Order_ID + " = ?"); List parameters = new ArrayList<>(); parameters.add(orderId); @@ -4756,7 +4756,7 @@ private ListPointOfSalesResponse.Builder convertPointOfSalesList(ListPointOfSale String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); // Get POS List boolean isAppliedNewFeaturesPOS = M_Element.get(Env.getCtx(), "IsSharedPOS") != null && M_Element.get(Env.getCtx(), "IsAllowsAllocateSeller") != null; StringBuffer whereClause = new StringBuffer("SalesRep_ID = ? OR EXISTS(SELECT 1 FROM AD_User u WHERE u.AD_User_ID = ? AND IsPOSManager = 'Y')"); @@ -5572,7 +5572,7 @@ private ListProductPriceResponse.Builder getProductPriceList(ListProductPriceReq String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); // Dynamic where clause StringBuffer whereClause = new StringBuffer(); // Parameters diff --git a/src/main/java/org/spin/grpc/service/UpdateImplementation.java b/src/main/java/org/spin/grpc/service/UpdateImplementation.java index 958addf67..115305466 100644 --- a/src/main/java/org/spin/grpc/service/UpdateImplementation.java +++ b/src/main/java/org/spin/grpc/service/UpdateImplementation.java @@ -141,7 +141,7 @@ private ListStepsResponse.Builder convertStepsList(ListStepsRequest request) { String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber("page-token", request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); // Get POS List StringBuffer whereClause = new StringBuffer("AD_Migration_ID = ?"); List parameters = new ArrayList<>(); @@ -230,7 +230,7 @@ private ListUpdatesResponse.Builder convertUpdatesList(ListUpdatesRequest reques String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber("page-token", request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); // Get POS List StringBuffer whereClause = new StringBuffer("EntityType = ?"); List parameters = new ArrayList<>(); @@ -303,7 +303,7 @@ private ListPackagesResponse.Builder convertPackagesList(ListPackagesRequest req String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber("page-token", request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); // Get POS List String whereClause = null; List parameters = new ArrayList<>(); diff --git a/src/main/java/org/spin/grpc/service/UserInterfaceServiceImplementation.java b/src/main/java/org/spin/grpc/service/UserInterfaceServiceImplementation.java index 0b0eddac4..5b0081c5d 100644 --- a/src/main/java/org/spin/grpc/service/UserInterfaceServiceImplementation.java +++ b/src/main/java/org/spin/grpc/service/UserInterfaceServiceImplementation.java @@ -1039,7 +1039,7 @@ private ListTabEntitiesResponse.Builder convertEntitiesList(Properties context, String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); int count = 0; ListTabEntitiesResponse.Builder builder = ListTabEntitiesResponse.newBuilder(); // @@ -2665,7 +2665,7 @@ private ListLookupItemsResponse.Builder convertLookupItemsList(ListLookupItemsRe String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); int count = 0; // Count records count = RecordUtil.countRecords(sql, reference.TableName, parameters); @@ -2962,7 +2962,7 @@ private ListBrowserItemsResponse.Builder convertBrowserList(ListBrowserItemsRequ } int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); // Add Row Number parsedSQL = RecordUtil.getQueryWithLimit(parsedSQL, limit, offset); // Add Order By diff --git a/src/main/java/org/spin/grpc/service/WebStoreServiceImplementation.java b/src/main/java/org/spin/grpc/service/WebStoreServiceImplementation.java index 461b953b3..e037c853f 100644 --- a/src/main/java/org/spin/grpc/service/WebStoreServiceImplementation.java +++ b/src/main/java/org/spin/grpc/service/WebStoreServiceImplementation.java @@ -1373,7 +1373,7 @@ private ListOrdersResponse.Builder listOrders(ListOrdersRequest request) { String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); // Get Orders list Query query = new Query(Env.getCtx(), I_C_Order.Table_Name, "EXISTS(SELECT 1 FROM W_Basket b WHERE b.W_Basket_ID = C_Order.W_Basket_ID AND b.AD_User_ID = ?)", null) .setParameters(Env.getAD_User_ID(Env.getCtx())) @@ -1418,7 +1418,7 @@ private ListShippingMethodsResponse.Builder listShippingMethods(ListShippingMeth String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); StringBuffer whereClause = new StringBuffer(I_M_Product.COLUMNNAME_SKU + " IN("); whereClause.append(")"); Query query = new Query(Env.getCtx(), I_W_DeliveryViaRuleAllocation.Table_Name, I_W_DeliveryViaRuleAllocation.COLUMNNAME_W_Store_ID + " = ?", null) @@ -1594,7 +1594,7 @@ private ListPaymentMethodsResponse.Builder listPaymentMethods(ListPaymentMethods String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); Query query = new Query(Env.getCtx(), I_C_PaymentMethod.Table_Name, "EXISTS(SELECT 1 FROM C_PaymentMethodAllocation a " + "WHERE a.C_PaymentMethod_ID = C_PaymentMethod.C_PaymentMethod_ID " + "AND a.W_Store_ID = ?)" , null) @@ -2336,7 +2336,7 @@ private ListProductsResponse.Builder listProducts(ListProductsRequest request) { String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); StringBuffer whereClause = new StringBuffer(I_M_Product.COLUMNNAME_SKU + " IN("); AtomicBoolean first = new AtomicBoolean(true); List parameters = new ArrayList<>(); @@ -2394,7 +2394,7 @@ private ListRenderProductsResponse.Builder listRenderProducts(ListRenderProducts String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); StringBuffer whereClause = new StringBuffer(I_M_Product.COLUMNNAME_SKU + " IN("); AtomicBoolean first = new AtomicBoolean(true); List parameters = new ArrayList<>(); @@ -2628,7 +2628,7 @@ private ListStocksResponse.Builder listStocks(ListStocksRequest request) { String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); Query query = new Query(Env.getCtx(), I_M_Storage.Table_Name, I_M_Storage.COLUMNNAME_M_Product_ID + " = ? " + "AND " + I_M_Storage.COLUMNNAME_QtyOnHand + " > 0", null) diff --git a/src/main/java/org/spin/grpc/service/WorkflowServiceImplementation.java b/src/main/java/org/spin/grpc/service/WorkflowServiceImplementation.java index 9ec3ccd7f..7289f8e18 100644 --- a/src/main/java/org/spin/grpc/service/WorkflowServiceImplementation.java +++ b/src/main/java/org/spin/grpc/service/WorkflowServiceImplementation.java @@ -184,7 +184,7 @@ private ListWorkflowActivitiesResponse.Builder convertWorkflowActivities(Propert String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); Query query = new Query(context, I_AD_WF_Activity.Table_Name, whereClause, null) .setParameters(userId, userId, userId, userId); int count = query.count(); @@ -428,7 +428,7 @@ private ListWorkflowsResponse.Builder convertWorkflows(Properties context, ListW String nexPageToken = null; int pageNumber = RecordUtil.getPageNumber(request.getClientRequest().getSessionUuid(), request.getPageToken()); int limit = RecordUtil.getPageSize(request.getPageSize()); - int offset = pageNumber * RecordUtil.getPageSize(request.getPageSize()); + int offset = (pageNumber - 1) * RecordUtil.getPageSize(request.getPageSize()); Query query = new Query(context, I_AD_Workflow.Table_Name, whereClause.toString(), null) .setParameters(parameters); int count = query.count();