import DC_ACTION from '../../../enum/dcAction'; import PARTY from '../../../enum/party'; import USER_ROLE from '../../../enum/userRole'; import envConfig from '../../../env/env-config'; import { getNodeProfile } from '../../../env/nodeProfile'; import { generateAdvisingBankProceededDc } from '../../../util/generateDC'; import { HTTP_METHOD } from '../../../util/httpMethod'; import { makeAuthenticatedRequest } from '../../../util/loginUtil'; import scenarioContext from '../../../util/scenarioContext'; export default async function generateDpUtil(dcScenario: string, presentToParty: string, presentThroughParty: string) { await generateAdvisingBankProceededDc( dcScenario, DC_ACTION.ADVISED, USER_ROLE.MAKER + '.' + USER_ROLE.CHECKER_APPROVER ); let presentThroughCompanyName: any; let presentThroughX500Name: any; const dc = scenarioContext().dc; const appLinId = dc.uuid; const appRefId = dc.appRefId; const presentToCompanyName = envConfig.scenario[dcScenario][presentToParty]; const presentToX500Name = getNodeProfile(presentToCompanyName).name; if (presentThroughParty != 'null') { presentThroughCompanyName = envConfig.scenario[dcScenario][presentThroughParty]; presentThroughX500Name = getNodeProfile(presentThroughCompanyName).name; } else { presentThroughX500Name = null; } const json = { args: { appLinId: appLinId, locRef: appRefId, noticeOfCompleteness: 'COMPLETE', timezoneId: '+0800', amountDrawn: '111.00 USD', exportDCInstructions: { ourInstructions: { instruction: 'NONE', additionalInstructions: [] }, proceedsDisposalInstructions: { debitAccount: null, proceedAccount: null, exchangeContract: null, others: null } }, invoice: { props: [ { invoiceNo: '', goods: 'TVs [S1]', weight: '', mailingType: 'DIGITAL_COPY_FOR_PRESENTATION', transferMode: null, transferReference: null, attachmentHash: [], attachments: [] } ] }, billOfLading: { boleroDocument: null, props: { mailingType: 'DOCUMENT_NOT_AVAILABLE', billOfLadingID: null, dateOfShipment: null, portOfDischarge: null, portOfLoading: null }, attachments: [], endorsee: null, endorsementType: null, owner: presentToX500Name, boleroProps: null }, otherDocs: { doc101: { attachments: [], documentMailingType: 'DOCUMENT_NOT_AVAILABLE' } }, packingList: { attachments: [], documentMailingType: 'DOCUMENT_NOT_AVAILABLE' }, certOfOrigin: { attachments: [], documentMailingType: 'DOCUMENT_NOT_AVAILABLE' }, presentTo: presentToX500Name, presentThrough: presentThroughX500Name, presentationDate: 1596096464696, documentsSource: 'CONTOUR', comment: '' }, draftComment: null }; const beneficiary = Object.keys(scenarioContext().scenario).length > 0 ? scenarioContext().scenario[PARTY.BENEFICIARY] : envConfig.scenario[dcScenario].beneficiary; const res = await makeAuthenticatedRequest( beneficiary, USER_ROLE.ADMIN1, 'dp/submit', HTTP_METHOD.PUT, JSON.stringify(json) ); if (res.id != null) { await makeAuthenticatedRequest(beneficiary, USER_ROLE.ADMIN1, 'draft/execute/' + res.id, HTTP_METHOD.POST, null); } }