FINERACT-1932: Fineract modularization - fineract-branch

This commit is contained in:
Jose Alberto Hernandez
2024-04-09 20:25:24 +02:00
committed by Adam Saghy
parent cf65d81ccc
commit d7a4e0e953
62 changed files with 308 additions and 124 deletions
@@ -1,38 +0,0 @@
/**
* 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.organisation.monetary.data;
import java.util.Collection;
/**
* Immutable data object for application currency.
*/
public class ApplicationCurrencyConfigurationData {
@SuppressWarnings("unused")
private final Collection<CurrencyData> selectedCurrencyOptions;
@SuppressWarnings("unused")
private final Collection<CurrencyData> currencyOptions;
public ApplicationCurrencyConfigurationData(final Collection<CurrencyData> currencyOptions,
final Collection<CurrencyData> selectedCurrencyOptions) {
this.currencyOptions = currencyOptions;
this.selectedCurrencyOptions = selectedCurrencyOptions;
}
}
@@ -1,31 +0,0 @@
/**
* 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.organisation.monetary.service;
import java.util.Collection;
import org.apache.fineract.organisation.monetary.data.CurrencyData;
public interface CurrencyReadPlatformService {
Collection<CurrencyData> retrieveAllowedCurrencies();
Collection<CurrencyData> retrieveAllPlatformCurrencies();
CurrencyData retrieveCurrency(String code);
}
@@ -1,28 +0,0 @@
/**
* 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.organisation.monetary.service;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
public interface CurrencyWritePlatformService {
CommandProcessingResult updateAllowedCurrencies(JsonCommand command);
}
@@ -1,27 +0,0 @@
/**
* 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.organisation.monetary.service;
import org.apache.fineract.organisation.monetary.data.ApplicationCurrencyConfigurationData;
public interface OrganisationCurrencyReadPlatformService {
ApplicationCurrencyConfigurationData retrieveCurrencyConfiguration();
}
@@ -1,36 +0,0 @@
/**
* 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.organisation.staff.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
import org.springframework.dao.EmptyResultDataAccessException;
/**
* A {@link RuntimeException} thrown when staff resources are not found.
*/
public class StaffNotFoundException extends AbstractPlatformResourceNotFoundException {
public StaffNotFoundException(final Long id) {
super("error.msg.staff.id.invalid", "Staff with identifier " + id + " does not exist", id);
}
public StaffNotFoundException(Long id, EmptyResultDataAccessException e) {
super("error.msg.staff.id.invalid", "Staff with identifier " + id + " does not exist", id, e);
}
}
@@ -1,60 +0,0 @@
/**
* 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.organisation.teller.api;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Collection;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.organisation.teller.data.CashierData;
import org.apache.fineract.organisation.teller.service.TellerManagementReadPlatformService;
import org.springframework.stereotype.Component;
@Path("/v1/cashiers")
@Component
@Tag(name = "Cashiers", description = "")
@RequiredArgsConstructor
public class CashierApiResource {
private final DefaultToApiJsonSerializer<CashierData> jsonSerializer;
private final TellerManagementReadPlatformService readPlatformService;
@GET
@Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
public String getCashierData(@QueryParam("officeId") final Long officeId, @QueryParam("tellerId") final Long tellerId,
@QueryParam("staffId") final Long staffId, @QueryParam("date") final String date) {
final DateTimeFormatter dateFormatter = DateTimeFormatter.BASIC_ISO_DATE;
final LocalDate dateRestriction = (date != null ? LocalDate.parse(date, dateFormatter) : DateUtils.getBusinessLocalDate());
final Collection<CashierData> allCashiers = this.readPlatformService.getCashierData(officeId, tellerId, staffId, dateRestriction);
return this.jsonSerializer.serialize(allCashiers);
}
}
@@ -1,419 +0,0 @@
/**
* 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.organisation.teller.api;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Collection;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.commands.domain.CommandWrapper;
import org.apache.fineract.commands.service.CommandWrapperBuilder;
import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.infrastructure.core.service.Page;
import org.apache.fineract.infrastructure.core.service.SearchParameters;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.apache.fineract.organisation.teller.data.CashierData;
import org.apache.fineract.organisation.teller.data.CashierTransactionData;
import org.apache.fineract.organisation.teller.data.CashierTransactionsWithSummaryData;
import org.apache.fineract.organisation.teller.data.TellerData;
import org.apache.fineract.organisation.teller.data.TellerJournalData;
import org.apache.fineract.organisation.teller.data.TellerTransactionData;
import org.apache.fineract.organisation.teller.service.TellerManagementReadPlatformService;
import org.apache.fineract.organisation.teller.util.DateRange;
import org.springframework.stereotype.Component;
@Path("/v1/tellers")
@Component
@Tag(name = "Teller Cash Management", description = "Teller cash management which will allow an organization to manage their cash transactions at branches or head office more effectively.")
@RequiredArgsConstructor
public class TellerApiResource {
private final PlatformSecurityContext securityContext;
private final DefaultToApiJsonSerializer<TellerData> jsonSerializer;
private final TellerManagementReadPlatformService readPlatformService;
private final PortfolioCommandSourceWritePlatformService commandWritePlatformService;
@GET
@Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "List all tellers", description = "Retrieves list tellers")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(array = @ArraySchema(schema = @Schema(implementation = TellerApiResourceSwagger.GetTellersResponse.class)))) })
public String getTellerData(@QueryParam("officeId") @Parameter(description = "officeId") final Long officeId) {
final Collection<TellerData> foundTellers = this.readPlatformService.getTellers(officeId);
return this.jsonSerializer.serialize(foundTellers);
}
@GET
@Path("{tellerId}")
@Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Retrieve tellers", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = TellerApiResourceSwagger.GetTellersResponse.class))) })
public String findTeller(@PathParam("tellerId") @Parameter(description = "tellerId") final Long tellerId) {
final TellerData teller = this.readPlatformService.findTeller(tellerId);
return this.jsonSerializer.serialize(teller);
}
@POST
@Consumes({ MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Create teller", description = "Mandatory Fields\n" + "Teller name, OfficeId, Description, Start Date, Status\n"
+ "Optional Fields\n" + "End Date")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = TellerApiResourceSwagger.PostTellersRequest.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = TellerApiResourceSwagger.PostTellersResponse.class))) })
public String createTeller(@Parameter(hidden = true) final String tellerData) {
final CommandWrapper request = new CommandWrapperBuilder().createTeller().withJson(tellerData).build();
final CommandProcessingResult result = this.commandWritePlatformService.logCommandSource(request);
return this.jsonSerializer.serialize(result);
}
@PUT
@Path("{tellerId}")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Update teller", description = "")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = TellerApiResourceSwagger.PutTellersRequest.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = TellerApiResourceSwagger.PutTellersResponse.class))) })
public String updateTeller(@PathParam("tellerId") @Parameter(description = "tellerId") final Long tellerId,
@Parameter(hidden = true) final String tellerData) {
final CommandWrapper request = new CommandWrapperBuilder().updateTeller(tellerId).withJson(tellerData).build();
final CommandProcessingResult result = this.commandWritePlatformService.logCommandSource(request);
return this.jsonSerializer.serialize(result);
}
@DELETE
@Path("{tellerId}")
@Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
public String deleteTeller(@PathParam("tellerId") @Parameter(description = "tellerId") final Long tellerId) {
final CommandWrapper request = new CommandWrapperBuilder().deleteTeller(tellerId).build();
final CommandProcessingResult result = this.commandWritePlatformService.logCommandSource(request);
return this.jsonSerializer.serialize(result);
}
@GET
@Path("{tellerId}/cashiers")
@Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "List Cashiers", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = TellerApiResourceSwagger.GetTellersTellerIdCashiersResponse.class))) })
public String getCashierData(@PathParam("tellerId") @Parameter(description = "tellerId") final Long tellerId,
@QueryParam("fromdate") @Parameter(description = "fromdate") final String fromDateStr,
@QueryParam("todate") @Parameter(description = "todate") final String toDateStr) {
final DateTimeFormatter dateFormatter = DateTimeFormatter.BASIC_ISO_DATE;
final LocalDate fromDate = fromDateStr != null ? LocalDate.parse(fromDateStr, dateFormatter) : DateUtils.getBusinessLocalDate();
final LocalDate toDate = toDateStr != null ? LocalDate.parse(toDateStr, dateFormatter) : DateUtils.getBusinessLocalDate();
final TellerData teller = this.readPlatformService.findTeller(tellerId);
final Collection<CashierData> cashiers = this.readPlatformService.getCashiersForTeller(tellerId, fromDate, toDate);
CashiersForTeller cashiersForTeller = new CashiersForTeller();
cashiersForTeller.cashiers = cashiers;
cashiersForTeller.tellerId = tellerId;
cashiersForTeller.tellerName = teller.getName();
cashiersForTeller.officeId = teller.getOfficeId();
cashiersForTeller.officeName = teller.getOfficeName();
return this.jsonSerializer.serialize(cashiersForTeller);
}
@GET
@Path("{tellerId}/cashiers/{cashierId}")
@Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Retrieve a cashier", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = TellerApiResourceSwagger.GetTellersTellerIdCashiersCashierIdResponse.class))) })
public String findCashierData(@PathParam("tellerId") @Parameter(description = "tellerId") final Long tellerId,
@PathParam("cashierId") @Parameter(description = "cashierId") final Long cashierId) {
final CashierData cashier = this.readPlatformService.findCashier(cashierId);
return this.jsonSerializer.serialize(cashier);
}
@GET
@Path("{tellerId}/cashiers/template")
@Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Find Cashiers", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = TellerApiResourceSwagger.GetTellersTellerIdCashiersTemplateResponse.class))) })
public String getCashierTemplate(@PathParam("tellerId") @Parameter(description = "tellerId") final Long tellerId) {
final TellerData teller = this.readPlatformService.findTeller(tellerId);
Long officeId = teller.getOfficeId();
final CashierData cashier = this.readPlatformService.retrieveCashierTemplate(officeId, tellerId, true);
return this.jsonSerializer.serialize(cashier);
}
@POST
@Path("{tellerId}/cashiers")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Create Cashiers", description = "Mandatory Fields: \n"
+ "Cashier/staff, Fromm Date, To Date, Full Day or From time and To time\n" + "\n\n\n" + "Optional Fields: \n"
+ "Description/Notes")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = TellerApiResourceSwagger.PostTellersTellerIdCashiersRequest.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = TellerApiResourceSwagger.PostTellersTellerIdCashiersResponse.class))) })
public String createCashier(@PathParam("tellerId") @Parameter(description = "tellerId") final Long tellerId,
@Parameter(hidden = true) final String cashierData) {
final CommandWrapper request = new CommandWrapperBuilder().allocateTeller(tellerId).withJson(cashierData).build();
final CommandProcessingResult result = this.commandWritePlatformService.logCommandSource(request);
return this.jsonSerializer.serialize(result);
}
@PUT
@Path("{tellerId}/cashiers/{cashierId}")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Update Cashier", description = "")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = TellerApiResourceSwagger.PutTellersTellerIdCashiersCashierIdRequest.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = TellerApiResourceSwagger.PutTellersTellerIdCashiersCashierIdResponse.class))) })
public String updateCashier(@PathParam("tellerId") @Parameter(description = "tellerId") final Long tellerId,
@PathParam("cashierId") @Parameter(description = "cashierId") final Long cashierId,
@Parameter(hidden = true) final String cashierDate) {
final CommandWrapper request = new CommandWrapperBuilder().updateAllocationTeller(tellerId, cashierId).withJson(cashierDate)
.build();
final CommandProcessingResult result = this.commandWritePlatformService.logCommandSource(request);
return this.jsonSerializer.serialize(result);
}
@DELETE
@Path("{tellerId}/cashiers/{cashierId}")
@Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Delete Cashier", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = TellerApiResourceSwagger.DeleteTellersTellerIdCashiersCashierIdResponse.class))) })
public String deleteCashier(@PathParam("tellerId") @Parameter(description = "tellerId") final Long tellerId,
@PathParam("cashierId") @Parameter(description = "cashierId") final Long cashierId) {
final CommandWrapper request = new CommandWrapperBuilder().deleteAllocationTeller(tellerId, cashierId).build();
final CommandProcessingResult result = this.commandWritePlatformService.logCommandSource(request);
return this.jsonSerializer.serialize(result);
}
@POST
@Path("{tellerId}/cashiers/{cashierId}/allocate")
@Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Allocate Cash To Cashier", description = "Mandatory Fields: \n" + "Date, Amount, Currency, Notes/Comments")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = TellerApiResourceSwagger.PostTellersTellerIdCashiersCashierIdAllocateRequest.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = TellerApiResourceSwagger.PostTellersTellerIdCashiersCashierIdAllocateResponse.class))) })
public String allocateCashToCashier(@PathParam("tellerId") @Parameter(description = "tellerId") final Long tellerId,
@PathParam("cashierId") @Parameter(description = "cashierId") final Long cashierId,
@Parameter(hidden = true) final String cashierTxnData) {
final CommandWrapper request = new CommandWrapperBuilder().allocateCashToCashier(tellerId, cashierId).withJson(cashierTxnData)
.build();
final CommandProcessingResult result = this.commandWritePlatformService.logCommandSource(request);
return this.jsonSerializer.serialize(result);
}
@POST
@Path("{tellerId}/cashiers/{cashierId}/settle")
@Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Settle Cash From Cashier", description = "Mandatory Fields\n" + "Date, Amount, Currency, Notes/Comments")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = TellerApiResourceSwagger.PostTellersTellerIdCashiersCashierIdSettleRequest.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = TellerApiResourceSwagger.PostTellersTellerIdCashiersCashierIdSettleResponse.class))) })
public String settleCashFromCashier(@PathParam("tellerId") @Parameter(description = "tellerId") final Long tellerId,
@PathParam("cashierId") @Parameter(description = "cashierId") final Long cashierId,
@Parameter(hidden = true) final String cashierTxnData) {
final CommandWrapper request = new CommandWrapperBuilder().settleCashFromCashier(tellerId, cashierId).withJson(cashierTxnData)
.build();
final CommandProcessingResult result = this.commandWritePlatformService.logCommandSource(request);
return this.jsonSerializer.serialize(result);
}
@GET
@Path("{tellerId}/cashiers/{cashierId}/transactions")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Retrieve Cashier Transaction", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(array = @ArraySchema(schema = @Schema(implementation = TellerApiResourceSwagger.GetTellersTellerIdCashiersCashiersIdTransactionsResponse.class)))) })
public String getTransactionsForCashier(@PathParam("tellerId") @Parameter(description = "tellerId") final Long tellerId,
@PathParam("cashierId") @Parameter(description = "cashierId") final Long cashierId,
@QueryParam("currencyCode") @Parameter(description = "currencyCode") final String currencyCode,
@QueryParam("offset") @Parameter(description = "offset") final Integer offset,
@QueryParam("limit") @Parameter(description = "limit") final Integer limit,
@QueryParam("orderBy") @Parameter(description = "orderBy") final String orderBy,
@QueryParam("sortOrder") @Parameter(description = "sortOrder") final String sortOrder) {
// TODO: can we remove these 2 calls? we don't use the results, but left it here in case something is done in
// the functions
this.readPlatformService.findTeller(tellerId);
this.readPlatformService.findCashier(cashierId);
final LocalDate fromDate = null;
final LocalDate toDate = null;
final SearchParameters searchParameters = SearchParameters.forPagination(offset, limit, orderBy, sortOrder);
final Page<CashierTransactionData> cashierTxns = this.readPlatformService.retrieveCashierTransactions(cashierId, false, fromDate,
toDate, currencyCode, searchParameters);
return this.jsonSerializer.serialize(cashierTxns);
}
@GET
@Path("{tellerId}/cashiers/{cashierId}/summaryandtransactions")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Transactions Wtih Summary For Cashier", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = TellerApiResourceSwagger.GetTellersTellerIdCashiersCashiersIdSummaryAndTransactionsResponse.class))) })
public String getTransactionsWtihSummaryForCashier(@PathParam("tellerId") @Parameter(description = "tellerId") final Long tellerId,
@PathParam("cashierId") @Parameter(description = "cashierId") final Long cashierId,
@QueryParam("currencyCode") @Parameter(description = "currencyCode") final String currencyCode,
@QueryParam("offset") @Parameter(description = "offset") final Integer offset,
@QueryParam("limit") @Parameter(description = "limit") final Integer limit,
@QueryParam("orderBy") @Parameter(description = "orderBy") final String orderBy,
@QueryParam("sortOrder") @Parameter(description = "sortOrder") final String sortOrder) {
// TODO: can we remove these 2 calls? we don't use the results, but left it here in case something is done in
// the functions
this.readPlatformService.findTeller(tellerId);
this.readPlatformService.findCashier(cashierId);
final LocalDate fromDate = null;
final LocalDate toDate = null;
final SearchParameters searchParameters = SearchParameters.forPagination(offset, limit, orderBy, sortOrder);
final CashierTransactionsWithSummaryData cashierTxnWithSummary = this.readPlatformService
.retrieveCashierTransactionsWithSummary(cashierId, false, fromDate, toDate, currencyCode, searchParameters);
return this.jsonSerializer.serialize(cashierTxnWithSummary);
}
@GET
@Path("{tellerId}/cashiers/{cashierId}/transactions/template")
@Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Retrieve Cashier Transaction Template", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = TellerApiResourceSwagger.GetTellersTellerIdCashiersCashiersIdTransactionsTemplateResponse.class))) })
public String getCashierTxnTemplate(@PathParam("tellerId") @Parameter(description = "tellerId") final Long tellerId,
@PathParam("cashierId") @Parameter(description = "cashierId") final Long cashierId) {
final CashierTransactionData cashierTxnTemplate = this.readPlatformService.retrieveCashierTxnTemplate(cashierId);
return this.jsonSerializer.serialize(cashierTxnTemplate);
}
@GET
@Path("{tellerId}/transactions")
@Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
public String getTransactionData(@PathParam("tellerId") @Parameter(description = "tellerId") final Long tellerId,
@QueryParam("dateRange") @Parameter(description = "dateRange") final String dateRange) {
final DateRange dateRangeHolder = DateRange.fromString(dateRange);
final Collection<TellerTransactionData> transactions = this.readPlatformService.fetchTellerTransactionsByTellerId(tellerId,
dateRangeHolder.getStartDate(), dateRangeHolder.getEndDate());
return this.jsonSerializer.serialize(transactions);
}
@GET
@Path("{tellerId}/transactions/{transactionId}")
@Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
public String findTransactionData(@PathParam("tellerId") @Parameter(description = "tellerId") final Long tellerid,
@PathParam("transactionId") @Parameter(description = "transactionId") final Long transactionId) {
final TellerTransactionData transaction = this.readPlatformService.findTellerTransaction(transactionId);
return this.jsonSerializer.serialize(transaction);
}
@GET
@Path("{tellerId}/journals")
@Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
public String getJournalData(@PathParam("tellerId") @Parameter(description = "tellerId") final Long tellerId,
@QueryParam("cashierId") @Parameter(description = "cashierId") final Long cashierDate,
@QueryParam("dateRange") @Parameter(description = "dateRange") final String dateRange) {
final DateRange dateRangeHolder = DateRange.fromString(dateRange);
final Collection<TellerJournalData> journals = this.readPlatformService.fetchTellerJournals(tellerId, cashierDate,
dateRangeHolder.getStartDate(), dateRangeHolder.getEndDate());
return this.jsonSerializer.serialize(journals);
}
private static final class CashiersForTeller {
public Long tellerId;
public String tellerName;
public Long officeId;
public String officeName;
public Collection<CashierData> cashiers;
}
}
@@ -1,491 +0,0 @@
/**
* 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.organisation.teller.api;
import io.swagger.v3.oas.annotations.media.Schema;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Collection;
import org.apache.fineract.infrastructure.core.service.Page;
import org.apache.fineract.organisation.monetary.data.CurrencyData;
import org.apache.fineract.organisation.staff.data.StaffData;
import org.apache.fineract.organisation.teller.data.CashierData;
import org.apache.fineract.organisation.teller.data.CashierTransactionData;
import org.apache.fineract.organisation.teller.domain.CashierTxnType;
import org.apache.fineract.organisation.teller.domain.TellerStatus;
/**
* Created by sanyam on 20/8/17.
*/
final class TellerApiResourceSwagger {
private TellerApiResourceSwagger() {
}
@Schema(description = "GetTellersResponse")
public static final class GetTellersResponse {
private GetTellersResponse() {
}
@Schema(example = "3")
public Long id;
@Schema(example = "1")
public Long officeId;
@Schema(example = "0")
public Long debitAccountId;
@Schema(example = "0")
public Long creditAccountId;
@Schema(example = "Teller3")
public String name;
@Schema(example = "[2015,2,1]")
public LocalDate startDate;
@Schema(example = "ACTIVE")
public TellerStatus status;
@Schema(example = "Head Office")
public String officeName;
}
@Schema(description = "PostTellersRequest")
public static final class PostTellersRequest {
private PostTellersRequest() {
}
@Schema(example = "1")
public Long officeId;
@Schema(example = "Teller3")
public String name;
@Schema(example = "cash handling")
public String description;
@Schema(example = "ACTIVE")
public TellerStatus status;
@Schema(example = "en")
public String locale;
@Schema(example = "dd-MM-yyyy")
public String dateFormat;
@Schema(example = "01 February 2015")
public LocalDate startDate;
}
@Schema(description = "PostTellersResponse")
public static final class PostTellersResponse {
private PostTellersResponse() {
}
@Schema(example = "1")
public Long officeId;
@Schema(example = "5")
public Long resourceId;
}
@Schema(description = "PutTellersRequest")
public static final class PutTellersRequest {
private PutTellersRequest() {
}
@Schema(example = "Teller3")
public String name;
@Schema(example = "1")
public Long officeId;
@Schema(example = "teller cash handling")
public String description;
@Schema(example = "ACTIVE")
public TellerStatus status;
@Schema(example = "28 February 2015")
public LocalDate endDate;
@Schema(example = "01 February 2015")
public LocalDate startDate;
@Schema(example = "en")
public String locale;
@Schema(example = "dd-MM-yyyy")
public String dateFormat;
}
@Schema(description = "PutTellersResponse")
public static final class PutTellersResponse {
private PutTellersResponse() {
}
static final class PutTellersResponseChanges {
private PutTellersResponseChanges() {}
@Schema(example = "teller cash handling")
public String description;
@Schema(example = "28 February 2015")
public LocalDate endDate;
@Schema(example = "01 February 2015")
public LocalDate startDate;
@Schema(example = "en")
public String locale;
@Schema(example = "dd-MM-yyyy")
public String dateFormat;
}
@Schema(example = "1")
public Long officeId;
@Schema(example = "5")
public Long resourceId;
public PutTellersResponseChanges changes;
}
@Schema(description = "GetTellersTellerIdCashiersResponse")
public static final class GetTellersTellerIdCashiersResponse {
private GetTellersTellerIdCashiersResponse() {
}
@Schema(example = "1")
public Long tellerId;
@Schema(example = "Teller1")
public String tellerName;
@Schema(example = "1")
public Long officeId;
@Schema(example = "Head Office")
public String officeName;
public Collection<CashierData> cashiers;
}
@Schema(description = "PostTellersTellerIdCashiersRequest")
public static final class PostTellersTellerIdCashiersRequest {
private PostTellersTellerIdCashiersRequest() {
}
@Schema(example = "28 February 2015")
public LocalDate endDate;
@Schema(example = "teller cash handling")
public String description;
@Schema(example = "true")
public Boolean isFullDay;
@Schema(example = "3")
public Long staffId;
@Schema(example = "en")
public String locale;
@Schema(example = "dd-MM-yyyy")
public String dateFormat;
@Schema(example = "01 February 2015")
public LocalDate startDate;
}
@Schema(description = "PostTellersTellerIdCashiersResponse")
public static final class PostTellersTellerIdCashiersResponse {
private PostTellersTellerIdCashiersResponse() {
}
@Schema(example = "1")
public Long resourceId;
@Schema(example = "2")
public Long subResourceId;
}
@Schema(description = "GetTellersTellerIdCashiersCashierIdResponse")
public static final class GetTellersTellerIdCashiersCashierIdResponse {
private GetTellersTellerIdCashiersCashierIdResponse() {
}
@Schema(example = "1")
public Long id;
@Schema(example = "1")
public Long tellerId;
@Schema(example = "1")
public Long staffId;
@Schema(example = "")
public String description;
@Schema(example = "Feb 20, 2015 12:00:00 AM")
public LocalDate startDate;
@Schema(example = "Feb 27, 2015 12:00:00 AM")
public LocalDate endDate;
@Schema(example = "true")
public Boolean isFullDay;
@Schema(example = "")
public String startTime;
@Schema(example = "")
public String endTime;
@Schema(example = "Teller1")
public String tellerName;
@Schema(example = "Staff1, Test")
public String staffName;
}
@Schema(description = "PutTellersTellerIdCashiersCashierIdRequest")
public static final class PutTellersTellerIdCashiersCashierIdRequest {
private PutTellersTellerIdCashiersCashierIdRequest() {
}
@Schema(example = "25 February 2015")
public LocalDate endDate;
@Schema(example = "Cashier updated.")
public String description;
@Schema(example = "true")
public Boolean isFullDay;
@Schema(example = "1")
public Long staffId;
@Schema(example = "en")
public String locale;
@Schema(example = "dd-MM-yyyy")
public String dateFormat;
@Schema(example = "01 February 2015")
public LocalDate startDate;
}
@Schema(description = "PutTellersTellerIdCashiersCashierIdResponse")
public static final class PutTellersTellerIdCashiersCashierIdResponse {
private PutTellersTellerIdCashiersCashierIdResponse() {
}
static final class PutTellersTellerIdCashiersCashierIdResponseChanges {
private PutTellersTellerIdCashiersCashierIdResponseChanges() {}
@Schema(example = "25 February 2015")
public LocalDate endDate;
@Schema(example = "Cashier updated.")
public String description;
@Schema(example = "en")
public String locale;
@Schema(example = "dd-MM-yyyy")
public String dateFormat;
}
@Schema(example = "1")
public Long resourceId;
@Schema(example = "2")
public Long subResourceId;
public PutTellersTellerIdCashiersCashierIdResponseChanges changes;
}
@Schema(description = "DeleteTellersTellerIdCashiersCashierIdResponse")
public static final class DeleteTellersTellerIdCashiersCashierIdResponse {
private DeleteTellersTellerIdCashiersCashierIdResponse() {
}
@Schema(example = "1")
public Long resourceId;
}
@Schema(description = "GetTellersTellerIdCashiersTemplateResponse")
public static final class GetTellersTellerIdCashiersTemplateResponse {
private GetTellersTellerIdCashiersTemplateResponse() {
}
@Schema(example = "1")
public Long tellerId;
@Schema(example = "Teller1")
public String tellerName;
@Schema(example = "1")
public Long officeId;
@Schema(example = "Head Office")
public String officeName;
public Collection<StaffData> staffOptions;
}
@Schema(description = "GetTellersTellerIdCashiersCashiersIdTransactionsResponse")
public static final class GetTellersTellerIdCashiersCashiersIdTransactionsResponse {
private GetTellersTellerIdCashiersCashiersIdTransactionsResponse() {
}
@Schema(example = "8")
public Long id;
@Schema(example = "15")
public Long cashierId;
public CashierTxnType txnType;
@Schema(example = "1000")
public BigDecimal txnAmount;
@Schema(example = "[2015, 02, 25]")
public LocalDate txnDate;
@Schema(example = "2")
public Long entityId;
@Schema(example = "loans")
public String entityType;
@Schema(example = "Disbursement, Loan:2-000000002,Client:1-Test 1")
public String txnNote;
@Schema(example = "[2015, 02, 25, 12, 00, 00]")
public LocalDateTime createdDate;
@Schema(example = "1")
public Long officeId;
@Schema(example = "Head Office")
public String officeName;
@Schema(example = "0")
public Long tellerId;
@Schema(example = "B, Ramesh")
public String cashierName;
}
@Schema(description = "PostTellersTellerIdCashiersCashierIdAllocateRequest")
public static final class PostTellersTellerIdCashiersCashierIdAllocateRequest {
private PostTellersTellerIdCashiersCashierIdAllocateRequest() {
}
@Schema(example = "USD")
public String currencyCode;
@Schema(example = "5000")
public BigDecimal txnAmount;
@Schema(example = "allocating cash")
public String txnNote;
@Schema(example = "en")
public String locale;
@Schema(example = "dd-MM-yyyy")
public String dateFormat;
@Schema(example = "[2015, 02, 01]")
public LocalDate txnDate;
}
@Schema(description = "PostTellersTellerIdCashiersCashierIdAllocateResponse")
public static final class PostTellersTellerIdCashiersCashierIdAllocateResponse {
private PostTellersTellerIdCashiersCashierIdAllocateResponse() {
}
@Schema(example = "1")
public Long resourceId;
@Schema(example = "4")
public Long subResourceId;
}
@Schema(description = "PostTellersTellerIdCashiersCashierIdSettleRequest")
public static final class PostTellersTellerIdCashiersCashierIdSettleRequest {
private PostTellersTellerIdCashiersCashierIdSettleRequest() {
}
@Schema(example = "USD")
public String currencyCode;
@Schema(example = "2000")
public BigDecimal txnAmount;
@Schema(example = "cash settlement")
public String txnNote;
@Schema(example = "en")
public String locale;
@Schema(example = "dd-MM-yyyy")
public String dateFormat;
@Schema(example = "[2015, 02, 20]")
public LocalDate txnDate;
}
@Schema(description = "PostTellersTellerIdCashiersCashierIdSettleResponse")
public static final class PostTellersTellerIdCashiersCashierIdSettleResponse {
private PostTellersTellerIdCashiersCashierIdSettleResponse() {
}
@Schema(example = "1")
public Long resourceId;
@Schema(example = "5")
public Long subResourceId;
}
@Schema(description = "GetTellersTellerIdCashiersCashiersIdSummaryAndTransactionsResponse")
public static final class GetTellersTellerIdCashiersCashiersIdSummaryAndTransactionsResponse {
private GetTellersTellerIdCashiersCashiersIdSummaryAndTransactionsResponse() {
}
@Schema(example = "7000.000000")
public BigDecimal sumCashAllocation;
@Schema(example = "0")
public BigDecimal sumInwardCash;
@Schema(example = "0")
public BigDecimal sumOutwardCash;
@Schema(example = "50.000000")
public BigDecimal sumCashSettlement;
@Schema(example = "6950.000000")
public BigDecimal netCash;
@Schema(example = "Head Office")
public String officeName;
@Schema(example = "1")
public long tellerId;
@Schema(example = "Teller1")
public String tellerName;
@Schema(example = "1")
public long cashierId;
@Schema(example = "Staff1, Test")
public String cashierName;
public Page<CashierTransactionData> cashierTransactions;
}
@Schema(description = "GetTellersTellerIdCashiersCashiersIdTransactionsTemplateResponse")
public static final class GetTellersTellerIdCashiersCashiersIdTransactionsTemplateResponse {
private GetTellersTellerIdCashiersCashiersIdTransactionsTemplateResponse() {
}
@Schema(example = "1")
public Long cashierId;
@Schema(example = "Head Office")
public String officeName;
@Schema(example = "0")
public Long tellerId;
@Schema(example = "Teller1")
public String tellerName;
@Schema(example = "Staff1, Test")
public String cashierName;
public CashierData cashierData;
@Schema(example = "Feb 20, 2015 12:00:00 AM")
public LocalDate startDate;
@Schema(example = "Feb 27, 2015 12:00:00 AM")
public LocalDate endDate;
public Collection<CurrencyData> currencyOptions;
}
}
@@ -1,60 +0,0 @@
/**
* 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.organisation.teller.api;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;
import java.util.Collection;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.apache.fineract.organisation.teller.data.TellerData;
import org.apache.fineract.organisation.teller.data.TellerJournalData;
import org.apache.fineract.organisation.teller.service.TellerManagementReadPlatformService;
import org.apache.fineract.organisation.teller.util.DateRange;
import org.springframework.stereotype.Component;
@Path("/v1/cashiersjournal")
@Component
@Tag(name = "Cashier Journals", description = "")
@RequiredArgsConstructor
public class TellerJournalApiResource {
private final PlatformSecurityContext securityContext;
private final DefaultToApiJsonSerializer<TellerData> jsonSerializer;
private final TellerManagementReadPlatformService readPlatformService;
@GET
@Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
public String getJournalData(@QueryParam("officeId") final Long officeId, @QueryParam("tellerId") final Long tellerId,
@QueryParam("cashierId") final Long cashierId, @QueryParam("dateRange") final String dateRange) {
final DateRange dateRangeHolder = DateRange.fromString(dateRange);
final Collection<TellerJournalData> journals = this.readPlatformService.getJournals(officeId, tellerId, cashierId,
dateRangeHolder.getStartDate(), dateRangeHolder.getEndDate());
return this.jsonSerializer.serialize(journals);
}
}
@@ -1,115 +0,0 @@
/**
* 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.organisation.teller.data;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.Collection;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.apache.fineract.organisation.staff.data.StaffData;
/**
* Represents a cashier, providing access to the cashier's office, staff information, teller, and more.
*
* @author Markus Geiss
*
* @since 2.0.0
* @see org.apache.fineract.organisation.teller.domain.Cashier
* @since 2.0.0
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public final class CashierData implements Serializable {
private Long id;
private Long tellerId;
private Long officeId;
private Long staffId;
private String description;
private LocalDate startDate;
private LocalDate endDate;
private Boolean isFullDay;
private String startTime;
private String endTime;
// Template fields
private String officeName;
private String tellerName;
private String staffName;
private Collection<StaffData> staffOptions;
/**
* Creates a new cashier.
*
* <p>
* The valid from/to dates may be used to define a time period in which the cashier is assignable to a teller.
* </p>
*
* <p>
* The start/end times may be used to define a time period in which the cashier works part time.
* </p>
*
* @param id
* the primary key of this cashier
* @param officeId
* the primary key of the related office
* @param officeName
* the primary key of the related staff
* @param staffId
* the primary key of the related teller
* @param staffName
* @param tellerId
* the primary key of the related teller
* @param tellerName
* @param description
* the description of this cashier
* @param startDate
* the valid from date of this cashier
* @param endDate
* the valid to date of this cashier
* @param isFullDay
* the part time flag of this cashier
* @param startTime
* the start time of this cashier
* @param endTime
* the end time of this cashier
* @return
*/
public static CashierData instance(final Long id, final Long officeId, String officeName, final Long staffId, final String staffName,
final Long tellerId, final String tellerName, final String description, final LocalDate startDate, final LocalDate endDate,
final Boolean isFullDay, final String startTime, final String endTime) {
return new CashierData().setId(id).setOfficeId(officeId).setOfficeName(officeName).setStaffId(staffId).setStaffName(staffName)
.setTellerId(tellerId).setTellerName(tellerName).setDescription(description).setStartDate(startDate).setEndDate(endDate)
.setIsFullDay(isFullDay).setStartTime(startTime).setEndTime(endTime);
}
/*
* Creates a new cashier.
*/
public static CashierData template(final Long officeId, final String officeName, final Long tellerId, final String tellerName,
final Collection<StaffData> staffOptions) {
return new CashierData().setOfficeId(officeId).setOfficeName(officeName).setTellerId(tellerId).setTellerName(tellerName)
.setStaffOptions(staffOptions);
}
}
@@ -1,77 +0,0 @@
/**
* 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.organisation.teller.data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Collection;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.apache.fineract.organisation.monetary.data.CurrencyData;
import org.apache.fineract.organisation.teller.domain.CashierTxnType;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public final class CashierTransactionData implements Serializable {
private Long id;
private Long cashierId;
private CashierTxnType txnType;
private BigDecimal txnAmount;
private LocalDate txnDate;
private Long entityId;
private String entityType;
private String txnNote;
private OffsetDateTime createdDate;
// Template fields
private Long officeId;
private String officeName;
private Long tellerId;
private String tellerName;
private String cashierName;
private CashierData cashierData;
private LocalDate startDate;
private LocalDate endDate;
private Collection<CurrencyData> currencyOptions;
public static CashierTransactionData instance(final Long id, final Long cashierId, CashierTxnType txnType, final BigDecimal txnAmount,
final LocalDate txnDate, final String txnNote, final String entityType, final Long entityId, final OffsetDateTime createdDate,
final Long officeId, final String officeName, final Long tellerId, final String tellerName, final String cashierName,
final CashierData cashierData, LocalDate startDate, LocalDate endDate) {
return new CashierTransactionData().setId(id).setCashierId(cashierId).setTxnType(txnType).setTxnAmount(txnAmount)
.setTxnDate(txnDate).setTxnNote(txnNote).setEntityType(entityType).setEntityId(entityId).setCreatedDate(createdDate)
.setOfficeId(officeId).setOfficeName(officeName).setTellerId(tellerId).setTellerName(tellerName).setCashierName(cashierName)
.setCashierData(cashierData).setStartDate(startDate).setEndDate(endDate);
}
public static CashierTransactionData template(final Long cashierId, final Long tellerId, final String tellerName, final Long officeId,
final String officeName, final String cashierName, final CashierData cashierData, LocalDate startDate, LocalDate endDate,
final Collection<CurrencyData> currencyOptions) {
return new CashierTransactionData().setCashierId(cashierId).setOfficeId(officeId).setOfficeName(officeName).setTellerId(tellerId)
.setTellerName(tellerName).setCashierName(cashierName).setCashierData(cashierData).setStartDate(startDate)
.setEndDate(endDate).setCurrencyOptions(currencyOptions);
}
}
@@ -1,139 +0,0 @@
/**
* 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.organisation.teller.data;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.HashMap;
import java.util.Map;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.infrastructure.core.service.MathUtil;
import org.apache.fineract.infrastructure.core.service.SearchParameters;
import org.apache.fineract.organisation.teller.domain.Cashier;
import org.apache.fineract.organisation.teller.domain.Teller;
import org.apache.fineract.organisation.teller.exception.CashierAlreadyAllocated;
import org.apache.fineract.organisation.teller.exception.CashierDateRangeOutOfTellerDateRangeException;
import org.apache.fineract.organisation.teller.exception.CashierInsufficientAmountException;
import org.apache.fineract.organisation.teller.service.TellerManagementReadPlatformService;
import org.apache.fineract.useradministration.domain.AppUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Component;
@Component
public class CashierTransactionDataValidator {
private final TellerManagementReadPlatformService tellerManagementReadPlatformService;
private final NamedParameterJdbcTemplate jdbcTemplate;
private static final Logger LOG = LoggerFactory.getLogger(CashierTransactionDataValidator.class);
@Autowired
public CashierTransactionDataValidator(final TellerManagementReadPlatformService tellerManagementReadPlatformService,
final NamedParameterJdbcTemplate jdbcTemplate) {
this.tellerManagementReadPlatformService = tellerManagementReadPlatformService;
this.jdbcTemplate = jdbcTemplate;
}
public void validateSettleCashAndCashOutTransactions(final Long cashierId, String currencyCode, final BigDecimal transactionAmount) {
final Integer offset = null;
final Integer limit = null;
final String orderBy = null;
final String sortOrder = null;
final LocalDate fromDate = null;
final LocalDate toDate = null;
final SearchParameters searchParameters = SearchParameters.forPagination(offset, limit, orderBy, sortOrder);
final CashierTransactionsWithSummaryData cashierTxnWithSummary = this.tellerManagementReadPlatformService
.retrieveCashierTransactionsWithSummary(cashierId, false, fromDate, toDate, currencyCode, searchParameters);
if (MathUtil.isGreaterThan(transactionAmount, cashierTxnWithSummary.getNetCash())) {
throw new CashierInsufficientAmountException();
}
}
public void validateSettleCashAndCashOutTransactions(final Long cashierId, JsonCommand command) {
String currencyCode = command.stringValueOfParameterNamed("currencyCode");
BigDecimal transactionAmount = command.bigDecimalValueOfParameterNamed("txnAmount");
validateSettleCashAndCashOutTransactions(cashierId, currencyCode, transactionAmount);
}
public void validateCashierAllowedDateAndTime(final Cashier cashier, final Teller teller) {
Long staffId = cashier.getStaff().getId();
final LocalDate fromDate = cashier.getStartDate();
final LocalDate endDate = cashier.getEndDate();
final LocalDate tellerFromDate = teller.getStartDate();
final LocalDate tellerEndDate = teller.getEndDate();
// Validate cashier date range in range of teller date range
if (DateUtils.isBefore(fromDate, tellerFromDate) || DateUtils.isBefore(endDate, tellerFromDate)
|| (tellerEndDate != null && (DateUtils.isAfter(fromDate, tellerEndDate) || DateUtils.isAfter(endDate, tellerEndDate)))) {
throw new CashierDateRangeOutOfTellerDateRangeException();
}
// Validate cashier has not been assigned for the same duration
String sql = "SELECT COUNT(*) FROM m_cashiers c WHERE c.staff_id = :staffId AND "
+ "((:fromDate BETWEEN c.start_date AND c.end_date OR :endDate BETWEEN c.start_date AND c.end_date) "
+ "OR (c.start_date BETWEEN :fromDate AND :endDate OR c.end_date BETWEEN :fromDate AND :endDate))";
if (!cashier.getIsFullDay()) {
sql += " AND (TIME(c.start_time) BETWEEN TIME(:startTime) AND TIME(:endTime) "
+ "OR TIME(c.end_time) BETWEEN TIME(:startTime) AND TIME(:endTime))";
}
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("staffId", staffId);
paramMap.put("fromDate", fromDate);
paramMap.put("endDate", endDate);
if (!cashier.getIsFullDay()) {
paramMap.put("startTime", cashier.getStartTime());
paramMap.put("endTime", cashier.getEndTime());
}
Integer count = jdbcTemplate.queryForObject(sql, paramMap, Integer.class);
if (count != null && count > 0) {
throw new CashierAlreadyAllocated();
}
}
public void validateOnLoanDisbursal(AppUser user, String currencyCode, BigDecimal transactionAmount) {
LocalDate tenantDate = DateUtils.getLocalDateOfTenant();
OffsetDateTime tenantDateTime = DateUtils.getOffsetDateTimeOfTenant();
if (user.getStaff() != null) {
String sql = "SELECT c.id FROM m_cashiers c WHERE c.staff_id = :staffId "
+ "AND (CASE WHEN c.full_day THEN :tenantDate BETWEEN c.start_date AND c.end_date "
+ "ELSE (:tenantDate BETWEEN c.start_date AND c.end_date AND "
+ "TIME(:tenantDateTime) BETWEEN TIME(c.start_time) AND TIME(c.end_time)) END)";
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("staffId", user.getStaff().getId());
paramMap.put("tenantDate", tenantDate);
paramMap.put("tenantDateTime", tenantDateTime);
try {
Long cashierId = jdbcTemplate.queryForObject(sql, paramMap, Long.class);
validateSettleCashAndCashOutTransactions(cashierId, currencyCode, transactionAmount);
} catch (EmptyResultDataAccessException e) {
LOG.error("Problem occurred in validateOnLoanDisbursal function", e);
}
}
}
}
@@ -1,40 +0,0 @@
/**
* 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.organisation.teller.data;
import java.io.Serializable;
import java.math.BigDecimal;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public final class CashierTransactionTypeTotalsData implements Serializable {
private Integer cashierTxnType;
private BigDecimal cashTotal;
public static CashierTransactionTypeTotalsData instance(final Integer cashierTxnType, final BigDecimal cashTotal) {
return new CashierTransactionTypeTotalsData().setCashierTxnType(cashierTxnType).setCashTotal(cashTotal);
}
}
@@ -1,110 +0,0 @@
/**
* 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.organisation.teller.data;
import java.io.Serializable;
import java.math.BigDecimal;
import org.apache.fineract.infrastructure.core.service.Page;
public final class CashierTransactionsWithSummaryData implements Serializable {
private final BigDecimal sumCashAllocation;
private final BigDecimal sumInwardCash;
private final BigDecimal sumOutwardCash;
private final BigDecimal sumCashSettlement;
private final BigDecimal netCash;
private final String officeName;
private final long tellerId;
private final String tellerName;
private final long cashierId;
private final String cashierName;
private final Page<CashierTransactionData> cashierTransactions;
private CashierTransactionsWithSummaryData(final Page<CashierTransactionData> cashierTransactions, final BigDecimal sumCashAllocation,
final BigDecimal sumInwardCash, final BigDecimal sumOutwardCash, final BigDecimal sumCashSettlement, final BigDecimal netCash,
final String officeName, final Long tellerId, final String tellerName, final Long cashierId, final String cashierName) {
this.cashierTransactions = cashierTransactions;
this.sumCashAllocation = sumCashAllocation;
this.sumInwardCash = sumInwardCash;
this.sumOutwardCash = sumOutwardCash;
this.sumCashSettlement = sumCashSettlement;
this.netCash = netCash;
this.officeName = officeName;
this.tellerId = tellerId;
this.tellerName = tellerName;
this.cashierId = cashierId;
this.cashierName = cashierName;
}
public static CashierTransactionsWithSummaryData instance(final Page<CashierTransactionData> cashierTransactions,
final BigDecimal sumCashAllocation, final BigDecimal sumInwardCash, final BigDecimal sumOutwardCash,
final BigDecimal sumCashSettlement, final String officeName, final Long tellerId, final String tellerName, final Long cashierId,
final String cashierName) {
final BigDecimal netCash = sumCashAllocation.add(sumInwardCash).subtract(sumOutwardCash).subtract(sumCashSettlement);
return new CashierTransactionsWithSummaryData(cashierTransactions, sumCashAllocation, sumInwardCash, sumOutwardCash,
sumCashSettlement, netCash, officeName, tellerId, tellerName, cashierId, cashierName);
}
public BigDecimal getSumCashAllocation() {
return sumCashAllocation;
}
public BigDecimal getSumInwardCash() {
return sumInwardCash;
}
public BigDecimal getSumOutwardCash() {
return sumOutwardCash;
}
public BigDecimal getSumCashSettlement() {
return sumCashSettlement;
}
public BigDecimal getNetCash() {
return netCash;
}
public String getOfficeName() {
return officeName;
}
public Long getTellerId() {
return tellerId;
}
public String getTellerName() {
return tellerName;
}
public Long getCashierId() {
return cashierId;
}
public String getCashierName() {
return cashierName;
}
public Page<CashierTransactionData> getCashierTransactions() {
return cashierTransactions;
}
}
@@ -1,101 +0,0 @@
/**
* 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.organisation.teller.data;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.Collection;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.apache.fineract.organisation.office.data.OfficeData;
import org.apache.fineract.organisation.staff.data.StaffData;
import org.apache.fineract.organisation.teller.domain.TellerStatus;
/**
* {@code TellerData} represents an immutable data object for teller data.
*
* @version 1.0
*
* @since 2.0.0
* @see java.io.Serializable
* @since 2.0.0
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public final class TellerData implements Serializable {
private Long id;
private Long officeId;
private Long debitAccountId;
private Long creditAccountId;
private String name;
private String description;
private LocalDate startDate;
private LocalDate endDate;
private TellerStatus status;
private Boolean hasTransactions;
private Boolean hasMappedCashiers;
private String officeName;
private Collection<OfficeData> officeOptions;
private Collection<StaffData> staffOptions;
/**
* Creates a new teller data object.
*
* @param id
* - id of the teller
* @param officeId
* - id of the related office
* @param debitAccountId
* - id of the debit account to use
* @param creditAccountId
* - id of the credit account to use
* @param name
* - name of the teller
* @param description
* - description of the teller
* @param startDate
* - date when the teller becomes available
* @param endDate
* - date when the teller becomes unavailable
* @param status
* - current state of the teller, eg. active, inactive, pending
* @param hasTransactions
* - indicates that this teller already is used to perform postings
* @param hasMappedCashiers
* - indicates that the teller already has @code Cashier}s assigned to it
* @return the new created {@code TellerData}
*/
public static TellerData instance(final Long id, final Long officeId, final Long debitAccountId, final Long creditAccountId,
final String name, final String description, final LocalDate startDate, final LocalDate endDate, final TellerStatus status,
final String officeName, final Boolean hasTransactions, final Boolean hasMappedCashiers) {
return new TellerData().setId(id).setOfficeId(officeId).setDebitAccountId(debitAccountId).setCreditAccountId(creditAccountId)
.setName(name).setDescription(description).setStartDate(startDate).setEndDate(endDate).setStatus(status)
.setOfficeName(officeName).setHasTransactions(hasTransactions).setHasMappedCashiers(hasMappedCashiers);
}
public static TellerData lookup(final Long id, final String name) {
return new TellerData().setId(id).setName(name);
}
}
@@ -1,79 +0,0 @@
/**
* 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.organisation.teller.data;
import java.io.Serializable;
import java.time.LocalDate;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
/**
* {@code TellerJournalData} represents an immutable journal data object.
*
* @version 1.0.0
*
* @since 2.0.0
* @see java.io.Serializable
* @since 2.0.0
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public final class TellerJournalData implements Serializable {
private Long officeId;
private Long tellerId;
private LocalDate day;
private Double openingBalance;
private Double settledBalance;
private Double closingBalance;
private Double sumReceipts;
private Double sumPayments;
/**
* Create a new teller journal data object.
*
* @param officeId
* - id of related office
* @param tellerId
* - id of related teller
* @param day
* - day of this journals data
* @param openingBalance
* - balance at the time of opening the teller
* @param settledBalance
* - balance at the time od settling the teller
* @param closingBalance
* - balance at the time of closing the teller
* @param sumReceipts
* - sum of all posted receipts
* @param sumPayments
* - sum of all posted payments
* @return the new created {@code TellerJournalData}
*/
public static TellerJournalData instance(final Long officeId, final Long tellerId, final LocalDate day, final Double openingBalance,
final Double settledBalance, final Double closingBalance, final Double sumReceipts, final Double sumPayments) {
return new TellerJournalData().setOfficeId(officeId).setTellerId(tellerId).setDay(day).setOpeningBalance(openingBalance)
.setSettledBalance(settledBalance).setClosingBalance(closingBalance).setSumReceipts(sumReceipts)
.setSumPayments(sumPayments);
}
}
@@ -1,79 +0,0 @@
/**
* 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.organisation.teller.data;
import java.io.Serializable;
import java.time.LocalDate;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
/**
* {@code TellerTransactionData} represents an immutable data object for a transction.
*
* @version 1.0.0
*
* @since 2.0.0
* @see java.io.Serializable
* @since 2.0.0
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public final class TellerTransactionData implements Serializable {
private Long id;
private Long officeId;
private Long tellerId;
private Long cashierId;
private Long clientId;
private EnumOptionData type;
private Double amount;
private LocalDate postingDate;
/**
* Creates a new teller transaction data object.
*
* @param id
* - id of the transaction
* @param officeId
* - id of the related office
* @param tellerId
* - id of the related teller
* @param cashierId
* - id of the cashier
* @param clientId
* - id of the client
* @param type
* - type of transaction (eg receipt, payment, open, close, settle)
* @param amount
* - amount of the transaction
* @param postingDate
* - posting date of the transaction
* @return the new created {@code TellerTransactionData}
*/
public static TellerTransactionData instance(final Long id, final Long officeId, final Long tellerId, final Long cashierId,
final Long clientId, final EnumOptionData type, final Double amount, final LocalDate postingDate) {
return new TellerTransactionData().setId(id).setOfficeId(officeId).setTellerId(tellerId).setCashierId(cashierId)
.setClientId(clientId).setType(type).setAmount(amount).setPostingDate(postingDate);
}
}
@@ -1,234 +0,0 @@
/**
* 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.organisation.teller.domain;
import com.google.common.base.Splitter;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.persistence.Transient;
import jakarta.persistence.UniqueConstraint;
import java.time.LocalDate;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import org.apache.fineract.organisation.office.domain.Office;
import org.apache.fineract.organisation.staff.domain.Staff;
/**
* Provides the base model for a cashier. Represents a row in the &quot;m_cashiers&quot; database table, with each
* column mapped to a property of this class.
*
* @author Markus Geiss
* @since 2.0.0
*/
@Entity
@Table(name = "m_cashiers", uniqueConstraints = {
@UniqueConstraint(name = "ux_cashiers_staff_teller", columnNames = { "staff_id", "teller_id" }) })
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class Cashier extends AbstractPersistableCustom {
// ManyToOne(fetch = FetchType.LAZY)
// JoinColumn(name = "office_id", nullable = false)
@Transient
private Office office;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "staff_id", nullable = false)
private Staff staff;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "teller_id", nullable = false)
private Teller teller;
@Column(name = "description", nullable = true, length = 500)
private String description;
@Column(name = "start_date", nullable = false)
private LocalDate startDate;
@Column(name = "end_date", nullable = false)
private LocalDate endDate;
@Column(name = "full_day", nullable = true)
private Boolean isFullDay;
@Column(name = "start_time", nullable = true, length = 10)
private String startTime;
@Column(name = "end_time", nullable = true, length = 10)
private String endTime;
public static Cashier fromJson(final Office cashierOffice, final Teller teller, final Staff staff, final String startTime,
final String endTime, final JsonCommand command) {
// final Long tellerId = teller.getId();
// final Long staffId = command.longValueOfParameterNamed("staffId");
final String description = command.stringValueOfParameterNamed("description");
final LocalDate startDate = command.localDateValueOfParameterNamed("startDate");
final LocalDate endDate = command.localDateValueOfParameterNamed("endDate");
final Boolean isFullDay = command.booleanObjectValueOfParameterNamed("isFullDay");
/*
* final String startTime = command.stringValueOfParameterNamed("startTime"); final String endTime =
* command.stringValueOfParameterNamed("endTime");
*/
return new Cashier().setOffice(cashierOffice).setTeller(teller).setStaff(staff).setDescription(description).setStartDate(startDate)
.setEndDate(endDate).setIsFullDay(isFullDay).setStartTime(startTime).setEndTime(endTime);
}
public Map<String, Object> update(final JsonCommand command) {
final Map<String, Object> actualChanges = new LinkedHashMap<>(7);
final String dateFormatAsInput = command.dateFormat();
final String localeAsInput = command.locale();
final String descriptionParamName = "description";
if (command.isChangeInStringParameterNamed(descriptionParamName, this.description)) {
final String newValue = command.stringValueOfParameterNamed(descriptionParamName);
actualChanges.put(descriptionParamName, newValue);
this.description = newValue;
}
final String startDateParamName = "startDate";
if (command.isChangeInLocalDateParameterNamed(startDateParamName, getStartDate())) {
final String valueAsInput = command.stringValueOfParameterNamed(startDateParamName);
actualChanges.put(startDateParamName, valueAsInput);
actualChanges.put("dateFormat", dateFormatAsInput);
actualChanges.put("locale", localeAsInput);
this.startDate = command.localDateValueOfParameterNamed(startDateParamName);
}
final String endDateParamName = "endDate";
if (command.isChangeInLocalDateParameterNamed(endDateParamName, getEndDate())) {
final String valueAsInput = command.stringValueOfParameterNamed(endDateParamName);
actualChanges.put(endDateParamName, valueAsInput);
actualChanges.put("dateFormat", dateFormatAsInput);
actualChanges.put("locale", localeAsInput);
this.endDate = command.localDateValueOfParameterNamed(endDateParamName);
}
final Boolean isFullDay = command.booleanObjectValueOfParameterNamed("isFullDay");
final String isFullDayParamName = "isFullDay";
if (command.isChangeInBooleanParameterNamed(isFullDayParamName, this.isFullDay)) {
final Boolean newValue = command.booleanObjectValueOfParameterNamed(isFullDayParamName);
actualChanges.put(isFullDayParamName, newValue);
/*
* this.startTime="00"; this.endTime="00";
*/
this.isFullDay = newValue;
}
if (!isFullDay) {
String newStartHour = "";
String newStartMin = "";
String newEndHour = "";
String newEndMin = "";
final String hourStartTimeParamName = "hourStartTime";
final String minStartTimeParamName = "minStartTime";
final String hourEndTimeParamName = "hourEndTime";
final String minEndTimeParamName = "minEndTime";
if (command.isChangeInLongParameterNamed(hourStartTimeParamName, this.getHourFromStartTime())
|| command.isChangeInLongParameterNamed(minStartTimeParamName, this.getMinFromStartTime())) {
newStartHour = command.stringValueOfParameterNamed(hourStartTimeParamName);
if (newEndHour.equalsIgnoreCase("0")) {
newEndHour = newEndHour + "0";
}
actualChanges.put(hourStartTimeParamName, newStartHour);
newStartMin = command.stringValueOfParameterNamed(minStartTimeParamName);
if (newStartMin.equalsIgnoreCase("0")) {
newStartMin = newStartMin + "0";
}
actualChanges.put(minStartTimeParamName, newStartMin);
this.startTime = newStartHour + ":" + newStartMin;
}
if (command.isChangeInLongParameterNamed(hourEndTimeParamName, this.getHourFromEndTime())
|| command.isChangeInLongParameterNamed(minEndTimeParamName, this.getMinFromEndTime())) {
newEndHour = command.stringValueOfParameterNamed(hourEndTimeParamName);
if (newEndHour.equalsIgnoreCase("0")) {
newEndHour = newEndHour + "0";
}
actualChanges.put(hourEndTimeParamName, newEndHour);
newEndMin = command.stringValueOfParameterNamed(minEndTimeParamName);
if (newEndMin.equalsIgnoreCase("0")) {
newEndMin = newEndMin + "0";
}
actualChanges.put(minEndTimeParamName, newEndMin);
this.endTime = newEndHour + ":" + newEndMin;
}
}
return actualChanges;
}
public Long getHourFromStartTime() {
if (this.startTime != null && !this.startTime.equalsIgnoreCase("")) {
List<String> extractHourFromStartTime = Splitter.on(':').splitToList(this.startTime);
Long hour = Long.parseLong(extractHourFromStartTime.get(1));
return hour;
}
return null;
}
public Long getMinFromStartTime() {
if (this.startTime != null && !this.startTime.equalsIgnoreCase("")) {
List<String> extractMinFromStartTime = Splitter.on(':').splitToList(this.startTime);
Long min = Long.parseLong(extractMinFromStartTime.get(1));
return min;
}
return null;
}
public Long getHourFromEndTime() {
if (this.endTime != null && !this.endTime.equalsIgnoreCase("")) {
List<String> extractHourFromEndTime = Splitter.on(':').splitToList(this.endTime);
Long hour = Long.parseLong(extractHourFromEndTime.get(0));
return hour;
}
return null;
}
public Long getMinFromEndTime() {
if (this.endTime != null && !this.endTime.equalsIgnoreCase("")) {
List<String> extractMinFromEndTime = Splitter.on(':').splitToList(this.endTime);
Long min = Long.parseLong(extractMinFromEndTime.get(1));
return min;
}
return null;
}
}
@@ -1,33 +0,0 @@
/**
* 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.organisation.teller.domain;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* Provides the domain repository for accessing, adding, modifying or deleting cashiers.
*
* @author Markus Geiss
* @see org.apache.fineract.organisation.teller.domain.Cashier
* @since 2.0.0
*/
public interface CashierRepository extends JpaRepository<Cashier, Long>, JpaSpecificationExecutor<Cashier> {
// no added behavior
}
@@ -1,38 +0,0 @@
/**
* 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.organisation.teller.domain;
import org.apache.fineract.organisation.teller.exception.TellerNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class CashierRepositoryWrapper {
private final CashierRepository repository;
@Autowired
public CashierRepositoryWrapper(final CashierRepository repository) {
this.repository = repository;
}
public Cashier findOneWithNotFoundDetection(final Long id) {
return this.repository.findById(id).orElseThrow(() -> new TellerNotFoundException(id));
}
}
@@ -1,148 +0,0 @@
/**
* 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.organisation.teller.domain;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.persistence.Transient;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.LinkedHashMap;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.organisation.office.domain.Office;
@Entity
@Table(name = "m_cashier_transactions")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class CashierTransaction extends AbstractPersistableCustom {
@Transient
private Office office;
@Transient
private Teller teller;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "cashier_id", nullable = false)
private Cashier cashier;
@Column(name = "txn_type", nullable = false)
private Integer txnType;
@Column(name = "txn_date", nullable = false)
private LocalDate txnDate;
@Column(name = "txn_amount", scale = 6, precision = 19, nullable = false)
private BigDecimal txnAmount;
@Column(name = "txn_note", nullable = true)
private String txnNote;
@Column(name = "entity_type", nullable = true)
private String entityType;
@Column(name = "entity_id", nullable = true)
private Long entityId;
@Column(name = "created_date", nullable = false)
private LocalDateTime createdDate = DateUtils.getLocalDateTimeOfSystem();
@Column(name = "currency_code", nullable = true)
private String currencyCode;
public static CashierTransaction fromJson(final Cashier cashier, final JsonCommand command) {
final Integer txnType = command.integerValueOfParameterNamed("txnType");
final BigDecimal txnAmount = command.bigDecimalValueOfParameterNamed("txnAmount");
final LocalDate txnDate = command.localDateValueOfParameterNamed("txnDate");
final String entityType = command.stringValueOfParameterNamed("entityType");
final String txnNote = command.stringValueOfParameterNamed("txnNote");
final Long entityId = command.longValueOfParameterNamed("entityId");
final String currencyCode = command.stringValueOfParameterNamed("currencyCode");
// TODO: get client/loan/savings details
return new CashierTransaction().setCashier(cashier).setTxnType(txnType).setTxnAmount(txnAmount)
.setTxnDate(txnDate != null ? txnDate : null).setEntityType(entityType).setEntityId(entityId).setTxnNote(txnNote)
.setCurrencyCode(currencyCode);
}
public Map<String, Object> update(final JsonCommand command) {
final Map<String, Object> actualChanges = new LinkedHashMap<>(7);
final String dateFormatAsInput = command.dateFormat();
final String localeAsInput = command.locale();
final String txnTypeParamName = "txnType";
if (command.isChangeInIntegerParameterNamed(txnTypeParamName, this.txnType)) {
final Integer newValue = command.integerValueOfParameterNamed(txnTypeParamName);
actualChanges.put(txnTypeParamName, newValue);
this.txnType = newValue;
}
final String txnDateParamName = "txnDate";
if (command.isChangeInLocalDateParameterNamed(txnDateParamName, this.txnDate)) {
final String valueAsInput = command.stringValueOfParameterNamed(txnDateParamName);
actualChanges.put(txnDateParamName, valueAsInput);
actualChanges.put("dateFormat", dateFormatAsInput);
actualChanges.put("locale", localeAsInput);
this.txnDate = command.localDateValueOfParameterNamed(txnDateParamName);
}
final String txnAmountParamName = "txnAmount";
if (command.isChangeInBigDecimalParameterNamed(txnAmountParamName, this.txnAmount)) {
final BigDecimal newValue = command.bigDecimalValueOfParameterNamed(txnAmountParamName);
actualChanges.put(txnAmountParamName, newValue);
this.txnAmount = newValue;
}
final String txnNoteParamName = "txnNote";
if (command.isChangeInStringParameterNamed(txnNoteParamName, this.txnNote)) {
final String newValue = command.stringValueOfParameterNamed(txnNoteParamName);
actualChanges.put(txnNoteParamName, newValue);
this.txnNote = newValue;
}
final String currencyCodeParamName = "currencyCode";
if (command.isChangeInStringParameterNamed(currencyCodeParamName, this.currencyCode)) {
final String newValue = command.stringValueOfParameterNamed(currencyCodeParamName);
actualChanges.put(currencyCodeParamName, newValue);
this.currencyCode = newValue;
}
return actualChanges;
}
}
@@ -1,27 +0,0 @@
/**
* 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.organisation.teller.domain;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
public interface CashierTransactionRepository
extends JpaRepository<CashierTransaction, Long>, JpaSpecificationExecutor<CashierTransaction> {
// no added behavior
}
@@ -1,65 +0,0 @@
/**
* 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.organisation.teller.domain;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
@Getter
@NoArgsConstructor
@AllArgsConstructor
public final class CashierTxnType implements Serializable {
private Integer id;
private String value;
public static final CashierTxnType ALLOCATE = new CashierTxnType(101, "Allocate Cash");
public static final CashierTxnType SETTLE = new CashierTxnType(102, "Settle Cash");
public static final CashierTxnType INWARD_CASH_TXN = new CashierTxnType(103, "Cash In");
public static final CashierTxnType OUTWARD_CASH_TXN = new CashierTxnType(104, "Cash Out");
@Override
public String toString() {
return value;
}
public static CashierTxnType getCashierTxnType(Integer id) {
CashierTxnType retVal = null;
switch (id) {
case 101:
retVal = ALLOCATE;
break;
case 102:
retVal = SETTLE;
break;
case 103:
retVal = INWARD_CASH_TXN;
break;
case 104:
retVal = OUTWARD_CASH_TXN;
break;
default:
break;
}
return retVal;
}
}
@@ -1,164 +0,0 @@
/**
* 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.organisation.teller.domain;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import java.time.LocalDate;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.apache.fineract.accounting.glaccount.domain.GLAccount;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import org.apache.fineract.organisation.office.domain.Office;
@Entity
@Table(name = "m_tellers", uniqueConstraints = { @UniqueConstraint(name = "ux_tellers_name", columnNames = { "name" }) })
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class Teller extends AbstractPersistableCustom {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "office_id", nullable = false)
private Office office;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "debit_account_id", nullable = true)
private GLAccount debitAccount;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "credit_account_id", nullable = true)
private GLAccount creditAccount;
@Column(name = "name", nullable = false, length = 100)
private String name;
@Column(name = "description", nullable = true, length = 500)
private String description;
@Column(name = "valid_from", nullable = true)
private LocalDate startDate;
@Column(name = "valid_to", nullable = true)
private LocalDate endDate;
@Column(name = "state", nullable = false)
private Integer status;
@OneToMany(mappedBy = "teller", fetch = FetchType.LAZY)
private Set<Cashier> cashiers;
public static Teller fromJson(final Office tellerOffice, final JsonCommand command) {
final String name = command.stringValueOfParameterNamed("name");
final String description = command.stringValueOfParameterNamed("description");
final LocalDate startDate = command.localDateValueOfParameterNamed("startDate");
final LocalDate endDate = command.localDateValueOfParameterNamed("endDate");
final Integer tellerStatusInt = command.integerValueOfParameterNamed("status");
final TellerStatus status = TellerStatus.fromInt(tellerStatusInt);
return new Teller().setOffice(tellerOffice).setName(name).setDescription(description).setStartDate(startDate).setEndDate(endDate)
.setStatus(status.getValue());
}
public Map<String, Object> update(Office tellerOffice, final JsonCommand command) {
final Map<String, Object> actualChanges = new LinkedHashMap<>(7);
final String dateFormatAsInput = command.dateFormat();
final String localeAsInput = command.locale();
final String officeIdParamName = "officeId";
if (command.isChangeInLongParameterNamed(officeIdParamName, this.officeId())) {
final long newValue = command.longValueOfParameterNamed(officeIdParamName);
actualChanges.put(officeIdParamName, newValue);
this.office = tellerOffice;
}
final String nameParamName = "name";
if (command.isChangeInStringParameterNamed(nameParamName, this.name)) {
final String newValue = command.stringValueOfParameterNamed(nameParamName);
actualChanges.put(nameParamName, newValue);
this.name = newValue;
}
final String descriptionParamName = "description";
if (command.isChangeInStringParameterNamed(descriptionParamName, this.description)) {
final String newValue = command.stringValueOfParameterNamed(descriptionParamName);
actualChanges.put(descriptionParamName, newValue);
this.description = newValue;
}
final String startDateParamName = "startDate";
if (command.isChangeInLocalDateParameterNamed(startDateParamName, this.startDate)) {
final String valueAsInput = command.stringValueOfParameterNamed(startDateParamName);
actualChanges.put(startDateParamName, valueAsInput);
actualChanges.put("dateFormat", dateFormatAsInput);
actualChanges.put("locale", localeAsInput);
this.startDate = command.localDateValueOfParameterNamed(startDateParamName);
}
final String endDateParamName = "endDate";
if (command.isChangeInLocalDateParameterNamed(endDateParamName, this.endDate)) {
final String valueAsInput = command.stringValueOfParameterNamed(endDateParamName);
actualChanges.put(endDateParamName, valueAsInput);
actualChanges.put("dateFormat", dateFormatAsInput);
actualChanges.put("locale", localeAsInput);
this.endDate = command.localDateValueOfParameterNamed(endDateParamName);
}
final String statusParamName = "status";
if (command.isChangeInIntegerParameterNamed(statusParamName, getStatus())) {
final Integer valueAsInput = command.integerValueOfParameterNamed(statusParamName);
actualChanges.put(statusParamName, valueAsInput);
final Integer newValue = command.integerValueOfParameterNamed(statusParamName);
final TellerStatus status = TellerStatus.fromInt(newValue);
if (status != TellerStatus.INVALID) {
this.status = status.getValue();
}
}
return actualChanges;
}
public Long officeId() {
return this.office.getId();
}
public void initializeLazyCollections() {
this.office.getId();
this.cashiers.size();
}
}
@@ -1,21 +0,0 @@
/**
* 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.organisation.teller.domain;
public class TellerJournal {}
@@ -1,34 +0,0 @@
/**
* 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.organisation.teller.domain;
import java.util.Collection;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* Provides the domain repository for accessing, adding, modifying or deleting tellers.
*
* @see org.apache.fineract.organisation.teller.domain.Teller
* @since 2.0.0
*/
public interface TellerRepository extends JpaRepository<Teller, Long>, JpaSpecificationExecutor<Teller> {
Collection<Teller> findTellerByOfficeId(Long officeId);
}
@@ -1,54 +0,0 @@
/**
* 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.organisation.teller.domain;
import org.apache.fineract.organisation.teller.exception.TellerNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class TellerRepositoryWrapper {
private final TellerRepository repository;
@Autowired
public TellerRepositoryWrapper(final TellerRepository repository) {
this.repository = repository;
}
@Transactional(readOnly = true)
public Teller findOneWithNotFoundDetection(final Long id) {
final Teller teller = this.repository.findById(id).orElseThrow(() -> new TellerNotFoundException(id));
teller.initializeLazyCollections();
return teller;
}
public Teller save(final Teller teller) {
return this.repository.save(teller);
}
public Teller saveAndFlush(final Teller teller) {
return this.repository.saveAndFlush(teller);
}
public void delete(final Teller teller) {
this.repository.delete(teller);
}
}
@@ -1,77 +0,0 @@
/**
* 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.organisation.teller.domain;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* Enum representation of teller status states.
*/
@Getter
@AllArgsConstructor
public enum TellerStatus {
INVALID(0, "tellerStatusType.invalid"), PENDING(100, "tellerStatusType.pending"), ACTIVE(300, "tellerStatusType.active"), INACTIVE(400,
"tellerStatusType.inactive"), CLOSED(600, "tellerStatusType.closed");
private final Integer value;
private final String code;
public static TellerStatus fromInt(final Integer statusValue) {
TellerStatus status = TellerStatus.INVALID;
switch (statusValue) {
case 100:
status = TellerStatus.PENDING;
break;
case 300:
status = TellerStatus.ACTIVE;
break;
case 400:
status = TellerStatus.INACTIVE;
break;
case 600:
status = TellerStatus.CLOSED;
break;
}
return status;
}
public boolean hasStateOf(final TellerStatus state) {
return this.value.equals(state.getValue());
}
public boolean isPending() {
return this.value.equals(TellerStatus.PENDING.getValue());
}
public boolean isActive() {
return this.value.equals(TellerStatus.ACTIVE.getValue());
}
public boolean isClosed() {
return this.value.equals(TellerStatus.CLOSED.getValue());
}
public boolean isInactive() {
return this.value.equals(TellerStatus.INACTIVE.getValue());
}
}
@@ -1,71 +0,0 @@
/**
* 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.organisation.teller.domain;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import java.time.LocalDate;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import org.apache.fineract.organisation.office.domain.Office;
import org.apache.fineract.portfolio.client.domain.Client;
@Entity
@Table(name = "m_teller_transactions")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class TellerTransaction extends AbstractPersistableCustom {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "office_id", nullable = false)
private Office office;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "teller_id", nullable = false)
private Teller teller;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "cashier_id", nullable = false)
private Cashier cashier;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "client_id", nullable = false)
private Client client;
@Column(name = "type", nullable = false)
private Integer type;
@Column(name = "amount", nullable = false)
private Double amount;
@Column(name = "posting_date", nullable = false)
private LocalDate postingDate;
}
@@ -1,32 +0,0 @@
/**
* 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.organisation.teller.domain;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* Provides the domain repository for accessing, adding, modifying or deleting teller transactions.
*
* @see org.apache.fineract.organisation.teller.domain.TellerTransaction
* @since 2.0.0
*/
public interface TellerTransactionRepository extends JpaRepository<TellerTransaction, Long>, JpaSpecificationExecutor<TellerTransaction> {
// no added behavior
}
@@ -1,30 +0,0 @@
/**
* 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.organisation.teller.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException;
@SuppressWarnings("serial")
public class CashierAlreadyAllocated extends AbstractPlatformDomainRuleException {
public CashierAlreadyAllocated() {
super("cashier.already.allocated.for.given.data.and.time.exception", "Cashier already allocated for given date and time range.");
}
}
@@ -1,30 +0,0 @@
/**
* 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.organisation.teller.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException;
@SuppressWarnings("serial")
public class CashierDateRangeOutOfTellerDateRangeException extends AbstractPlatformDomainRuleException {
public CashierDateRangeOutOfTellerDateRangeException() {
super("cashier.date.range.out.of.teller.date.range.exception", "Cashier date range should be in teller date range.");
}
}
@@ -1,32 +0,0 @@
/**
* 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.organisation.teller.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException;
public class CashierExistForTellerException extends AbstractPlatformDomainRuleException {
private static final String ERROR_MESSAGE_CODE = "error.msg.cashier.is.associated.with.this.teller";
private static final String DEFAULT_ERROR_MESSAGE = "Cannot delete teller, Cashier is associated for this teller ";
public CashierExistForTellerException(Long tellerId) {
super(ERROR_MESSAGE_CODE, DEFAULT_ERROR_MESSAGE, tellerId);
}
}
@@ -1,30 +0,0 @@
/**
* 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.organisation.teller.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException;
@SuppressWarnings("serial")
public class CashierInsufficientAmountException extends AbstractPlatformDomainRuleException {
public CashierInsufficientAmountException() {
super("cashier.insufficient.amount.exception", "Cashier do not have sufficient amount for this transaction.");
}
}
@@ -1,43 +0,0 @@
/**
* 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.organisation.teller.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
/**
* Indicates that a cashier could not be found.
*
* @author Markus Geiss
* @since 2.0.0
*/
public class CashierNotFoundException extends AbstractPlatformResourceNotFoundException {
private static final String ERROR_MESSAGE_CODE = "error.msg.cashier.not.found";
private static final String DEFAULT_ERROR_MESSAGE = "Cashier with identifier {0,number,long} not found!";
/**
* Creates a new instance.
*
* @param cashierId
* the primary key of the cashier
*/
public CashierNotFoundException(Long cashierId) {
super(ERROR_MESSAGE_CODE, DEFAULT_ERROR_MESSAGE, cashierId);
}
}
@@ -1,28 +0,0 @@
/**
* 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.organisation.teller.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
public class InvalidDateInputException extends AbstractPlatformResourceNotFoundException {
public InvalidDateInputException(final String startDate, final String endDate) {
super("error.msg.invalid.endDate", "EndDate " + endDate + " cannot be before StartDate " + startDate);
}
}
@@ -1,43 +0,0 @@
/**
* 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.organisation.teller.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
/**
* Indicates that a teller could not be found.
*
* @author Markus Geiss
* @since 2.0.0
*/
public class TellerNotFoundException extends AbstractPlatformResourceNotFoundException {
private static final String ERROR_MESSAGE_CODE = "error.msg.teller.not.found";
private static final String DEFAULT_ERROR_MESSAGE = "Teller with identifier {0,number,long} not found!";
/**
* Creates a new instance.
*
* @param tellerId
* the primary key of the teller
*/
public TellerNotFoundException(Long tellerId) {
super(ERROR_MESSAGE_CODE, DEFAULT_ERROR_MESSAGE, tellerId);
}
}
@@ -1,52 +0,0 @@
/**
* 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.organisation.teller.handler;
import org.apache.fineract.commands.annotation.CommandType;
import org.apache.fineract.commands.handler.NewCommandSourceHandler;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.organisation.teller.service.TellerWritePlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
@CommandType(entity = "TELLER", action = "ALLOCATECASHTOCASHIER")
public class AllocateCashToCashierCommandHandler implements NewCommandSourceHandler {
private final TellerWritePlatformService writePlatformService;
/**
* Creates a new instance.
*
* @param writePlatformService
* the {@code CashierWritePlatformService} used to access the backend
*/
@Autowired
public AllocateCashToCashierCommandHandler(final TellerWritePlatformService writePlatformService) {
this.writePlatformService = writePlatformService;
}
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
return this.writePlatformService.allocateCashToCashier(command.subentityId(), command);
}
}
@@ -1,52 +0,0 @@
/**
* 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.organisation.teller.handler;
import org.apache.fineract.commands.annotation.CommandType;
import org.apache.fineract.commands.handler.NewCommandSourceHandler;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.organisation.teller.service.TellerWritePlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
@CommandType(entity = "TELLER", action = "ALLOCATECASHIER")
public class AllocateCashierToTellerCommandHandler implements NewCommandSourceHandler {
private final TellerWritePlatformService writePlatformService;
/**
* Creates a new instance.
*
* @param writePlatformService
* the {@code CashierWritePlatformService} used to access the backend
*/
@Autowired
public AllocateCashierToTellerCommandHandler(final TellerWritePlatformService writePlatformService) {
this.writePlatformService = writePlatformService;
}
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
return this.writePlatformService.allocateCashierToTeller(command.entityId(), command);
}
}
@@ -1,57 +0,0 @@
/**
* 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.organisation.teller.handler;
import org.apache.fineract.commands.annotation.CommandType;
import org.apache.fineract.commands.handler.NewCommandSourceHandler;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.organisation.teller.service.TellerWritePlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Handles a create teller command.
*
* @author Markus Geiss
* @see org.apache.fineract.organisation.teller.service.TellerWritePlatformService
* @since 2.0.0
*/
@Service
@CommandType(entity = "TELLER", action = "CREATE")
public class CreateTellerCommandHandler implements NewCommandSourceHandler {
private final TellerWritePlatformService writePlatformService;
/**
* Creates a new instance
*
* @param writePlatformService
* the {@code TellerWritePlatformService} used to access the backend
*/
@Autowired
public CreateTellerCommandHandler(final TellerWritePlatformService writePlatformService) {
this.writePlatformService = writePlatformService;
}
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
return this.writePlatformService.createTeller(command);
}
}
@@ -1,41 +0,0 @@
/**
* 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.organisation.teller.handler;
import org.apache.fineract.commands.handler.NewCommandSourceHandler;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.organisation.teller.service.TellerTransactionWritePlatformService;
import org.springframework.beans.factory.annotation.Autowired;
public class CreateTellerTransactionCommandHandler implements NewCommandSourceHandler {
private final TellerTransactionWritePlatformService writePlatformService;
@Autowired
public CreateTellerTransactionCommandHandler(final TellerTransactionWritePlatformService writePlatformService) {
this.writePlatformService = writePlatformService;
}
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
return this.writePlatformService.createTellerTransaction(command);
}
}
@@ -1,58 +0,0 @@
/**
* 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.organisation.teller.handler;
import org.apache.fineract.commands.annotation.CommandType;
import org.apache.fineract.commands.handler.NewCommandSourceHandler;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.organisation.teller.service.TellerWritePlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Handles a delete cashier command.
*
* @author Markus Geiss
* @see org.apache.fineract.organisation.teller.service.CashierWritePlatformService
* @since 2.0.0
*/
@Service
@CommandType(entity = "TELLER", action = "DELETECASHIERALLOCATION")
public class DeleteCashierAllocationCommandHandler implements NewCommandSourceHandler {
private final TellerWritePlatformService writePlatformService;
/**
* Creates a new instance.
*
* @param writePlatformService
* the {@code CashierWritePlatformService} used to access the backend
*/
@Autowired
public DeleteCashierAllocationCommandHandler(final TellerWritePlatformService writePlatformService) {
this.writePlatformService = writePlatformService;
}
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
return this.writePlatformService.deleteCashierAllocation(command.entityId(), command.subentityId(), command);
}
}
@@ -1,58 +0,0 @@
/**
* 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.organisation.teller.handler;
import org.apache.fineract.commands.annotation.CommandType;
import org.apache.fineract.commands.handler.NewCommandSourceHandler;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.organisation.teller.service.TellerWritePlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Handles a delete teller command.
*
* @author Markus Geiss
* @see org.apache.fineract.organisation.teller.service.TellerWritePlatformService
* @since 2.0.0
*/
@Service
@CommandType(entity = "TELLER", action = "DELETE")
public class DeleteTellerCommandHandler implements NewCommandSourceHandler {
private final TellerWritePlatformService writePlatformService;
/**
* Creates a new instance
*
* @param writePlatformService
* the {@code TellerWritePlatformService} used to access the backend
*/
@Autowired
public DeleteTellerCommandHandler(final TellerWritePlatformService writePlatformService) {
this.writePlatformService = writePlatformService;
}
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
return this.writePlatformService.deleteTeller(command.entityId());
}
}
@@ -1,54 +0,0 @@
/**
* 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.organisation.teller.handler;
import org.apache.fineract.commands.handler.NewCommandSourceHandler;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.organisation.teller.service.CashierWritePlatformService;
import org.springframework.beans.factory.annotation.Autowired;
/**
* Handles a modify cashier command.
*
* @author Markus Geiss
* @see org.apache.fineract.organisation.teller.service.CashierWritePlatformService
* @since 2.0.0
*/
public class ModifyCashierCommandHandler implements NewCommandSourceHandler {
private final CashierWritePlatformService writePlatformService;
/**
* Creates a new instance.
*
* @param writePlatformService
* the {@code CashierWritePlatformService} used to access the backend
*/
@Autowired
public ModifyCashierCommandHandler(final CashierWritePlatformService writePlatformService) {
this.writePlatformService = writePlatformService;
}
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
return this.writePlatformService.modifyCashier(command.entityId(), command);
}
}
@@ -1,52 +0,0 @@
/**
* 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.organisation.teller.handler;
import org.apache.fineract.commands.annotation.CommandType;
import org.apache.fineract.commands.handler.NewCommandSourceHandler;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.organisation.teller.service.TellerWritePlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
@CommandType(entity = "TELLER", action = "SETTLECASHFROMCASHIER")
public class SettleCashFromCashierCommandHandler implements NewCommandSourceHandler {
private final TellerWritePlatformService writePlatformService;
/**
* Creates a new instance.
*
* @param writePlatformService
* the {@code CashierWritePlatformService} used to access the backend
*/
@Autowired
public SettleCashFromCashierCommandHandler(final TellerWritePlatformService writePlatformService) {
this.writePlatformService = writePlatformService;
}
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
return this.writePlatformService.settleCashFromCashier(command.subentityId(), command);
}
}
@@ -1,58 +0,0 @@
/**
* 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.organisation.teller.handler;
import org.apache.fineract.commands.annotation.CommandType;
import org.apache.fineract.commands.handler.NewCommandSourceHandler;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.organisation.teller.service.TellerWritePlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Handles a delete teller command.
*
* @author Markus Geiss
* @see org.apache.fineract.organisation.teller.service.TellerWritePlatformService
* @since 2.0.0
*/
@Service
@CommandType(entity = "TELLER", action = "UPDATECASHIERALLOCATION")
public class UpdateCashierAllocationCommandHandler implements NewCommandSourceHandler {
private final TellerWritePlatformService writePlatformService;
/**
* Creates a new instance
*
* @param writePlatformService
* the {@code TellerWritePlatformService} used to access the backend
*/
@Autowired
public UpdateCashierAllocationCommandHandler(final TellerWritePlatformService writePlatformService) {
this.writePlatformService = writePlatformService;
}
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
return this.writePlatformService.updateCashierAllocation(command.entityId(), command.subentityId(), command);
}
}
@@ -1,58 +0,0 @@
/**
* 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.organisation.teller.handler;
import org.apache.fineract.commands.annotation.CommandType;
import org.apache.fineract.commands.handler.NewCommandSourceHandler;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.organisation.teller.service.TellerWritePlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Handles a delete teller command.
*
* @author Markus Geiss
* @see org.apache.fineract.organisation.teller.service.TellerWritePlatformService
* @since 2.0.0
*/
@Service
@CommandType(entity = "TELLER", action = "UPDATE")
public class UpdateTellerCommandHandler implements NewCommandSourceHandler {
private final TellerWritePlatformService writePlatformService;
/**
* Creates a new instance
*
* @param writePlatformService
* the {@code TellerWritePlatformService} used to access the backend
*/
@Autowired
public UpdateTellerCommandHandler(final TellerWritePlatformService writePlatformService) {
this.writePlatformService = writePlatformService;
}
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
return this.writePlatformService.modifyTeller(command.entityId(), command);
}
}
@@ -1,202 +0,0 @@
/**
* 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.organisation.teller.serialization;
import com.google.gson.JsonElement;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.core.data.ApiParameterError;
import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
import org.apache.fineract.infrastructure.core.exception.InvalidJsonException;
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.organisation.teller.exception.InvalidDateInputException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* Deserializer of JSON for Teller API.
*/
@Component
public final class TellerCommandFromApiJsonDeserializer {
public static final String OFFICE_ID = "officeId";
public static final String NAME = "name";
public static final String DESCRIPTION = "description";
public static final String START_DATE = "startDate";
public static final String END_DATE = "endDate";
public static final String STATUS = "status";
public static final String DATE_FORMAT = "dateFormat";
public static final String LOCALE = "locale";
public static final String IS_FULL_DAY = "isFullDay";
public static final String STAFF_ID = "staffId";
public static final String ENTITY_TYPE = "entityType";
public static final String ENTITY_ID = "entityId";
public static final String CURRENCY_CODE = "currencyCode";
public static final String HOUR_START_TIME = "hourStartTime";
public static final String MIN_START_TIME = "minStartTime";
public static final String HOUR_END_TIME = "hourEndTime";
public static final String MIN_END_TIME = "minEndTime";
public static final String TXN_AMOUNT = "txnAmount";
public static final String TXN_DATE = "txnDate";
public static final String TXN_NOTE = "txnNote";
public static final String TELLER = "teller";
/**
* The parameters supported for this command.
*/
private static final Set<String> SUPPORTED_PARAMETERS = new HashSet<>(Arrays.asList(OFFICE_ID, NAME, DESCRIPTION, START_DATE, END_DATE,
STATUS, DATE_FORMAT, LOCALE, IS_FULL_DAY, STAFF_ID, HOUR_START_TIME, MIN_START_TIME, HOUR_END_TIME, MIN_END_TIME, TXN_AMOUNT,
TXN_DATE, TXN_NOTE, ENTITY_TYPE, ENTITY_ID, CURRENCY_CODE));
private final FromJsonHelper fromApiJsonHelper;
@Autowired
public TellerCommandFromApiJsonDeserializer(final FromJsonHelper fromApiJsonHelper) {
this.fromApiJsonHelper = fromApiJsonHelper;
}
public void validateForCreateAndUpdateTeller(final String json) {
if (StringUtils.isBlank(json)) {
throw new InvalidJsonException();
}
final Type typeOfMap = new TypeToken<Map<String, Object>>() {
}.getType();
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, SUPPORTED_PARAMETERS);
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource(TELLER);
final JsonElement element = this.fromApiJsonHelper.parse(json);
final Long officeId = this.fromApiJsonHelper.extractLongNamed(OFFICE_ID, element);
baseDataValidator.reset().parameter(OFFICE_ID).value(officeId).notNull().integerGreaterThanZero();
final String name = this.fromApiJsonHelper.extractStringNamed(NAME, element);
baseDataValidator.reset().parameter(NAME).value(name).notBlank().notExceedingLengthOf(50);
final String description = this.fromApiJsonHelper.extractStringNamed(DESCRIPTION, element);
baseDataValidator.reset().parameter(DESCRIPTION).value(description).notExceedingLengthOf(100);
final LocalDate startDate = this.fromApiJsonHelper.extractLocalDateNamed(START_DATE, element);
baseDataValidator.reset().parameter(START_DATE).value(startDate).notNull();
final LocalDate endDate = this.fromApiJsonHelper.extractLocalDateNamed(END_DATE, element);
baseDataValidator.reset().parameter(END_DATE).value(endDate).ignoreIfNull();
final String status = this.fromApiJsonHelper.extractStringNamed(STATUS, element);
baseDataValidator.reset().parameter(STATUS).value(status).notBlank().notExceedingLengthOf(50);
if (endDate != null && DateUtils.isBefore(endDate, startDate)) {
throw new InvalidDateInputException(startDate.toString(), endDate.toString());
}
throwExceptionIfValidationWarningsExist(dataValidationErrors);
}
private void throwExceptionIfValidationWarningsExist(final List<ApiParameterError> dataValidationErrors) {
if (!dataValidationErrors.isEmpty()) {
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.",
dataValidationErrors);
}
}
public void validateForAllocateCashier(final String json) {
if (StringUtils.isBlank(json)) {
throw new InvalidJsonException();
}
final Type typeOfMap = new TypeToken<Map<String, Object>>() {
}.getType();
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, SUPPORTED_PARAMETERS);
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource(TELLER);
final JsonElement element = this.fromApiJsonHelper.parse(json);
final Long staffId = this.fromApiJsonHelper.extractLongNamed(STAFF_ID, element);
baseDataValidator.reset().parameter(STAFF_ID).value(staffId).notNull().integerGreaterThanZero();
final String description = this.fromApiJsonHelper.extractStringNamed(DESCRIPTION, element);
baseDataValidator.reset().parameter(DESCRIPTION).value(description).notExceedingLengthOf(100);
final LocalDate startDate = this.fromApiJsonHelper.extractLocalDateNamed(START_DATE, element);
baseDataValidator.reset().parameter(START_DATE).value(startDate).notNull();
final LocalDate endDate = this.fromApiJsonHelper.extractLocalDateNamed(END_DATE, element);
baseDataValidator.reset().parameter(END_DATE).value(endDate).notNull();
final Boolean isFullDay = this.fromApiJsonHelper.extractBooleanNamed(IS_FULL_DAY, element);
baseDataValidator.reset().parameter(IS_FULL_DAY).value(isFullDay).notNull();
if (!isFullDay) {
final String hourStartTime = this.fromApiJsonHelper.extractStringNamed(HOUR_START_TIME, element);
baseDataValidator.reset().parameter("startTime").value(hourStartTime).notBlank();
final String minStartTime = this.fromApiJsonHelper.extractStringNamed(MIN_START_TIME, element);
baseDataValidator.reset().parameter("startTime").value(minStartTime).notBlank();
final String hourEndTime = this.fromApiJsonHelper.extractStringNamed(HOUR_END_TIME, element);
baseDataValidator.reset().parameter(HOUR_END_TIME).value(hourEndTime).notBlank();
final String minEndTime = this.fromApiJsonHelper.extractStringNamed(MIN_END_TIME, element);
baseDataValidator.reset().parameter(MIN_END_TIME).value(minEndTime).notBlank();
}
throwExceptionIfValidationWarningsExist(dataValidationErrors);
}
public void validateForCashTxnForCashier(final String json) {
if (StringUtils.isBlank(json)) {
throw new InvalidJsonException();
}
final Type typeOfMap = new TypeToken<Map<String, Object>>() {
}.getType();
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, SUPPORTED_PARAMETERS);
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource(TELLER);
final JsonElement element = this.fromApiJsonHelper.parse(json);
final BigDecimal txnAmount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(TXN_AMOUNT, element);
baseDataValidator.reset().parameter(TXN_AMOUNT).value(txnAmount).notNull();
final LocalDate txnDate = this.fromApiJsonHelper.extractLocalDateNamed(TXN_DATE, element);
baseDataValidator.reset().parameter(TXN_DATE).value(txnDate).notNull();
final String txnNote = this.fromApiJsonHelper.extractStringNamed(TXN_NOTE, element);
baseDataValidator.reset().parameter(TXN_NOTE).value(txnNote).notExceedingLengthOf(200);
final String currencyCode = this.fromApiJsonHelper.extractStringNamed(CURRENCY_CODE, element);
baseDataValidator.reset().parameter(CURRENCY_CODE).value(currencyCode).notExceedingLengthOf(3);
}
}
@@ -1,41 +0,0 @@
/**
* 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.organisation.teller.service;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
public class CashierWritePlatformService {
public CommandProcessingResult allocateCashierToTeller(JsonCommand command) {
// TODO Auto-generated method stub
return null;
}
public CommandProcessingResult deleteCashier(Long entityId) {
// TODO Auto-generated method stub
return null;
}
public CommandProcessingResult modifyCashier(Long entityId, JsonCommand command) {
// TODO Auto-generated method stub
return null;
}
}
@@ -1,70 +0,0 @@
/**
* 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.organisation.teller.service;
import java.time.LocalDate;
import java.util.Collection;
import org.apache.fineract.infrastructure.core.service.Page;
import org.apache.fineract.infrastructure.core.service.SearchParameters;
import org.apache.fineract.organisation.teller.data.CashierData;
import org.apache.fineract.organisation.teller.data.CashierTransactionData;
import org.apache.fineract.organisation.teller.data.CashierTransactionsWithSummaryData;
import org.apache.fineract.organisation.teller.data.TellerData;
import org.apache.fineract.organisation.teller.data.TellerJournalData;
import org.apache.fineract.organisation.teller.data.TellerTransactionData;
public interface TellerManagementReadPlatformService {
Collection<TellerData> getTellers(Long officeId);
TellerData findTeller(Long tellerId);
CashierData findCashier(Long cashierId);
Collection<CashierData> getCashierData(Long officeId, Long tellerId, Long staffId, LocalDate date);
Collection<CashierData> getTellerCashiers(Long tellerId, LocalDate date);
CashierData retrieveCashierTemplate(Long officeId, Long tellerId, boolean staffInSelectedOfficeOnly);
CashierTransactionData retrieveCashierTxnTemplate(Long cashierId);
TellerTransactionData findTellerTransaction(Long transactionId);
Collection<TellerTransactionData> fetchTellerTransactionsByTellerId(Long tellerId, LocalDate fromDate, LocalDate toDate);
Collection<TellerJournalData> getJournals(Long officeId, Long tellerId, Long cashierId, LocalDate dateFrom, LocalDate dateTo);
Collection<TellerJournalData> fetchTellerJournals(Long tellerId, Long cashierId, LocalDate fromDate, LocalDate toDate);
Collection<TellerData> retrieveAllTellersForDropdown(Long officeId);
Collection<TellerData> retrieveAllTellers(String sqlSearch, Long officeId, String status);
Collection<CashierData> getCashiersForTeller(Long tellerId, LocalDate fromDate, LocalDate toDate);
Collection<CashierData> retrieveCashiersForTellers(String sqlSearch, Long tellerId);
Page<CashierTransactionData> retrieveCashierTransactions(Long cashierId, boolean includeAllTellers, LocalDate fromDate,
LocalDate toDate, String currencyCode, SearchParameters searchParameters);
CashierTransactionsWithSummaryData retrieveCashierTransactionsWithSummary(Long cashierId, boolean includeAllTellers, LocalDate fromDate,
LocalDate toDate, String currencyCode, SearchParameters searchParameters);
}
@@ -1,40 +0,0 @@
/**
* 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.organisation.teller.service;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
/**
* Provides the local service for adding teller transactions.
*
* @see org.apache.fineract.organisation.teller.domain.TellerTransactionRepository
* @since 2.0.0
*/
public interface TellerTransactionWritePlatformService {
/**
* Stores teller transactions into the data base.
*
* @param command
* the command containing the teller transaction details
* @return the result i
*/
CommandProcessingResult createTellerTransaction(JsonCommand command);
}
@@ -1,88 +0,0 @@
/**
* 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.organisation.teller.service;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
/**
* Provides the local service for adding, modifying and deleting tellers.
*
* @author Markus Geiss
* @see org.apache.fineract.organisation.teller.domain.TellerRepository
* @since 2.0.0
*/
public interface TellerWritePlatformService {
/**
* Creates a new teller.
*
* @param command
* the command to create a new teller
* @return {@code CommandProcessingResult} if successful
* @throws org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException
* @throws org.apache.fineract.infrastructure.core.exception.InvalidJsonException
*/
CommandProcessingResult createTeller(JsonCommand command);
/**
* Modifies a new teller.
*
* @param tellerId
* the primary key of the teller
* @param command
* the command to modifya new teller
* @return {@code CommandProcessingResult} if successful
* @throws org.apache.fineract.organisation.teller.exception.TellerNotFoundException
* @throws org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException
* @throws org.apache.fineract.infrastructure.core.exception.InvalidJsonException
*/
CommandProcessingResult modifyTeller(Long tellerId, JsonCommand command);
/**
* deletes a new teller.
*
* @param tellerId
* the primary key of the teller
* @return {@code CommandProcessingResult} if successful
* @throws org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException
* @throws org.apache.fineract.infrastructure.core.exception.InvalidJsonException
*/
CommandProcessingResult deleteTeller(Long tellerId);
/**
* Allocates a cashier to an existing teller. The allocation can be for a duration from a date to a date from a
* certain start time to an end time.
*
* @param command
* the command to allocate a cashier for a specific teller
* @return {@code CommandProcessingResult} if successful
* @throws org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException
* @throws org.apache.fineract.infrastructure.core.exception.InvalidJsonException
*/
CommandProcessingResult allocateCashierToTeller(Long tellerId, JsonCommand command);
CommandProcessingResult updateCashierAllocation(Long tellerId, Long cashierId, JsonCommand command);
CommandProcessingResult deleteCashierAllocation(Long tellerId, Long cashierId, JsonCommand command);
CommandProcessingResult allocateCashToCashier(Long cashierId, JsonCommand command);
CommandProcessingResult settleCashFromCashier(Long cashierId, JsonCommand command);
}
@@ -1,85 +0,0 @@
/**
* 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.organisation.teller.util;
import java.time.LocalDate;
import java.time.format.DateTimeParseException;
import java.util.StringTokenizer;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DateRange {
private static final Logger LOG = LoggerFactory.getLogger(DateRange.class);
private static final String ISO_8601_DATE_PATTERN = "yyy-MM-dd";
private static final String RANGE_DELIMITER = "..";
private LocalDate startDate;
private LocalDate endDate;
public DateRange() {
}
public LocalDate getStartDate() {
return startDate;
}
public void setStartDate(LocalDate startDate) {
this.startDate = startDate;
}
public LocalDate getEndDate() {
return endDate;
}
public void setEndDate(LocalDate endDate) {
this.endDate = endDate;
}
public static DateRange fromString(final String dateToParse) {
final DateRange dateRange = new DateRange();
final String testee;
if (dateToParse == null) {
testee = DateUtils.DEFAULT_DATE_FORMATTER.format(DateUtils.getBusinessLocalDate());
} else {
testee = dateToParse;
}
final StringTokenizer tokenizer = new StringTokenizer(testee, DateRange.RANGE_DELIMITER);
try {
dateRange.setStartDate(LocalDate.parse(tokenizer.nextToken(), DateUtils.DEFAULT_DATE_FORMATTER));
} catch (DateTimeParseException ex) {
LOG.error("Problem occurred in DateRange function Could not parse the date recieved.", ex);
}
if (tokenizer.hasMoreTokens()) {
try {
dateRange.setEndDate(LocalDate.parse(tokenizer.nextToken(), DateUtils.DEFAULT_DATE_FORMATTER));
} catch (DateTimeParseException ex) {
LOG.error("Problem occurred in DateRange function Could not parse the date recieved.", ex);
}
}
return dateRange;
}
}