Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Develop #512

Merged
merged 7 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions build/build-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,10 @@ config:
dockerfile: "build/maven/Dockerfile"
- work-dir: "municipal-services/property-services/src/main/resources/db"
image-name: "property-services-db"
- name: "builds/mGramSeva/business-services/egov-apportion-service"
build:
- work-dir: "business-services/egov-apportion-service"
image-name: "egov-apportion-service"
dockerfile: "build/maven/Dockerfile"
- work-dir: "business-services/egov-apportion-service/src/main/resources/db"
image-name: "egov-apportion-service-db"
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"info": {
"_postman_id": "199db000-e1ea-41e0-a559-2fca1e4d5d9d",
"name": "Apportion",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "apportion",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"RequestInfo\": {\n \"apiId\": \"Rainmaker\",\n \"action\": \"\",\n \"did\": 1,\n \"key\": \"\",\n \"msgId\": \"20170310130900|en_IN\",\n \"requesterId\": \"\",\n \"ts\": \"\",\n \"ver\": \".01\",\n \"userInfo\": {\n \n \"id\": 104,\n \"uuid\": \"1dc1db2c-6f26-4803-a3a7-028eb4abff6e\",\n \"userName\": \"9999999999\",\n \"name\": \"dfghj\",\n \"gender\": null,\n \"mobileNumber\": \"9999999999\",\n \"type\": \"CITIZEN\",\n \"roles\": [\n {\n \"id\": null,\n \"name\": \"Citizen\",\n \"code\": \"CITIZEN\"\n }\n ],\n \"tenantId\": \"pb\"\n },\n \"authToken\": \"7f7d617b-f7b4-4e2c-907d-dfd0256f2331\"\n },\n \"tenantId\":\"pb.amritsar\",\n \"Bills\":[\n {\n \"id\": \"10090\",\n \"payeeName\": \"NAMEchanged\",\n \"payeeAddress\": \"ADDRESS\",\n \"mobileNumber\": \"9999999999\",\n \"payeeEmail\": null,\n \"isActive\": true,\n \"isCancelled\": false,\n \"collectionMap\": {\n \"PT\": \"213409\"\n },\n \"billDetails\": [\n {\n \"id\": \"10166\",\n \"bill\": \"10090\",\n \"billDate\": 1551249289654,\n \"billDescription\": \"PT Consumer Code: PT-107-016526:AS-2019-02-27-016985\",\n \"billNumber\": \"10166\",\n \"consumerCode\": \"PT-107-016526:AS-2019-02-27-016985\",\n \"consumerType\": \"BUILTUP\",\n \"minimumAmount\": 100,\n \"totalAmount\": 213409,\n \"collectedAmount\": 0,\n \"collectionModesNotAllowed\": [\n \"\"\n ],\n \"tenantId\": \"pb.amritsar\",\n \"businessService\": \"PT\",\n \"displayMessage\": \"PT Consumer Code: PT-107-016526:AS-2019-02-27-016985\",\n \"callBackForApportioning\": false,\n \"receiptNumber\": null,\n \"receiptDate\": null,\n \"receiptType\": null,\n \"channel\": null,\n \"voucherHeader\": null,\n \"boundary\": null,\n \"reasonForCancellation\": null,\n \"amountPaid\": null,\n \"cancellationRemarks\": null,\n \"status\": null,\n \"billAccountDetails\": [\n {\n \"id\": \"37770\",\n \"tenantId\": \"pb.amritsar\",\n \"billDetail\": \"10166\",\n \"glcode\": \"1100101\",\n \"order\": 2,\n \"accountDescription\": \"PT_CANCER_CESS-1522540800000-1554076799000\",\n \"amount\": 8750,\n \"adjustedAmount\": 0,\n \"isActualDemand\": true,\n \"purpose\": \"CURRENT_AMOUNT\"\n },\n {\n \"id\": \"37771\",\n \"tenantId\": \"pb.amritsar\",\n \"billDetail\": \"10166\",\n \"glcode\": \"1405019\",\n \"order\": 99,\n \"accountDescription\": \"PT_DECIMAL_CEILING_CREDIT-1522540800000-1554076799000\",\n \"amount\": 0.1,\n \"adjustedAmount\": 0,\n \"isActualDemand\": true,\n \"purpose\": \"CURRENT_AMOUNT\"\n },\n {\n \"id\": \"37772\",\n \"tenantId\": \"pb.amritsar\",\n \"billDetail\": \"10166\",\n \"glcode\": \"1405013\",\n \"order\": 2,\n \"accountDescription\": \"PT_FIRE_CESS-1522540800000-1554076799000\",\n \"amount\": 8750,\n \"adjustedAmount\": 0,\n \"isActualDemand\": true,\n \"purpose\": \"CURRENT_AMOUNT\"\n },\n {\n \"id\": \"37773\",\n \"tenantId\": \"pb.amritsar\",\n \"billDetail\": \"10166\",\n \"glcode\": \"1405015\",\n \"order\": 1,\n \"accountDescription\": \"PT_OWNER_EXEMPTION-1522540800000-1554076799000\",\n \"amount\": -5000,\n \"adjustedAmount\": 0,\n \"isActualDemand\": true,\n \"purpose\": \"EXEMPTION\"\n },\n {\n \"id\": \"37774\",\n \"tenantId\": \"pb.amritsar\",\n \"billDetail\": \"10166\",\n \"glcode\": \"1405013\",\n \"order\": 3,\n \"accountDescription\": \"PT_TAX-1522540800000-1554076799000\",\n \"amount\": 180000,\n \"adjustedAmount\": 0,\n \"isActualDemand\": true,\n \"purpose\": \"CURRENT_AMOUNT\"\n },\n {\n \"id\": \"37775\",\n \"tenantId\": \"pb.amritsar\",\n \"billDetail\": \"10166\",\n \"glcode\": \"1405019\",\n \"order\": 10,\n \"accountDescription\": \"PT_TIME_INTEREST-1522540800000-1554076799000\",\n \"amount\": 3408.9,\n \"adjustedAmount\": 0,\n \"isActualDemand\": true,\n \"purpose\": \"OTHERS\"\n },\n {\n \"id\": \"37776\",\n \"tenantId\": \"pb.amritsar\",\n \"billDetail\": \"10166\",\n \"glcode\": \"1405013\",\n \"order\": 1,\n \"accountDescription\": \"PT_TIME_PENALTY-1522540800000-1554076799000\",\n \"amount\": 17500,\n \"adjustedAmount\": 0,\n \"isActualDemand\": true,\n \"purpose\": \"OTHERS\"\n },\n {\n \"id\": \"37777\",\n \"tenantId\": \"pb.amritsar\",\n \"billDetail\": \"10166\",\n \"glcode\": \"1405016\",\n \"order\": 1,\n \"accountDescription\": \"PT_TIME_REBATE-1522540800000-1554076799000\",\n \"amount\": 0,\n \"adjustedAmount\": 0,\n \"isActualDemand\": true,\n \"purpose\": \"REBATE\"\n },\n {\n \"id\": \"37778\",\n \"tenantId\": \"pb.amritsar\",\n \"billDetail\": \"10166\",\n \"glcode\": \"1405019\",\n \"order\": 100,\n \"accountDescription\": \"PT_UNIT_USAGE_EXEMPTION-1522540800000-1554076799000\",\n \"amount\": 0,\n \"adjustedAmount\": 0,\n \"isActualDemand\": true,\n \"purpose\": \"EXEMPTION\"\n }\n ],\n \"manualReceiptNumber\": null,\n \"stateId\": null\n } \n ],\n \"tenantId\": \"pb.amritsar\",\n \"auditDetails\": null\n }\n \t]\n\n}"
},
"url": {
"raw": "https://egov-micro-dev.egovernments.org/apportion-service/v1/_apportion",
"protocol": "https",
"host": [
"egov-micro-dev",
"egovernments",
"org"
],
"path": [
"apportion-service",
"v1",
"_apportion"
]
}
},
"response": []
}
]
}
37 changes: 37 additions & 0 deletions business-services/egov-apportion-service/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@


