> For the complete documentation index, see [llms.txt](https://docs.digit.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.digit.org/mgramseva/introducing-mgramseva/product-docs/functional-docs/advance-changes.md).

# Advance Changes

## **Overview** <a href="#overview" id="overview"></a>

Water Connection advance changes are added to allow the customer to pay the advance amount. This amount is adjusted when a new demand is generated. We can enable or disable advance based on the configuration.

## Pre-requisites <a href="#pre-requisites" id="pre-requisites"></a>

Before you proceed with the documentation, make sure the following pre-requisites are met -

* *Java 8*
* Kafka server is up and running
* egov-persister service is running and has the water service persister configs path added to it
* PSQL server is running and a database is created to store water connection/application data
* The following services should be up and running:
  * egov-persister
  * egov-mdms
  * ws-services
  * billing-service
  * ws-calculator
  * egov-apportion-service

## Key Functionalities <a href="#key-functionalities" id="key-functionalities"></a>

* Accepts advance amount during water connection creation and while collecting payment
* Creates demand for consumer type waterConnection-advance
* Adjusts the new demand with existing advance with apportion service

## Deployment Details <a href="#deployment-details" id="deployment-details"></a>

Deploy the latest version of ws-service, ws-calculator, billing-service, egov-apportion-service

### MDMS Configuration <a href="#mdms-configuration" id="mdms-configuration"></a>

**Billing Service tax head configuration**

{% code lineNumbers="true" %}

```
{
      "businessService": "ws-services-calculation",
      "code": "WS",
      "collectionModesNotAllowed": [
        "DD",
        "CHEQUE",
        "CARD",
        "OFFLINE_NEFT",
        "OFFLINE_RTGS",
        "POSTAL_ORDER",
        "ONLINE"
      ],
      "partPaymentAllowed": true,
      "isAdvanceAllowed": true,
      "demandUpdateTime": 86400000,
      "isVoucherCreationEnabled": false,
      "billGineiURL" : "egov-searcher/bill-genie/waterbills/_get",
      "isBillAmendmentEnabled":true
    }
```

{% endcode %}

**Tax head master service configuration**

{% code lineNumbers="true" %}

```
{
      "category": "ADVANCE_COLLECTION",
      "service": "WS",
      "name": "Ws advance carry forward",
      "code": "WS_ADVANCE_CARRYFORWARD",
      "isDebit": true,
      "isActualDemand": false,
      "order": "0",
      "isRequired": true,
      "IsBillamend": false
    },
```

{% endcode %}

### **Existing Service Code Changes**  **Billing service changes:**

* Creating a new bill for the advance amount in BillServiceV2.\
  Removing the following line while adding the bill objects to the list\
  `if (billAmount.compareTo(BigDecimal.ZERO) >= 0)`
* Passing Active status filter for demand search during apportioning in DemandService.\
  `DemandCriteria searchCriteria = DemandCriteria.builder().tenantId(tenantId)`\
  `.status(Demand.StatusEnum.ACTIVE.toString()).consumerCode(Collections.singleton(consumerCode)). businessService(businessService).build();`
* New Demand audit history API in Demandcontroller.\
  An API that returns the audit history of demandDetails. `demand/_history`

**Water service changes:**

* Create water connection API :\
  Adding a check for payment type advance. If advance, passing a boolean isAdvanceCollection to calculationRequest to water calculator service.
* Update water connection API:\
  Adding a check for payment type advance. If advance, passing a boolean isAdvanceCollection to calculationRequest to water calculator service.\
  Adding a check for advance in the validateUpdate method to set the current demand to CANCELLED.

**Water calculator service changes:**

* Calling estimation service getEstimationMap based on isAdvanceCalculation boolean. If true, reading taxAmount from criteria.getWaterConnection().getAdvance();
* Changes in getEstimatesForTax for a new taxHeadCode ADVANCE\_COLLECTION with value WS\_ADVANCE\_CARRYFORWARD
* Getting the advance amount in getCalculation with taxHeadCode ADVANCE\_COLLECTION\
  4.Calling generateDemand method based on isAdvanceCalculation. If true, create a demand object with consumerType “waterConnection-advance“.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.digit.org/mgramseva/introducing-mgramseva/product-docs/functional-docs/advance-changes.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
