Skip to content

Commit

Permalink
IMN-601 Fixing contract name creation date (#610)
Browse files Browse the repository at this point in the history
  • Loading branch information
ecamellini authored Jun 5, 2024
1 parent ab845ed commit c35e9cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
genericError,
tenantAttributeType,
unsafeBrandId,
AgreementDocument,
} from "pagopa-interop-models";
import {
UserResponse,
Expand All @@ -40,7 +41,6 @@ import {
userNotFound,
} from "../model/domain/errors.js";
import { UpdateAgreementSeed } from "../model/domain/models.js";
import { ApiAgreementDocumentSeed } from "../model/types.js";
import { AgreementProcessConfig } from "../utilities/config.js";
import { ReadModelService } from "./readModelService.js";

Expand All @@ -64,10 +64,11 @@ const retrieveUser = async (

const createAgreementDocumentName = (
consumerId: TenantId,
producerId: TenantId
producerId: TenantId,
documentCreatedAt: Date
): string =>
`${consumerId}_${producerId}_${formatDateyyyyMMddHHmmss(
new Date()
documentCreatedAt
)}_agreement_contract.pdf`;

const getAttributeInvolved = async (
Expand Down Expand Up @@ -314,7 +315,7 @@ export const contractBuilder = (
consumer: Tenant,
producer: Tenant,
seed: UpdateAgreementSeed
): Promise<ApiAgreementDocumentSeed> => {
): Promise<AgreementDocument> => {
const templateFilePath = path.resolve(
dirname,
"..",
Expand All @@ -338,9 +339,11 @@ export const contractBuilder = (
);

const documentId = generateId<AgreementDocumentId>();
const documentCreatedAt = new Date();
const documentName = createAgreementDocumentName(
agreement.consumerId,
agreement.producerId
agreement.producerId,
documentCreatedAt
);

const documentPath = await fileManager.storeBytes(
Expand All @@ -358,6 +361,7 @@ export const contractBuilder = (
contentType: CONTENT_TYPE_PDF,
prettyName: AGREEMENT_CONTRACT_PRETTY_NAME,
path: documentPath,
createdAt: documentCreatedAt,
};
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ async function addContractOnFirstActivation(

return {
...agreement,
contract: apiAgreementDocumentToAgreementDocument(contract),
contract,
};
}

Expand Down

0 comments on commit c35e9cb

Please sign in to comment.