diff --git a/fineract-core/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java b/fineract-core/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java index b95df2d30..398218dec 100644 --- a/fineract-core/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java +++ b/fineract-core/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java @@ -71,6 +71,158 @@ public class CommandWrapperBuilder { this.sanitizeJsonKeys); } + public CommandWrapperBuilder createChequeSeries() { + this.actionName = "CREATE"; + this.entityName = "CHEQUESERIES"; + this.entityId = null; + this.href = "/chequeseries"; + return this; + } + + public CommandWrapperBuilder updateChequeSeries(final Long seriesId) { + this.actionName = "UPDATE"; + this.entityName = "CHEQUESERIES"; + this.entityId = seriesId; + this.href = "/chequeseries/" + seriesId; + return this; + } + + public CommandWrapperBuilder deleteChequeSeries(final Long seriesId) { + this.actionName = "DELETE"; + this.entityName = "CHEQUESERIES"; + this.entityId = seriesId; + this.href = "/chequeseries/" + seriesId; + return this; + } + + public CommandWrapperBuilder createChequeStockLot() { + this.actionName = "CREATE"; + this.entityName = "CHEQUESTOCKLOT"; + this.entityId = null; + this.href = "/chequestocklots"; + return this; + } + + public CommandWrapperBuilder reportLostChequeStockLot(final Long lotId) { + this.actionName = "REPORTLOST"; + this.entityName = "CHEQUESTOCKLOT"; + this.entityId = lotId; + this.href = "/chequestocklots/" + lotId; + return this; + } + + public CommandWrapperBuilder createChequeStockTransfer() { + this.actionName = "CREATE"; + this.entityName = "CHEQUESTOCKTRANSFER"; + this.entityId = null; + this.href = "/chequestocktransfers"; + return this; + } + + public CommandWrapperBuilder receiveChequeStockTransfer(final Long transferId) { + this.actionName = "RECEIVE"; + this.entityName = "CHEQUESTOCKTRANSFER"; + this.entityId = transferId; + this.href = "/chequestocktransfers/" + transferId; + return this; + } + + public CommandWrapperBuilder rejectChequeStockTransfer(final Long transferId) { + this.actionName = "REJECT"; + this.entityName = "CHEQUESTOCKTRANSFER"; + this.entityId = transferId; + this.href = "/chequestocktransfers/" + transferId; + return this; + } + + public CommandWrapperBuilder createChequeBook() { + this.actionName = "CREATE"; + this.entityName = "CHEQUEBOOK"; + this.entityId = null; + this.href = "/chequebooks"; + return this; + } + + public CommandWrapperBuilder issueChequeBook(final Long chequeBookId) { + this.actionName = "ISSUE"; + this.entityName = "CHEQUEBOOK"; + this.entityId = chequeBookId; + this.href = "/chequebooks/" + chequeBookId; + return this; + } + + public CommandWrapperBuilder rejectChequeBook(final Long chequeBookId) { + this.actionName = "REJECT"; + this.entityName = "CHEQUEBOOK"; + this.entityId = chequeBookId; + this.href = "/chequebooks/" + chequeBookId; + return this; + } + + public CommandWrapperBuilder withdrawChequeBook(final Long chequeBookId) { + this.actionName = "WITHDRAW"; + this.entityName = "CHEQUEBOOK"; + this.entityId = chequeBookId; + this.href = "/chequebooks/" + chequeBookId; + return this; + } + + public CommandWrapperBuilder stopPaymentChequeBook(final Long chequeBookId) { + this.actionName = "STOPPAYMENT"; + this.entityName = "CHEQUEBOOK"; + this.entityId = chequeBookId; + this.href = "/chequebooks/" + chequeBookId; + return this; + } + + public CommandWrapperBuilder revokeStopPaymentChequeBook(final Long chequeBookId) { + this.actionName = "REVOKESTOPPAYMENT"; + this.entityName = "CHEQUEBOOK"; + this.entityId = chequeBookId; + this.href = "/chequebooks/" + chequeBookId; + return this; + } + + public CommandWrapperBuilder reportLostChequeBook(final Long chequeBookId) { + this.actionName = "REPORTLOST"; + this.entityName = "CHEQUEBOOK"; + this.entityId = chequeBookId; + this.href = "/chequebooks/" + chequeBookId; + return this; + } + + public CommandWrapperBuilder cancelLeafChequeBook(final Long chequeBookId) { + this.actionName = "CANCELLEAF"; + this.entityName = "CHEQUEBOOK"; + this.entityId = chequeBookId; + this.href = "/chequebooks/" + chequeBookId; + return this; + } + + public CommandWrapperBuilder markUsedChequeBook(final Long chequeBookId) { + this.actionName = "MARKUSED"; + this.entityName = "CHEQUEBOOK"; + this.entityId = chequeBookId; + this.href = "/chequebooks/" + chequeBookId; + return this; + } + + public CommandWrapperBuilder approveChequeBookPendingRequest(final Long pendingRequestId) { + this.actionName = "APPROVE"; + this.entityName = "CHEQUEBOOKPENDINGREQUEST"; + this.entityId = pendingRequestId; + this.href = "/chequebook/pending-requests/" + pendingRequestId; + return this; + } + + public CommandWrapperBuilder rejectChequeBookPendingRequest(final Long pendingRequestId) { + this.actionName = "REJECT"; + this.entityName = "CHEQUEBOOKPENDINGREQUEST"; + this.entityId = pendingRequestId; + this.href = "/chequebook/pending-requests/" + pendingRequestId; + return this; + } + public CommandWrapperBuilder updateCreditBureau() { this.actionName = "UPDATE"; this.entityName = "ORGANISATIONCREDITBUREAU"; diff --git a/fineract-current-product/src/main/java/org/apache/fineract/portfolio/currentaccount/domain/CurrentAccountRepositoryWrapper.java b/fineract-current-product/src/main/java/org/apache/fineract/portfolio/currentaccount/domain/CurrentAccountRepositoryWrapper.java new file mode 100644 index 000000000..fc15692f1 --- /dev/null +++ b/fineract-current-product/src/main/java/org/apache/fineract/portfolio/currentaccount/domain/CurrentAccountRepositoryWrapper.java @@ -0,0 +1,47 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.currentaccount.domain; + +import lombok.RequiredArgsConstructor; +import org.apache.fineract.portfolio.currentaccount.exception.CurrentAccountNotFoundException; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + *
+ * Wrapper for {@link CurrentAccountRepository} that is responsible for checking if {@link CurrentAccount} is
+ * returned when using findOne repository method and throwing an appropriate not found exception.
+ *
+ * This is to avoid need for checking and throwing in multiple areas of code base where + * {@link CurrentAccountRepository} is required. + *
+ */ +@Service +@RequiredArgsConstructor +public class CurrentAccountRepositoryWrapper { + + private final CurrentAccountRepository repository; + + @Transactional(readOnly = true) + public CurrentAccount findOneWithNotFoundDetection(final Long id) { + return this.repository.findById(id).orElseThrow(() -> new CurrentAccountNotFoundException(id)); + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/chequebook/api/ChequeBookApiConstants.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/chequebook/api/ChequeBookApiConstants.java new file mode 100644 index 000000000..a9b340521 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/chequebook/api/ChequeBookApiConstants.java @@ -0,0 +1,35 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.chequebook.api; + +public final class ChequeBookApiConstants { + + private ChequeBookApiConstants() {} + + public static final String ENTITY_SERIES = "CHEQUESERIES"; + public static final String ENTITY_STOCK_LOT = "CHEQUESTOCKLOT"; + public static final String ENTITY_STOCK_TRANSFER = "CHEQUESTOCKTRANSFER"; + public static final String ENTITY_BOOK = "CHEQUEBOOK"; + public static final String ENTITY_PENDING_REQUEST = "CHEQUEBOOKPENDINGREQUEST"; + + public static final String RESOURCE_SERIES = "chequeseries"; + public static final String RESOURCE_STOCK_LOT = "chequestocklot"; + public static final String RESOURCE_STOCK_TRANSFER = "chequestocktransfer"; + public static final String RESOURCE_BOOK = "chequebook"; +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/chequebook/api/ChequeBookApiJsonInputParams.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/chequebook/api/ChequeBookApiJsonInputParams.java new file mode 100644 index 000000000..f02e15eca --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/chequebook/api/ChequeBookApiJsonInputParams.java @@ -0,0 +1,113 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.chequebook.api; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Collectors; + +public enum ChequeBookApiJsonInputParams { + + // series create/update + SERIES_CODE("seriesCode"), // + NAME("name"), // + LEAVES_PER_BOOK("leavesPerBook"), // + APPLICABLE_ACCOUNT_TYPE("applicableAccountType"), // + CTS_COMPLIANT("ctsCompliant"), // + REORDER_LEVEL("reorderLevel"), // + // stock lot receive + SERIES_ID("seriesId"), // + OFFICE_ID("officeId"), // + RANGE_START("rangeStart"), // + RANGE_END("rangeEnd"), // + BATCH_REF("batchRef"), // + // stock lot report-lost + FROM_SERIAL_NO("fromSerialNo"), // + REASON("reason"), // + // stock transfer dispatch + FROM_OFFICE_ID("fromOfficeId"), // + TO_OFFICE_ID("toOfficeId"), // + FROM_LOT_ID("fromLotId"), // + NO_OF_LEAVES("noOfLeaves"), // + // book request + ACCOUNT_TYPE("accountType"), // + ACCOUNT_ID("accountId"), // + NO_OF_BOOKS("noOfBooks"), // + // book issue + COLLECTION_ACKNOWLEDGED("collectionAcknowledged"), // + // book reject + REJECTION_REASON("rejectionReason"), // + // book leaf actions (stop-payment / revoke / report-lost / cancel-leaf) + FROM_LEAF_SEQ("fromLeafSeq"), // + TO_LEAF_SEQ("toLeafSeq"), // + // common — the web client always sends these on command payloads + LOCALE("locale"), // + DATE_FORMAT("dateFormat"); // + + private final String value; + + ChequeBookApiJsonInputParams(final String value) { + this.value = value; + } + + public String getValue() { + return this.value; + } + + public static Set
+ * Legal transitions: (created)->ACTIVE (issued) or (created, no book)->LOST (unissued theft report);
+ * ACTIVE<->STOP_PAYMENT (the one round-trip); ACTIVE->CANCELLED / LOST / WITHDRAWN / USED (all terminal).
+ * A recovered "lost" cheque conventionally stays hotlisted rather than silently reactivating, since the
+ * customer has typically already been issued a replacement book. USED is manually recorded by a branch,
+ * never automatic — see {@link #markUsed(String, Long)}.
+ */
+@Entity
+@Table(name = "m_cheque_leaf")
+@NoArgsConstructor(access = AccessLevel.PROTECTED)
+@Getter
+public class ChequeLeaf extends AbstractPersistableCustom