LC approval

After the buyer submits an LC request, the issuing bank approves the LC form, and sends it to the confirming bank. In our model file, we define the related IssuingBankApproveLC transaction and the related event as follows:

transaction IssuingBankApproveLC {
--> LetterOfCredit lc
}

event IssuingBankApproveLCEvent {
--> LetterOfCredit lc
}

The transaction logic here is similar to the previous step, where we use getAssetRegistry to find the existing LC asset and we update the LC status, before emitting the IssuingBankApproveLCEvent. The letter status is set to ISSUE_LC, and the LC step to 2:

/**
* issuing bank approval buyer LC
* @param {org.example.lc.IssuingBankApproveLC} issuingBankApproveLC -
* Issuing Bank approval LC transaction
* @transaction
*/
async function issuingBankApproveLC(request) { // eslint-disable-line no-unused-vars
const factory = getFactory();
const namespace = 'org.example.lc';

let letter = request.lc;

if (letter.status === 'CLOSED') {
throw new Error ('This letter of credit has already been closed');
} else if (letter.step!== 1) {
throw new Error ('This letter of credit should be in step 1 - REQUEST_LC');
}
letter.status = 'ISSUE_LC';
letter.step=2;

const assetRegistry = await getAssetRegistry(request.lc.getFullyQualifiedType());
await assetRegistry.update(letter);

// emit event
const issuingBankApproveLCEvent = factory.newEvent(namespace, 'IssuingBankApproveLCEvent');
issuingBankApproveLCEvent.lc = letter;
emit(issuingBankApproveLCEvent);
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset