# Quotation

## Concept

The performance of the quotation is better than the proposal and more scalable as being a separate microservice at the platform level.

It's critical for you to leverage quotation API, especially for digital distribution scenarios where the volume of data is big and the performance requirement is high.

## Policy JSON Structure

Mostly, you can use the same JSON body to call both proposal & quotation API. For details, see [Policy JSON Creation Guide](https://docs.insuremo.com/gi_insurance_service/json_creation).


## Transaction API

* `{{server}}/quotation/core/quotation/v1/calculate`
* `{{server}}/quotation/core/quotation/v1/calculateWithPersistence`
* `{{server}}/quotation/core/quotation/v1/create`
* `{{server}}/quotation/core/quotation/v1/load?quotationNo={{QuotationNo}}&withCodeDesc=Y`


The differences between the transaction APIs are as below:

| API                      | Rating | Save to DB | Convert to Policy |
|--------------------------|--------|------------|-------------------|
| quotation                | Y      | N    | N                 |
| persist                  | N      | Y    | Y                 |
| quotationWithPersistence | Y      | Y    | Y                 |


####  Quotation API

/quotation/core/quotation/v1/calculate

The quotation API will calculate the premium but not save it. So we can find premiums in response. 

###### Quotation - Request Sample

```json
{
    "ProductCode": "TBTI",
    "ProductVersion": "1.0",
    "ProposalDate": "2024-04-22T00:00:00",
    "EffectiveDate": "2024-04-22T00:00:00",
    "ExpiryDate": "2025-04-21T23:59:59",
    "AgentCode": "{{scCode}}",
    "BookCurrencyCode": "USD",
    "PremiumCurrencyCode": "USD",
    "OrgCode": "10002",
    "LocalCurrencyCode": "USD",
    "PremiumBookExchangeRate": 1,
    "PremiumLocalExchangeRate": 1,
    "PolicyLobList": [
        {
            "PolicyRiskList": [
                {
                    "CustomerName": "Customer",
                    "IdNo": "IdNo",
                    "IdType": "1",
                    "DateOfBirth": "1988-10-01",
                    "PolicyCoverageList": [
                        {
                            "ProductElementCode": "C100416",
                            "SumInsured": 300000
                        },
                        {
                            "ProductElementCode": "C100692",
                            "SumInsured": 300000
                        },
                        {
                            "ProductElementCode": "C100715",
                            "SumInsured": 300000
                        }
                    ],
                    "ProductElementCode": "R10007",
                    "RiskName": "Test1"
                }
            ],
            "ProductCode": "TBTI",
            "TotalInsuredCount": 1
        }
    ]
}
```

###### Quotation - Response Sample

```json
{
    "AdjustedPremium": 1004.4,
    "AgentCode": "XXXXX0000545XXXXX",
    "AnnualPremium": 930,
    "BeforeVatPremium": 930,
    "BookCurrencyCode": "USD",
    "BusinessCateCode": "1",
    "BusinessObjectId": 3517051304219,
    "CampaignDiscount": -0.1,
    "CampaignDiscountAmount": -93,
    "Commission": 279,
    "CommissionRate": 0.3,
    "DuePremium": 1004.4,
    "EffectiveDate": "2024-04-22",
    "ExpiryDate": "2025-04-21T23:59:59",
    "GrossPremium": 1004.4,
    "InterestRate": 0.05,
    "IsPremiumCalcSuccess": "Y",
    "LocalCurrencyCode": "USD",
    "OrgCode": "10002",
    "POIRate": 1,
    "PolicyLobList": [
        {
            "AdjustedPremium": 1004.4,
            "BeforeVatPremium": 930,
            "BusinessObjectId": 351861068,
            "DuePremium": 1004.4,
            "GrossPremium": 1004.4,
            "PolicyRiskList": [
                {
                    "AdjustedPremium": 1004.4,
                    "Age": 35,
                    "BeforeVatPremium": 930,
                    "BusinessObjectId": 351861075,
                    "CustomerName": "Customer",
                    "DateOfBirth": "1988-10-01",
                    "DuePremium": 1004.4,
                    "GrossPremium": 1004.4,
                    "IdNo": "IdNo",
                    "IdType": "1",
                    "PolicyCoverageList": [
                        {
                            "AdjustedPremium": 972,
                            "AnnualPremium": 900,
                            "BeforeVatPremium": 900,
                            "BusinessObjectId": 351861078,
                            "CampaignDiscountAmount": -90,
                            "CoverageName": "Accident Death & Dismemberment",
                            "DuePremium": 972,
                            "GrossPremium": 972,
                            "PolicyStatus": 2,
                            "ProductElementCode": "C100416",
                            "ProductElementId": 351926024,
                            "SequenceNumber": 1,
                            "SumInsured": 300000,
                            "TotalDiscountLoadingAmount": 0,
                            "UWLoadingAmount": 90,
                            "Vat": 72
                        },
                         .....skip....
                    ],
                    "PolicyStatus": 2,
                    "ProductElementCode": "R10007",
                    "ProductElementId": 351926021,
                    "RiskName": "Test1",
                    "SequenceNumber": 1,
                    "SumInsured": 900000,
                    "Vat": 74.4,
                    "TempData": {
                        "Mask-IdNo": "Jmf1vghdrScrTdpdeyKu7w==",
                        "IdNo": "Jmf1vghdrScrTdpdeyKu7w==",
                        "MaskAfter-IdNo": "IdNo"
                    }
                }
            ],
            "PolicyStatus": 2,
            "ProductCode": "TBTI",
            "ProductElementCode": "TBTI",
            "ProductElementId": 351925023,
            "ProductId": 351925022,
            "ProductLobId": 351925023,
            "SequenceNumber": 1,
            "SumInsured": 900000,
            "TechProductCode": "TR_POC",
            "TechProductId": 3516410623456,
            "TotalInsuredCount": 1,
            "Vat": 74.4
        }
    ],
    "PolicyStatus": 1,
    "PolicyType": "1",
    "PremCalcFactorHash": "20240507_162308_167,FsC+/iRzqE26aKlyS/oFVpSlDoM/bs+TgYSfYxwk75k=",
    "PremCalcResultHash": "20240507_162308_292,kN3/EM7LmI3+vdlbFmeKRE6B5toJKsN3eNWcgzokIdo=",
    "PremiumBookExchangeRate": 1,
    "PremiumCurrencyCode": "USD",
    "PremiumInterest": 46.5,
    "PremiumLocalExchangeRate": 1,
    "ProductCode": "TBTI",
    "ProductId": 351925022,
    "ProductVersion": "1.0",
    "ProposalDate": "2024-04-22",
    "ProposalStatus": "1",
    "SchemaVersion": 2,
    "SumInsured": 900000,
    "TaxInterest": 3.72,
    "TechProductCode": "TR_POC",
    "TechProductId": 3516410623456,
    "TotalDiscountLoading": 0,
    "TotalDiscountLoadingAmount": 0,
    "TotalInterest": 50.22,
    "TotalPremium": 1054.62,
    "UWLoading": 0.1,
    "UWLoadingAmount": 93,
    "Vat": 74.4,
    "VatRate": 0.08,
    "VersionSeq": 0
}
```

#### Persist API

/quotation/core/quotation/v1/create

The quotationWithPersistence API will save it, and convert the quotation to policy. So it returns **PolicyId** & **QuotationNo** in response **without** premiums.

###### Persist - Request Sample

```json
{
    "ProductCode": "TBTI",
    "ProductVersion": "1.0",
    "ProposalDate": "2024-04-22T00:00:00",
    "EffectiveDate": "2024-04-22T00:00:00",
    "ExpiryDate": "2025-04-21T23:59:59",
    "AgentCode": "{{scCode}}",
    "BookCurrencyCode": "USD",
    "PremiumCurrencyCode": "USD",
    "OrgCode": "10002",
    "LocalCurrencyCode": "USD",
    "PremiumBookExchangeRate": 1,
    "PremiumLocalExchangeRate": 1,
    "PolicyLobList": [
        {
            "PolicyRiskList": [
                {
                    "CustomerName": "Customer",
                    "IdNo": "IdNo",
                    "IdType": "1",
                    "DateOfBirth": "1988-10-01",
                    "PolicyCoverageList": [
                        {
                            "ProductElementCode": "C100416",
                            "SumInsured": 300000
                        },
                         .....skip....
                    ],
                    "ProductElementCode": "R10007",
                    "RiskName": "Test1"
                }
            ],
            "ProductCode": "TBTI",
            "TotalInsuredCount": 1
        }
    ]
}
```

###### Persist - Response Sample

```json
{
    "AgentCode": "XXXXX0000545XXXXX",
    "BookCurrencyCode": "USD",
    "BusinessCateCode": "1",
    "BusinessObjectId": 3517051304219,
    "EffectiveDate": "2024-04-22",
    "ExpiryDate": "2025-04-21T23:59:59",
    "LocalCurrencyCode": "USD",
    "OrgCode": "10002",
    "PolicyElementId": 10430420002,
    "PolicyId": "10430420002,5DD746B2AA5BD3756490D23DCE4F7C23",
    "PolicyLobList": [
        {
            "BusinessObjectId": 351861068,
            "PolicyRiskList": [
                {
                    "BusinessObjectId": 351861075,
                    "CustomerName": "Customer",
                    "DateOfBirth": "1988-10-01",
                    "IdNo": "IdNo",
                    "IdType": "1",
                    "PolicyCoverageList": [
                        {
                            "BusinessObjectId": 351861078,
                            "PolicyStatus": 2,
                            "ProductElementCode": "C100416",
                            "ProductElementId": 351926024,
                            "SequenceNumber": 1,
                            "SumInsured": 300000
                        },
                         .....skip....
                    ],
                    "PolicyStatus": 2,
                    "ProductElementCode": "R10007",
                    "ProductElementId": 351926021,
                    "RiskName": "Test1",
                    "SequenceNumber": 1,
                    "TempData": {
                        "Mask-IdNo": "Jmf1vghdrScrTdpdeyKu7w==",
                        "IdNo": "Jmf1vghdrScrTdpdeyKu7w==",
                        "MaskAfter-IdNo": "IdNo"
                    }
                }
            ],
            "PolicyStatus": 2,
            "ProductCode": "TBTI",
            "ProductElementCode": "TBTI",
            "ProductElementId": 351925023,
            "ProductId": 351925022,
            "ProductLobId": 351925023,
            "SequenceNumber": 1,
            "TechProductCode": "TR_POC",
            "TechProductId": 3516410623456,
            "TotalInsuredCount": 1
        }
    ],
    "PolicyStatus": 1,
    "PolicyType": "1",
    "PremiumBookExchangeRate": 1,
    "PremiumCurrencyCode": "USD",
    "PremiumLocalExchangeRate": 1,
    "ProductCode": "TBTI",
    "ProductId": 351925022,
    "ProductVersion": "1.0",
    "ProposalDate": "2024-04-22",
    "ProposalStatus": "1",
    "QuotationDate": "2024-05-07T16:34:53",
    "QuotationNo": "QTBTI000001790022",
    "SchemaVersion": 2,
    "TechProductCode": "TR_POC",
    "TechProductId": 3516410623456,
    "VersionSeq": 0
}

```

#### QuotationWithPersistence API

/quotation/core/quotation/v1/calculateWithPersistence

The quotationWithPersistence API will calculate the premium and save it, then convert the quotation to policy. So it returns **PolicyId** & **QuotationNo** in response to premiums.

###### QuotationWithPersistence - Request Sample

```json
{
    "ProductCode": "TBTI",
    "ProductVersion": "1.0",
    "ProposalDate": "2024-04-22T00:00:00",
    "EffectiveDate": "2024-04-22T00:00:00",
    "ExpiryDate": "2025-04-21T23:59:59",
    "AgentCode": "{{scCode}}",
    "BookCurrencyCode": "USD",
    "PremiumCurrencyCode": "USD",
    "OrgCode": "10002",
    "LocalCurrencyCode": "USD",
    "PremiumBookExchangeRate": 1,
    "PremiumLocalExchangeRate": 1,
    "PolicyLobList": [
        {
            "PolicyRiskList": [
                {
                    "CustomerName": "Customer",
                    "IdNo": "IdNo",
                    "IdType": "1",
                    "DateOfBirth": "1988-10-01",
                    "PolicyCoverageList": [
                        {
                            "ProductElementCode": "C100416",
                            "SumInsured": 300000
                        },
                         .....skip....
                    ],
                    "ProductElementCode": "R10007",
                    "RiskName": "Test1"
                }
            ],
            "ProductCode": "TBTI",
            "TotalInsuredCount": 1
        }
    ]
}
```

###### QuotationWithPersistence - Response Sample

```json
{
    "AdjustedPremium": 1004.4,
    "AgentCode": "XXXXX0000545XXXXX",
    "AnnualPremium": 930,
    "BeforeVatPremium": 930,
    "BookCurrencyCode": "USD",
    "BusinessCateCode": "1",
    "BusinessObjectId": 3517051304219,
    "CampaignDiscount": -0.1,
    "CampaignDiscountAmount": -93,
    "Commission": 279,
    "CommissionRate": 0.3,
    "DuePremium": 1004.4,
    "EffectiveDate": "2024-04-22",
    "ExpiryDate": "2025-04-21T23:59:59",
    "GrossPremium": 1004.4,
    "InterestRate": 0.05,
    "IsPremiumCalcSuccess": "Y",
    "LocalCurrencyCode": "USD",
    "OrgCode": "10002",
    "POIRate": 1,
    "PolicyElementId": 10430410002,
    "PolicyId": "10430410002,78E9887B1558B5FDBE296DCD8BC0A575",
    "PolicyLobList": [
        {
            "AdjustedPremium": 1004.4,
            "BeforeVatPremium": 930,
            "BusinessObjectId": 351861068,
            "DuePremium": 1004.4,
            "GrossPremium": 1004.4,
            "PolicyRiskList": [
                {
                    "AdjustedPremium": 1004.4,
                    "Age": 35,
                    "BeforeVatPremium": 930,
                    "BusinessObjectId": 351861075,
                    "CustomerName": "Customer",
                    "DateOfBirth": "1988-10-01",
                    "DuePremium": 1004.4,
                    "GrossPremium": 1004.4,
                    "IdNo": "IdNo",
                    "IdType": "1",
                    "PolicyCoverageList": [
                        {
                            "AdjustedPremium": 972,
                            "AnnualPremium": 900,
                            "BeforeVatPremium": 900,
                            "BusinessObjectId": 351861078,
                            "CampaignDiscountAmount": -90,
                            "CoverageName": "Accident Death & Dismemberment",
                            "DuePremium": 972,
                            "GrossPremium": 972,
                            "PolicyStatus": 2,
                            "ProductElementCode": "C100416",
                            "ProductElementId": 351926024,
                            "SequenceNumber": 1,
                            "SumInsured": 300000,
                            "TotalDiscountLoadingAmount": 0,
                            "UWLoadingAmount": 90,
                            "Vat": 72
                        },
                         .....skip....
                    ],
                    "PolicyStatus": 2,
                    "ProductElementCode": "R10007",
                    "ProductElementId": 351926021,
                    "RiskName": "Test1",
                    "SequenceNumber": 1,
                    "SumInsured": 900000,
                    "Vat": 74.4,
                    "TempData": {
                        "Mask-IdNo": "Jmf1vghdrScrTdpdeyKu7w==",
                        "IdNo": "Jmf1vghdrScrTdpdeyKu7w==",
                        "MaskAfter-IdNo": "IdNo"
                    }
                }
            ],
            "PolicyStatus": 2,
            "ProductCode": "TBTI",
            "ProductElementCode": "TBTI",
            "ProductElementId": 351925023,
            "ProductId": 351925022,
            "ProductLobId": 351925023,
            "SequenceNumber": 1,
            "SumInsured": 900000,
            "TechProductCode": "TR_POC",
            "TechProductId": 3516410623456,
            "TotalInsuredCount": 1,
            "Vat": 74.4
        }
    ],
    "PolicyStatus": 1,
    "PolicyType": "1",
    "PremCalcFactorHash": "20240507_163329_160,FsC+/iRzqE26aKlyS/oFVpSlDoM/bs+TgYSfYxwk75k=",
    "PremCalcResultHash": "20240507_163329_292,otaReWIAf3zgsDJTO0hZa2GpZUGTlvt8KhA9zkRtM0w=",
    "PremiumBookExchangeRate": 1,
    "PremiumCurrencyCode": "USD",
    "PremiumInterest": 46.5,
    "PremiumLocalExchangeRate": 1,
    "ProductCode": "TBTI",
    "ProductId": 351925022,
    "ProductVersion": "1.0",
    "ProposalDate": "2024-04-22",
    "ProposalStatus": "1",
    "QuotationDate": "2024-05-07T16:33:30",
    "QuotationNo": "QTBTI000001790127",
    "SchemaVersion": 2,
    "SumInsured": 900000,
    "TaxInterest": 3.72,
    "TechProductCode": "TR_POC",
    "TechProductId": 3516410623456,
    "TotalDiscountLoading": 0,
    "TotalDiscountLoadingAmount": 0,
    "TotalInterest": 50.22,
    "TotalPremium": 1054.62,
    "UWLoading": 0.1,
    "UWLoadingAmount": 93,
    "Vat": 74.4,
    "VatRate": 0.08,
    "VersionSeq": 0
}
```



## Validate/AttachElement/autoUnderWriting API

* `{{server}}/quotation/core/quotation/v1/validate?eventCode={{eventCode}}`
* `{{server}}/quotation/core/quotation/v1/attachElement?eventCode={{eventCode}}`
* `{{server}}/quotation/core/quotation/v1/autoUnderWriting`

####  Validate API

/quotation/core/quotation/v1/validate

The validate API will validate the policy JSON match the product structure and DD fields's definition.
It is the same as /proposal/core/proposal/v1/validate. For more information, see [Validation API](https://docs.insuremo.com/gi_insurance_service/policy_rule_api#validation-api).

###### Validate - Request Sample

```json
{
    "BeforeVatPremium": 121.5,
    "BusinessCateCode": "1",
    "Commission": 6.075,
    "DuePremium": 130,
    "EffectiveDate": null,
    "ExpiryDate": "2019-04-24T23:59:59",
    "IsPremiumCalcSuccess": "Y",
    "PolicyLobList": [
        {
            "PolicyRiskList": [
                {
                    "CustomerName": "Customer",
                    "DateOfBirth": "1988-10-01",
                    "IdNo": "IdNo",
                    "IdType": "1",
                    "PolicyCoverageList": [
                        {
                            "DuePremium": 100,
                            "ProductElementCode": "C100416",
                            "SumInsured": 300000,
                            "VersionSeq": 1
                        },
                         .....skip....
                    ],
                    "ProductElementCode": "R10007",
                    "RiskName": "InsuredName",
                    "VersionSeq": 1
                }
            ],
            "ProductCode": "TBTI",
            "ProductElementCode": "TBTI",
            "ProductId": 351925022,
            "ProductLobId": 351925023,
            "TechProductCode": "TR_POC",
            "TechProductId": 3516410623456,
            "TotalInsuredCount": 1,
            "VersionSeq": 1
        }
    ],
    "PolicyType": "1",
    "ProductCode": "TBTI",
    "ProductId": 351925022,
    "ProductVersion": "1.0",
    "ProposalDate": "2019-04-22",
    "TechProductCode": "TR_POC",
    "TechProductId": 3516410623456,
    "Vat": 8.5,
    "VersionSeq": 1
}
```

###### Validate - Response Sample

If validation passes, it will return the 204. No content will be returned.

The validation message is as below.

```json
{
    "timestamp": "2024-05-07T16:09:21",
    "timestampServer": "2024-05-07T08:09:21",
    "traceId": "XXXXX713c22421XXXXX59d0357bXXXXX",
    "traceIdContainer": null,
    "messages": [
        {
            "code": "MO-PA-Validation-B4002",
            "message": "Under \"Policy-POLICY\", field \"EffectiveDate\" is mandatory. Please input the field with proper value."
        },
        {
            "code": "MO-PA-Validation-B4002",
            "message": "Under \"Policy-POLICY\", field \"OrgCode\" is mandatory. Please input the field with proper value."
        },
        {
            "code": "MO-PA-Validation-B4003",
            "message": "Under \"PolicyCustomer-PolicyCustomer\", field \"IdType\" is mapped with the code table \"BR_IDType\", the value \"1111111\" is not in the code table value range."
        },
        {
            "code": "MO-PA-Validation-B4005",
            "message": "Under \"PolicyCustomer-PolicyCustomer\", field \"IdType\" , value \"1111111\", the length \"7\" of the value is larger than the definition max length \"3\"."
        }
    ],
    "status": 422,
    "code": "MO-PA-Validation-B4000",
    "message": "Policy Validation Error"
}
```


#### AttachElement API

/quotation/core/quotation/v1/attachElement

The attachElement API will attach the policy element according to the product configuration and rules.
It is the same as /proposal/core/proposal/v1/attachElement. For more information, see [Attachment-API](https://docs.insuremo.com/gi_insurance_service/policy_rule_api#form-clause-or-element-attachment-api).

###### AttachElement - Request Sample

```json
{
    "ProductCode": "TBTI",
    "ProductVersion": "1.0",
    "ProposalDate": "2024-04-22T00:00:00",
    "EffectiveDate": "2024-04-22T00:00:00",
    "ExpiryDate": "2025-04-21T23:59:59",
    "AgentCode": "{{scCode}}",
    "BookCurrencyCode": "USD",
    "PremiumCurrencyCode": "USD",
    "OrgCode": "10002",
    "LocalCurrencyCode": "USD",
    "PremiumBookExchangeRate": 1,
    "PremiumLocalExchangeRate": 1,
    "PolicyLobList": [
        {
            "PolicyRiskList": [
                {
                    "CustomerName": "Customer",
                    "IdNo": "IdNo",
                    "IdType": "1",
                    "DateOfBirth": "1988-10-01",
                    "PolicyCoverageList": [
                        {
                            "ProductElementCode": "C100416",
                            "SumInsured": 300000
                        },
                         .....skip....
                    ],
                    "ProductElementCode": "R10007",
                    "RiskName": "Test1"
                }
            ],
            "ProductCode": "TBTI",
            "TotalInsuredCount": 1
        }
    ]
}
```

###### AttachElement - Response Sample

```json
{
    "AgentCode": "XXXXX0000545XXXXX",
    "BookCurrencyCode": "USD",
    "BusinessCateCode": "1",
    "BusinessObjectId": 3517051304219,
    "EffectiveDate": "2024-04-22",
    "ExpiryDate": "2025-04-21T23:59:59",
    "LocalCurrencyCode": "USD",
    "OrgCode": "10002",
    "PolicyLobList": [
        {
            "BusinessObjectId": 351861068,
            "PolicyRiskList": [
                {
                    "BusinessObjectId": 351861075,
                    "CustomerName": "Customer",
                    "DateOfBirth": "1988-10-01",
                    "IdNo": "IdNo",
                    "IdType": "1",
                    "PolicyCoverageList": [
                        {
                            "BusinessObjectId": 351861078,
                            "PolicyStatus": 2,
                            "ProductElementCode": "C100416",
                            "ProductElementId": 351926024,
                            "SequenceNumber": 1,
                            "SumInsured": 300000
                        },
                         .....skip....
                    ],
                    "PolicyStatus": 2,
                    "ProductElementCode": "R10007",
                    "ProductElementId": 351926021,
                    "RiskName": "Test1",
                    "SequenceNumber": 1,
                    "TempData": {
                        "Mask-IdNo": "Jmf1vghdrScrTdpdeyKu7w==",
                        "IdNo": "Jmf1vghdrScrTdpdeyKu7w==",
                        "MaskAfter-IdNo": "IdNo"
                    }
                }
            ],
            "PolicyStatus": 2,
            "ProductCode": "TBTI",
            "ProductElementCode": "TBTI",
            "ProductElementId": 351925023,
            "ProductId": 351925022,
            "ProductLobId": 351925023,
            "SequenceNumber": 1,
            "TechProductCode": "TR_POC",
            "TechProductId": 3516410623456,
            "TotalInsuredCount": 1
        }
    ],
    "PolicyType": "1",
    "PremiumBookExchangeRate": 1,
    "PremiumCurrencyCode": "USD",
    "PremiumLocalExchangeRate": 1,
    "ProductCode": "TBTI",
    "ProductId": 351925022,
    "ProductVersion": "1.0",
    "ProposalDate": "2024-04-22",
    "ProposalStatus": "1",
    "SchemaVersion": 2,
    "TechProductCode": "TR_POC",
    "TechProductId": 3516410623456,
    "VersionSeq": 0
}
```



#### Underwriting API

/quotation/core/quotation/v1/autoUnderWriting

The underwriting API will check the underwriting rules. For more details, see [Underwriting API](https://docs.insuremo.com/gi_insurance_service/policy_rule_api#underwriting-api).

###### Underwriting - Request Sample

```json
{
    "ProductCode": "TBTI",
    "ProductVersion": "1.0",
    "ProposalDate": "2024-04-22T00:00:00",
    "EffectiveDate": "2024-04-22T00:00:00",
    "ExpiryDate": "2025-04-21T23:59:59",
    "AgentCode": "{{scCode}}",
    "BookCurrencyCode": "USD",
    "PremiumCurrencyCode": "USD",
    "ProposalStatus":"1",
    "OrgCode": "10002",
    "LocalCurrencyCode": "USD",
    "PremiumBookExchangeRate": 1,
    "PremiumLocalExchangeRate": 1,
    "PolicyLobList": [
        {
            "PolicyRiskList": [
                {
                    "CustomerName": "Customer",
                    "IdNo": "IdNo",
                    "IdType": "1",
                    "DateOfBirth": "1988-10-01",
                    "PolicyCoverageList": [
                        {
                            "ProductElementCode": "C100416",
                            "SumInsured": 300000
                        },
                         .....skip....
                    ],
                    "ProductElementCode": "R10007",
                    "RiskName": "Test1"
                }
            ],
            "ProductCode": "TBTI",
            "TotalInsuredCount": 1
        }
    ]
}
```

###### Underwriting - Response Sample

```json
{
    "MessageList": [
        {
            "Code": "MO-PA-UW-BLIMITAGE18",
            "Message": "Not reach minimum age(18) to be included, need underwriting!",
            "RuleName": "Insured Age Check"
        }
    ],
    "Model": {
        "AgentCode": "XXXXX0000545XXXXX",
        "AutoUwResultCode": "2",
        "BookCurrencyCode": "USD",
        "BusinessCateCode": "1",
        "BusinessObjectId": 3517051304219,
        "EffectiveDate": "2024-04-22",
        "ExpiryDate": "2025-04-21T23:59:59",
        "LocalCurrencyCode": "USD",
        "MaxUwLevelCode": "0",
        "OrgCode": "10002",
        "PolicyElementId": 10430420003,
        "PolicyId": "10430420003,E5D8984C2E8A48CCE73613A622820226",
        "PolicyLobList": [
            {
                "BusinessObjectId": 351861068,
                "PolicyRiskList": [
                    {
                        "BusinessObjectId": 351861075,
                        "CustomerName": "Customer",
                        "DateOfBirth": "1988-10-01",
                        "IdNo": "IdNo",
                        "IdType": "1",
                        "PolicyCoverageList": [
                            {
                                "BusinessObjectId": 351861078,
                                "PolicyStatus": 2,
                                "ProductElementCode": "C100416",
                                "ProductElementId": 351926024,
                                "SequenceNumber": 1,
                                "SumInsured": 300000
                            }
                            .....skip....
                        ],
                        "PolicyStatus": 2,
                        "ProductElementCode": "R10007",
                        "ProductElementId": 351926021,
                        "RiskName": "Test1",
                        "SequenceNumber": 1,
                        "TempData": {
                            "Mask-IdNo": "Jmf1vghdrScrTdpdeyKu7w==",
                            "IdNo": "Jmf1vghdrScrTdpdeyKu7w==",
                            "MaskAfter-IdNo": "IdNo"
                        }
                    }
                ],
                "PolicyStatus": 2,
                "ProductCode": "TBTI",
                "ProductElementCode": "TBTI",
                "ProductElementId": 351925023,
                "ProductId": 351925022,
                "ProductLobId": 351925023,
                "SequenceNumber": 1,
                "TechProductCode": "TR_POC",
                "TechProductId": 3516410623456,
                "TotalInsuredCount": 1
            }
        ],
        "PolicyStatus": 1,
        "PolicyType": "1",
        "PremiumBookExchangeRate": 1,
        "PremiumCurrencyCode": "USD",
        "PremiumLocalExchangeRate": 1,
        "ProductCode": "TBTI",
        "ProductId": 351925022,
        "ProductVersion": "1.0",
        "ProposalDate": "2024-04-22",
        "ProposalStatus": "5",
        "QuotationDate": "2024-05-07T16:44:59",
        "QuotationNo": "QTBTI000001790023",
        "SchemaVersion": 2,
        "TechProductCode": "TR_POC",
        "TechProductId": 3516410623456,
        "VersionSeq": 0
    },
    "Status": "Fail"
}
```

#### Load API

/quotation/core/quotation/v1/load

`GET {{server}}/quotation/core/quotation/v1/load?quotationNo={{QuotationNo}}&withCodeDesc=Y`

 The withCodeDesc is a flag to load the field's value-related description, the default is **N**. For more details about withCodeDesc, see [Load Policy API with Code Table Description](https://docs.insuremo.com/gi_insurance_service/policy_transaction_api#load-policy-api-with-code-table-description1).


###### Load - Response Sample

```json
{
    "AdjustedPremium": 1004.4,
    "AgentCode": "XXXXX0000545XXXXX",
    "AnnualPremium": 930,
    "BeforeVatPremium": 930,
    "BookCurrencyCode": "USD",
    "BusinessCateCode": "1",
    "BusinessObjectId": 3517051304219,
    "CampaignDiscount": -0.1,
    "CampaignDiscountAmount": -93,
    "Commission": 279,
    "CommissionRate": 0.3,
    "DuePremium": 1004.4,
    "EffectiveDate": "2024-04-22",
    "ExpiryDate": "2025-04-21T23:59:59",
    "GrossPremium": 1004.4,
    "InterestRate": 0.05,
    "IsPremiumCalcSuccess": "Y",
    "LocalCurrencyCode": "USD",
    "OrgCode": "10002",
    "POIRate": 1,
    "PolicyId": "10430410002,78E9887B1558B5FDBE296DCD8BC0A575",
    "PolicyLobList": [
        {
            "AdjustedPremium": 1004.4,
            "BeforeVatPremium": 930,
            "BusinessObjectId": 351861068,
            "DuePremium": 1004.4,
            "GrossPremium": 1004.4,
            "PolicyRiskList": [
                {
                    "AdjustedPremium": 1004.4,
                    "Age": 35,
                    "BeforeVatPremium": 930,
                    "BusinessObjectId": 351861075,
                    "CustomerName": "Customer",
                    "DateOfBirth": "1988-10-01",
                    "DuePremium": 1004.4,
                    "GrossPremium": 1004.4,
                    "IdNo": "IdNo",
                    "IdType": "1",
                    "PolicyCoverageList": [
                        {
                            "AdjustedPremium": 972,
                            "AnnualPremium": 900,
                            "BeforeVatPremium": 900,
                            "BusinessObjectId": 351861078,
                            "CampaignDiscountAmount": -90,
                            "CoverageName": "Accident Death & Dismemberment",
                            "DuePremium": 972,
                            "GrossPremium": 972,
                            "PolicyStatus": 2,
                            "ProductElementCode": "C100416",
                            "ProductElementId": 351926024,
                            "SequenceNumber": 1,
                            "SumInsured": 300000,
                            "TotalDiscountLoadingAmount": 0,
                            "UWLoadingAmount": 90,
                            "Vat": 72
                        },
                         .....skip....
                    ],
                    "PolicyStatus": 2,
                    "ProductElementCode": "R10007",
                    "ProductElementId": 351926021,
                    "RiskName": "Test1",
                    "SequenceNumber": 1,
                    "SumInsured": 900000,
                    "Vat": 74.4,
                    "TempData": {
                        "Mask-IdNo": "Jmf1vghdrScrTdpdeyKu7w==",
                        "IdNo": "Jmf1vghdrScrTdpdeyKu7w==",
                        "MaskAfter-IdNo": "IdNo"
                    }
                }
            ],
            "PolicyStatus": 2,
            "ProductCode": "TBTI",
            "ProductElementCode": "TBTI",
            "ProductElementId": 351925023,
            "ProductId": 351925022,
            "ProductLobId": 351925023,
            "SequenceNumber": 1,
            "SumInsured": 900000,
            "TechProductCode": "TR_POC",
            "TechProductId": 3516410623456,
            "TotalInsuredCount": 1,
            "Vat": 74.4
        }
    ],
    "PolicyStatus": 1,
    "PolicyType": "1",
    "PremCalcFactorHash": "20240507_163329_160,FsC+/iRzqE26aKlyS/oFVpSlDoM/bs+TgYSfYxwk75k=",
    "PremCalcResultHash": "20240507_163329_292,otaReWIAf3zgsDJTO0hZa2GpZUGTlvt8KhA9zkRtM0w=",
    "PremiumBookExchangeRate": 1,
    "PremiumCurrencyCode": "USD",
    "PremiumInterest": 46.5,
    "PremiumLocalExchangeRate": 1,
    "ProductCode": "TBTI",
    "ProductId": 351925022,
    "ProductVersion": "1.0",
    "ProposalDate": "2024-04-22",
    "ProposalStatus": "5",
    "QuotationDate": "2024-05-07T16:33:30",
    "QuotationNo": "QTBTI000001790127",
    "SchemaVersion": 2,
    "SumInsured": 900000,
    "TaxInterest": 3.72,
    "TechProductCode": "TR_POC",
    "TechProductId": 3516410623456,
    "TotalDiscountLoading": 0,
    "TotalDiscountLoadingAmount": 0,
    "TotalInterest": 50.22,
    "TotalPremium": 1054.62,
    "UWLoading": 0.1,
    "UWLoadingAmount": 93,
    "Vat": 74.4,
    "VatRate": 0.08,
    "VersionSeq": 0
}
```


## Quotation Query API

### Quotation Query - Business Usage

* Query quotation via specified search criteria
* Due to performance considerations, the ES index is not used and you can only extend 6 fixed indexes (3 unique & 3 non-unique) via the data dictionary.
* The saved quotation can be queried.

### Quotation Query - API Path

`{{server}}/quotation/core/quotation/v1/query`

#### Static Search Criteria

- `AgentCode`: String
- `CustomerName`: String
- `CustomerNo`: String (CUSTOMER_NO)
- `DuePremiumStart`: BigDecimal
- `DuePremiumEnd`: BigDecimal
- `EffectiveDateStart`: LocalDateTime
- `EffectiveDateEnd`: LocalDateTime
- `IsSubmitted`: "N"
- `PageSize`:  Integer
- `PageNumber`: Integer
- `ProductCode`: String
- `QuotationDateStart`: LocalDateTime
- `QuotationDateEnd`: LocalDateTime
- `QuotationNo`: String
- `TechProductCode`: String
- **DynamicProperties**:  Map<String,Object>

#### Dynamic Search Criteria - Data Dictionary


The Dynamic fields are set under DD object "**Policy-POLICY**".


<div class="docs-tip"><span class="docs-admonitions-text">tip</span>

* Max 3 ordinary fields with "**Is Unique Index=No** and max 3 unique index fields with property "**Is Unique Index=Yes**" can be set for Policy. Adding more than 3 index fields will cause the system to produce errors like "More than 3 ordinary index fields for Object" or "More than 3 unique index fields for Object".
* If the field is indexed, the length is limited to 50 max. The unique index fields for each policy must be unique.
* Only String/Integer/Long type fields can be indexed.

</div>

![Quotation Index Fields](./image/product_cfg_sample/quotation_index_field_001.png)


#### Quotation Query - Request Sample1

The Test001/Test002/Test006 are fields added under Policy-POLICY with indexed related flags.

The indexed fields only work for newly created quotations. For existing quotations, if you need to support a new indexed field, please load the quotation and save it again (api `/quotation/core/quotation/v1/create`).

```
{
    "ProductCode": "TBTI",
    "QuotationDateStart": "2024-02-22",
    "IsSubmitted": "N",
    "CustomerName": "Apitest202111",
    "DynamicProperties": {
        "Test001": "Test001",
        "Test002": "Test002",
        "Test006": "Test006"
    },
    "PageSize": 5,
    "PageNumber": 0
}
```


#### Quotation Query - Response Sample1

```
{
    "ElementsInCurrentPage": [
        {
            "AdjustedPremium": 1004.4,
            "AgentCode": "XXXXX0000545XXXXX",
            "AnnualPremium": 930,
            "BeforeVatPremium": 930,
            "BookCurrencyCode": "USD",
            "BusinessCateCode": "1",
            "BusinessObjectCode": "POLICY",
            "BusinessObjectId": 3517051304219,
            "CampaignDiscount": -0.1,
            "CampaignDiscountAmount": -93,
            "Commission": 279,
            "CommissionRate": 0.3,
            "CustomerName": "Apitest202111",
            "DuePremium": 1004.4,
            "EffectiveDate": "2024-04-22",
            "ExpiryDate": "2025-04-21T23:59:59",
            "GrossPremium": 1004.4,
            "InterestRate": 0.05,
            "IsPremiumCalcSuccess": "Y",
            "IsSubmitted": "N",
            "LocalCurrencyCode": "USD",
            "OrgCode": "10002",
            "POIRate": 1,
            "PolicyId": "10387340002,BE16DCD70ED4E13A54C595E667D0CEFD",
            "PolicyStatus": 1,
            "PolicyType": "1",
            "PremCalcFactorHash": "20240428_112341_120,FsC+/iRzqE26aKlyS/oFVpSlDoM/bs+TgYSfYxwk75k=",
            "PremCalcResultHash": "20240428_112341_128,X5BMA8gJexu4hmCj/aVNG0xfbXG7eisJh3kJeaLB7hI=",
            "PremiumBookExchangeRate": 1,
            "PremiumCurrencyCode": "USD",
            "PremiumInterest": 46.5,
            "PremiumLocalExchangeRate": 1,
            "ProductCode": "TBTI",
            "ProductId": 351925022,
            "ProductVersion": "1.0",
            "ProposalDate": "2024-04-22",
            "ProposalStatus": "5",
            "QuotationDate": "2024-04-28T11:23:41",
            "QuotationId": 10387340002,
            "QuotationNo": "QTBTI000001790107",
            "SchemaVersion": 2,
            "SumInsured": 900000,
            "TaxInterest": 3.72,
            "TechProductCode": "TR_POC",
            "TechProductId": 3516410623456,
            "Test001": "Test001",
            "Test002": "Test002",
            "Test003": 1,
            "Test004": 1,
            "Test005": "Test005",
            "Test006": "Test006",
            "TotalDiscountLoading": 0,
            "TotalDiscountLoadingAmount": 0,
            "TotalInterest": 50.22,
            "TotalPremium": 1054.62,
            "UWLoading": 0.1,
            "UWLoadingAmount": 93,
            "Vat": 74.4,
            "VatRate": 0.08,
            "VersionSeq": 0
        }
    ],
    "NumberOfElementsInCurrentPage": 1,
    "PageQuery": {
        "CustomerName": "Apitest202111",
        "IsSubmitted": "N",
        "PageNumber": 1,
        "PageSize": 5,
        "ProductCode": "TBTI",
        "QuotationDateStart": "2024-02-22",
        "Test001": "Test001",
        "Test002": "Test002",
        "Test006": "Test006"
    },
    "TotalElements": 1,
    "TotalPages": 1
}

```

#### Quotation Query - Request Sample2

```
{
    "ProductCode": "TBTI",
    "QuotationDateStart": "2024-02-22",
    "IsSubmitted": "N",
    "CustomerName": "Apitest202111",
    "DynamicProperties": {
        
        "Test005": "Test0051",
        "Test006": "Test0061"
    },
    "PageSize": 5,
    "PageNumber": 0
}
```

#### Quotation Query - Response Sample2

```
{
    "ElementsInCurrentPage": [
        {
            "AgentCode": "XXXXX0000545XXXXX",
            "BookCurrencyCode": "USD",
            "BusinessCateCode": "1",
            "BusinessObjectCode": "POLICY",
            "BusinessObjectId": 3517051304219,
            "CustomerName": "Apitest202111",
            "EffectiveDate": "2024-04-22",
            "ExpiryDate": "2025-04-21T23:59:59",
            "IsSubmitted": "N",
            "LocalCurrencyCode": "USD",
            "OrgCode": "10002",
            "PolicyId": "10387340006,3F8601E69CC9ECFAB363EACE899108F4",
            "PolicyStatus": 1,
            "PolicyType": "1",
            "PremiumBookExchangeRate": 1,
            "PremiumCurrencyCode": "USD",
            "PremiumLocalExchangeRate": 1,
            "ProductCode": "TBTI",
            "ProductId": 351925022,
            "ProductVersion": "1.0",
            "ProposalDate": "2024-04-22",
            "ProposalStatus": "5",
            "QuotationDate": "2024-04-28T11:32:55",
            "QuotationId": 10387340006,
            "QuotationNo": "QTBTI000001790113",
            "SchemaVersion": 2,
            "TechProductCode": "TR_POC",
            "TechProductId": 3516410623456,
            "Test001": "Test0015",
            "Test002": "Test0025",
            "Test003": 15,
            "Test004": 11,
            "Test005": "Test0051",
            "Test006": "Test0061",
            "VersionSeq": 0
        },
         .....skip....
    ],
    "NumberOfElementsInCurrentPage": 4,
    "PageQuery": {
        "CustomerName": "Apitest202111",
        "IsSubmitted": "N",
        "PageNumber": 1,
        "PageSize": 5,
        "ProductCode": "TBTI",
        "QuotationDateStart": "2024-02-22",
        "Test005": "Test0051",
        "Test006": "Test0061"
    },
    "TotalElements": 4,
    "TotalPages": 1
}

```



## Quotation Housekeeping API

* `GET {{server}}/quotation/core/quotation/v1/queryForHouseKeepingByUpdateTime?maxRecords=300&isExcludeSubmitted=Y&maxUpdateTime=2023-09-25T16:45:29&minUpdateTime=2023-09-23T16:10:29`
* `{{server}}/quotation/core/quotation/v1/batchDeletePolicyAtQuotationTable?needIndex=Y`


#### queryForHouseKeepingByUpdateTime

The **queryForHouseKeepingByUpdateTime** API is designed to get the quotations required to be deleted.

###### Quotation Housekeeping - Response Sample

```json
[
    22855036601,
    22855036602
]
```

#### batchDeletePolicyAtQuotationTable

The **batchDeletePolicyAtQuotationTable** API is designed to delete the quotations.

###### batchDeletePolicyAtQuotationTable - Request Sample

```json
[
    22855036601,
    22855036602
]
```

###### batchDeletePolicyAtQuotationTable - Response Sample

2 means the count deleted.

`2`

