Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add API getDebtPositionByIUV [PAGOPA-1744] #233

Merged
merged 21 commits into from
May 20, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ jobs:
needs: [ integration_test ]
runs-on: ubuntu-latest
name: Notify
if: always()
if: ${{ always() && inputs.environment == 'uat' }}
steps:
- name: Report Status
if: always()
uses: ravsamhq/notify-slack-action@v2
with:
status: ${{ needs.integration_test.result }}
token: ${{ secrets.GITHUB_TOKEN }}
notify_when: 'failure,skipped'
notify_when: 'failure'
notification_title: '{workflow} has {status_message}'
message_format: '{emoji} <{workflow_url}|{workflow}> {status_message} in <{repo_url}|{repo}>'
footer: 'Linked to Repo <{repo_url}|{repo}>'
Expand Down
4 changes: 2 additions & 2 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: pagopa-gpd-core
description: micro-service to manage Creditor Institution debtor positions
type: application
version: 0.124.0
appVersion: 0.11.27
version: 0.125.0
appVersion: 0.11.27-1-PAGOPA-1744-getDebtPositionByIUV
dependencies:
- name: microservice-chart
version: 2.4.0
Expand Down
2 changes: 1 addition & 1 deletion helm/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ microservice-chart:
image:
repository: ghcr.io/pagopa/pagopa-debt-position
tag: "0.11.2-1-PAGOPA-1530-upsert"
tag: "0.11.27"
tag: "0.11.27-1-PAGOPA-1744-getDebtPositionByIUV"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion helm/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-debt-position
tag: "0.11.27"
tag: "0.11.27-1-PAGOPA-1744-getDebtPositionByIUV"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion helm/values-uat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-debt-position
tag: "0.11.27"
tag: "0.11.27-1-PAGOPA-1744-getDebtPositionByIUV"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
19 changes: 7 additions & 12 deletions integration-test/src/features/debt-position-manage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,32 @@ Feature: Managing a debt position
When the debt position is created
Then the debt position gets the status code 201
And the organization gets the nav value after creation

Scenario: Debt position notification fee update
# Debt position notification fee update
When the notification fee of the debt position is updated
Then the organization gets the status code 209
And the organization gets the updated amounts

Scenario: Debt position filter list by status and due date
# Debt position filter list by status and due date
Given the filter made by status "DRAFT"
And the filter made by due date from today to 10 days
When we ask the list of organizations debt positions
Then we get the status code 200

Scenario: Debt position filter list by payment date
# Debt position filter list by payment date
Given the filter made by payment date from today to 20 days
When we ask the list of organizations debt positions
Then we get the status code 200

Scenario: Debt position update
# Debt position update
When the debt position is updated
Then the organization gets the update status code 200
And the organization gets the nav value after update

Scenario: Debt position get
# Debt position get
When we get the debt position
Then the company name is "Testing S.p.A."
And the organization get the nav value

Scenario: Debt position deleted
# Debt position deleted
When the debt position is deleted
Then the debt position gets the status code 200


Scenario: Debt position filter list: exclusive param violation
Given the filter made by due date from today to 10 days
And the filter made by payment date from today to 20 days
Expand Down
9 changes: 3 additions & 6 deletions integration-test/src/features/debt-position-pay.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@ Feature: Paying a debt position
Given a random iupd
When the debt position is created
Then the debt position gets the status code 201

Scenario: Debt position publication
# Debt position publication
When the debt position is published
Then the debt position gets the status code 200
And the organization gets the nav value after publication

Scenario: Payment option payment
# Payment option payment
When the payment option is paid
Then the payment option gets the status code 200

Scenario: Reporting the transfer
# Reporting the transfer
When the transfer is reported
Then the transfer gets the status code 200
14 changes: 14 additions & 0 deletions integration-test/src/features/debt-position-retrieval.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Feature: Retrieve a debt position

Background:
Given GPD running