# Changelog
All notable changes to this module will be documented in this file.
## 1.1.5 - 2023-02-02

- Transition from 1.1.5-beta version to 1.1.5 version

## 1.1.5-beta - 2022-01-13
- Updated to log4j2 version 2.17.1

## 1.1.4 2021-02-26

- Updated domain name in application.properties

## 1.1.3 2021-01-12

- Apportion and backupdate to demands enabled for zero payments, which was blocked till this point of time

## 1.1.3

## 1.1.2 2020-08-24
- Fixed Bug RAIN-1432: Added audit for demand apportion

## 1.1.1 - 2020-06-17

- Fixed Bug WOR-415: Regarding adjustedAmount during multiple advance adjustment

## 1.1.0 - 2020-06-25
- Added typescript definition generation plugin
- Upgraded to `tracer:2.0.0-SNAPSHOT`
- Upgraded to spring boot `2.2.6-RELEASE`
- Deleted `Dockerfile` and `start.sh` as it is no longer in use

## 1.0.0

- Base version
37 changes: 37 additions & 0 deletions business-services/egov-apportion-service/LOCALSETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Local Setup

To setup the egov-apportion-service service in your local system, clone the [Business Service repository](https://github.com/egovernments/business-services).

## Dependencies

### Infra Dependency

- [x] Postgres DB
- [ ] Redis
- [ ] Elasticsearch
- [x] Kafka
- [ ] Consumer
- [x] Producer

## Running Locally

To run the egov-apportion-service in local system, you need to port forward below services.

```bash
kubectl port-forward -n egov {egov-mdms} 8088:8080
```

Update below listed properties in `application.properties` before running the project:

```ini

-spring.datasource.url=jdbc:postgresql://localhost:5432/{local postgres db name}

-spring.flyway.url=jdbc:postgresql://localhost:5432/{local postgres db name}

-egov.mdms.host={mdms hostname}

```

Optionally egov=persister should be ran locally if auditing is required and following config path should be added in it:
(https://raw.githubusercontent.com/egovernments/configs/master/egov-persister/apportion-persister.yml)
73 changes: 73 additions & 0 deletions business-services/egov-apportion-service/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@


# eGov ApportionService


Module is used to distribute the paid amount among the taxHeads.

### Apportion
The Apportioning service is used to distribute the paid amount among the respective taxHead.
There are two API's first is /apportion-service/bill/_apportion endpoint which is used to apportion the bill. In this case each bill is processed seperately.
The billDetails in each bill are grouped by businessService. For each group the apportionPaidAmount() function is called to apportion the paid amount.
The second endpoint is /apportion-service/demand/_apportion which is used to apportion advance amount in demands. Demands for the same consumer code should be sent for the apportion.
The interface Apportion is to be implemented for custom logic. Default implementation is provided in class called OrderByPriorityApportion,
Default Implementation:
1. Apportions the paid amount based on the order in each taxhead (ascending wise priority)
2. If multiple billDetails are present they are sorted by fromPeriod and the oldest one is apportioned first
3. Validation is placed to enforce that all taxHeads containing negative amounts should have order less than the one with positive amounts
4. Any advance amount is added to the latest billDetail as new billAccountDetail
For custom implementation the methods getBusinessService() and apportionPaidAmount() has to be implemented. The first method returns key of the implementation while the second method contains the apportion logic for the particular key
The apportion request and respose are stored for audit using persister



### Service Dependencies
- egov-mdms
- egov-persister


### Project Structure
*Packages*
- config - Contains all the configuration properties related to module
- service - Consists of all services containing the business logic.
- util - Contains utility functions and constants.
- repository - Fetch data from dependent micro services
- web/controllers - Controllers for the app.
- web/models - POJO for the module.
- producer - Contains kafka producer


### Resources
- Granular details about the API's can be found in the [swagger api definition](https://raw.githubusercontent.com/egovernments/docs/collections/contracts/apportion/egov-apportion-service.yml)
- Postman collection for all the API's can be found in the [postman collection](https://raw.githubusercontent.com/egovernments/egov-services/core/egov-apportion-service/Apportion.postman_collection.json)


## Build & Run


mvn clean install
java -jar target/egov-apportion-service-1.1.1-SNAPSHOT.jar



### API Details

`BasePath` /apportion-service/v2/[API endpoint]

##### Method
**a) Apportion Bill `POST /bill/_apportion` :** API (Bulk API) Apportions the paid amount in the field collectedAmount of billDetails in the bill
**b) Apportion demands `POST /demand/_apportion` :** API Apportions the advance amount from previous billing cycles in the latest demands


### Kafka Consumers

- NA


### Kafka Producers

- Following are the Producer topic.
- **save-apportion-bill-request** :- This topic is used to save the bill apportion request for audit.
- **save-apportion-bill-response** :- This topic is used to save the bill apportion response for audit.
- **save-apportion-demand-request** :- This topic is used to save the demand apportion request for audit.
- **save-apportion-demand-response** :- This topic is used to save the demand apportion response for audit.
Loading
Loading