Scenario: Get Debt Position by IUV
# Remove dirty data -> create Payment Positions -> Get Payment Position by IUV
Given the debt position with IUPD 77777777777_GET_PP_BY_IUV is deleted
Given the debt position with IUPD 77777777777_GET_PP_BY_IUV and payment option with IUV 99000000000000000 is created
Then the response returns the status code 201
When we get the debt position by IUV 99000000000000000
Then the response returns the status code 200
And the debt position response IUV value is 99000000000000000
And the debt position with IUPD 77777777777_GET_PP_BY_IUV is deleted
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Feature: Managing a debt position

Scenario: Debt position creation
Given a random iupd
And a new debt position
When the debt position is updated and published
When the debt position is created
And the debt position is updated and published
Then the debt position gets the status code 200
And the debt position gets status "VALID"
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,18 @@ function getDebtPosition(orgId, iupd, segCodes) {
})
}

function getDebtPositionByIUV(orgId, iuv, segCodes) {
const params = {}
if (segCodes) {params.segregationCodes = segCodes}
return get(GPD_HOST + `/organizations/${orgId}/paymentoptions/${iuv}/debtposition`, {
timeout: API_TIMEOUT,
headers: {
"Ocp-Apim-Subscription-Key": process.env.API_SUBSCRIPTION_KEY,
"Content-Type": "application/json"
}
})
}

function getPaymentOptionByIuv(orgId, iuv) {
return get(GPD_HOST + `/organizations/${orgId}/paymentoptions/${iuv}`, {
timeout: API_TIMEOUT,
Expand Down Expand Up @@ -202,6 +214,7 @@ module.exports = {
updateNotificationFee,
getDebtPositionList,
getDebtPosition,
getDebtPositionByIUV,
deleteDebtPosition,
payPaymentOption,
reportTransfer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ async function assertNav(debtPosition, response) {
assert.strictEqual(response.paymentOption[0].nav, auxDigit + debtPosition.paymentOption[0].iuv);
}

async function assertIUV(response, expectedIUV) {
assert.strictEqual(response.paymentOption[0].iuv, expectedIUV);
}

async function assertSize (array, expectedSize){
assert.strictEqual(array.length, expectedSize)
}
Expand Down Expand Up @@ -77,6 +81,7 @@ module.exports = {
randomIupd,
assertIupd,
assertNav,
assertIUV,
assertNotificationFeeUpdatedDateNotificationFee,
assertSize,
assertMinSize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const {
updateAndPublishDebtPosition,
getPaymentOptionByIuv,
invalidateDebtPosition,
createMassiveDebtPositions
createMassiveDebtPositions,
getDebtPositionByIUV
} = require("../clients/gpd_client");

const {
Expand All @@ -24,9 +25,9 @@ const {
buildCreateMassiveDebtPositionRequest
} = require("../utility/request_builders");

async function executeDebtPositionCreation(bundle, idOrg, iupd) {
async function executeDebtPositionCreation(bundle, idOrg, iupd, iuv) {
bundle.organizationCode = idOrg;
bundle.debtPosition = buildDebtPositionDynamicData(bundle, iupd);
bundle.debtPosition = buildDebtPositionDynamicData(bundle, iupd, iuv);
let response = await createDebtPosition(bundle.organizationCode, buildCreateDebtPositionRequest(bundle.debtPosition, bundle.payer));
bundle.responseToCheck = response;
bundle.createdDebtPosition = bundle.responseToCheck.data;
Expand Down Expand Up @@ -124,6 +125,12 @@ async function executeDebtPositionGet(bundle, idOrg, iupd) {
bundle.responseToCheck = response;
}

async function executeDebtPositionGetByIuv(bundle, idOrg, iuv) {
let response = await getDebtPositionByIUV(idOrg, iuv);
bundle.payer.companyName = response.data.companyName;
bundle.responseToCheck = response;
}

async function executeDebtPositionGetWithSegregationCodes(bundle, idOrg, iupd) {
let segCodes = bundle.debtPosition.iuv1.slice(0, 2)
let response = await getDebtPosition(idOrg, iupd, segCodes);
Expand Down Expand Up @@ -198,6 +205,7 @@ module.exports = {
executeDebtPositionUpdate,
executeDebtPositionNotificationFeeUpdate,
executeDebtPositionGet,
executeDebtPositionGetByIuv,
executeDebtPositionPublish,
executePaymentOptionPay,
executeReportTransfer,
Expand Down
19 changes: 12 additions & 7 deletions integration-test/src/step_definitions/support/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const { executeDebtPositionCreation,
executeDebtPositionCreationAndPublication,
executeDebtPositionUpdateAndPublication,
executePaymentOptionGetByIuv,
executeDebtPositionGetByIuv,
executeOKDebtPositionCreation,
executeKODebtPositionCreation,
executeDebtPositionNotificationFeeUpdateNodeOK,
Expand All @@ -27,7 +28,9 @@ const { executeDebtPositionCreation,
executeMassiveDebtPositionCreationWithSegregationCodes
} = require('./logic/gpd_logic');
const { assertAmount, assertFaultCode, assertOutcome, assertStatusCode, assertCompanyName, assertNotificationFeeUpdatedAmounts,
assertStatusString, executeAfterAllStep, randomOrg, randomIupd, assertIupd, assertNav, assertNotificationFeeUpdatedDateNotificationFee, assertSize, assertMinSize } = require('./logic/common_logic');
assertStatusString, executeAfterAllStep, randomOrg, randomIupd, assertIupd, assertNav, assertNotificationFeeUpdatedDateNotificationFee, assertSize, assertMinSize,
assertIUV
} = require('./logic/common_logic');
const { gpdSessionBundle, gpdUpdateBundle, gpdPayBundle } = require('./utility/data');
const { getValidBundle, addDays, format } = require('./utility/helpers');

Expand Down Expand Up @@ -56,7 +59,6 @@ BeforeAll(async function() {
*/
Given('GPD running', () => executeHealthCheckForGPD());


/*
* Debt position creation
*/
Expand All @@ -65,15 +67,16 @@ Given('a random iupd', async function () {
// precondition -> deletion possible dirty data
await executeDebtPositionDeletion(gpdSessionBundle, idOrg, iupd);
});
When('the debt position is created', () => executeDebtPositionCreation(gpdSessionBundle, idOrg, iupd, status));
When(/^the debt position with IUPD (.*) and payment option with IUV (.*) is created$/, (IUPD_input, iuv) => executeDebtPositionCreation(gpdSessionBundle, idOrg, IUPD_input, iuv));
When('the debt position is created', () => executeDebtPositionCreation(gpdSessionBundle, idOrg, iupd));
Then('the debt position gets the status code {int}', (statusCode) => assertStatusCode(gpdSessionBundle, statusCode));
Then('the organization gets the nav value after creation', () => assertNav(gpdSessionBundle.createdDebtPosition, gpdSessionBundle.responseToCheck.data));

/*
* Massive debt positions creation
*/

When('the debt position items is created', () => executeMassiveDebtPositionsCreation(gpdSessionBundle, idOrg, iupd, status));
When('the debt position items is created', () => executeMassiveDebtPositionsCreation(gpdSessionBundle, idOrg, iupd));


/*
Expand Down Expand Up @@ -128,14 +131,16 @@ Then('the organization gets the nav value after update', () => assertNav(gpdSess
* Debt position get
*/
When('we get the debt position', () => executeDebtPositionGet(gpdSessionBundle, idOrg, iupd));
When(/^we get the debt position by IUV (.*)$/, (iuv) => executeDebtPositionGetByIuv(gpdSessionBundle, idOrg, iuv));
Then('the company name is {string}', (companyName) => assertCompanyName(gpdSessionBundle, companyName));
Then('the organization get the nav value', () => assertNav(gpdSessionBundle.responseToCheck.data, gpdSessionBundle.responseToCheck.data))
Then(/^the debt position response IUV value is (.*)$/, (expectedIUV) => assertIUV(gpdSessionBundle.responseToCheck.data, expectedIUV))

/*
* Debt position delete
*/
When('the debt position is deleted', () => executeDebtPositionDeletion(gpdSessionBundle, idOrg, iupd));

Then(/^the debt position with IUPD (.*) is deleted$/, (IUPD_input) => executeDebtPositionDeletion(gpdSessionBundle, idOrg, IUPD_input));

/*
* Debt position publish
Expand All @@ -161,6 +166,7 @@ Then('the payment option gets the status code {int}', (statusCode) => assertStat
*/
When('we get the payment option by iuv', () => executePaymentOptionGetByIuv(gpdSessionBundle, idOrg, gpdSessionBundle.debtPosition.iuv1));
Then('the get payment options returns the status code {int}', (statusCode) => assertStatusCode(gpdSessionBundle, statusCode));
Then('the response returns the status code {int}', (statusCode) => assertStatusCode(gpdSessionBundle, statusCode));
Then('the iupd is present and valued with the same value as the debt position', () => assertIupd(gpdSessionBundle));

/*
Expand All @@ -175,14 +181,13 @@ Then('the transfer gets the status code {int}', (statusCode) => assertStatusCode
When('the debt position is created and published', () => executeDebtPositionCreationAndPublication(gpdSessionBundle, idOrg, iupd));
Then('the debt position gets status {string}', (statusString) => assertStatusString(gpdSessionBundle, statusString));

Given('a new debt position', () => executeDebtPositionCreation(gpdSessionBundle, idOrg, iupd, status));
When('the debt position is updated and published', () => executeDebtPositionUpdateAndPublication(gpdSessionBundle, idOrg, iupd));

/*
* Debt position manage with segregation codes
*/

When('the debt position using segregation codes is created', () => executeDebtPositionCreationWithSegregationCodes(gpdSessionBundle, idOrg, iupd, status));
When('the debt position using segregation codes is created', () => executeDebtPositionCreationWithSegregationCodes(gpdSessionBundle, idOrg, iupd));
When('the debt position items, using segregation codes, is created', () => executeMassiveDebtPositionCreationWithSegregationCodes(gpdSessionBundle, idOrg, iupd, status));
When('the debt position using segregation codes is updated', () => executeDebtPositionUpdateWithSegregationCodes(gpdSessionBundle, gpdUpdateBundle, idOrg, iupd));
When('the organization gets the debt position using segregation codes', () => executeDebtPositionGetWithSegregationCodes(gpdSessionBundle, idOrg, iupd));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const { addDays, buildStringFromDate, makeidNumber, makeidMix, } = require("./helpers");

function buildDebtPositionDynamicData(gpdSessionBundle, iupdIn) {
function buildDebtPositionDynamicData(gpdSessionBundle, iupdIn, iuv = makeidNumber(17)) {
return {
iupd: iupdIn,
iuv1: makeidNumber(17),
iuv1: iuv,
iuv2: makeidNumber(17),
iuv3: makeidNumber(17),
iuvOK: process.env.iuv_ok, // es. "11101751670642134"
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi_external.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "PagoPA API Debt Position",
"description": "Progetto Gestione Posizioni Debitorie",
"termsOfService": "https://www.pagopa.gov.it/",
"version": "0.11.27"
"version": "0.11.27-1-PAGOPA-1744-getDebtPositionByIUV"
},
"servers": [
{
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi_external_massive.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "PagoPA API Debt Position",
"description": "Progetto Gestione Posizioni Debitorie",
"termsOfService": "https://www.pagopa.gov.it/",
"version": "0.11.27"
"version": "0.11.27-1-PAGOPA-1744-getDebtPositionByIUV"
},
"servers": [
{
Expand Down
Loading
Loading