Present document

After the seller has shipped the goods, he presents a written document to the confirming bank. Therefore, we define the SellerPresentDocument transaction and related event for the LC update:

transaction SellerPresentDocument {
--> LetterOfCredit lc
o String evidence
}
event SellerPresentDocumentEvent {
--> LetterOfCredit lc
}

The letter status is set to PRESENT DOCUMENT, and the step to 5:

/**
* seller Presentation the Document
* @param {org.example.lc.SellerPresentDocument} sellerPresentDocument - seller present document
* @transaction
*/
async function sellerPresentDocument(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!== 4) {
throw new Error ('This letter of credit should be in step 4 - ADVICE_LC');
}
letter.status = 'PRESENT_DOCUMENT';
letter.step=5;
letter.evidence.push(request.evidence);
const assetRegistry = await getAssetRegistry(request.lc.getFullyQualifiedType());
await assetRegistry.update(letter);

// emit event
const sellerPresentDocumentEvent = factory.newEvent(namespace, 'SellerPresentDocumentEvent');
sellerPresentDocumentEvent.lc = letter;
emit(sellerPresentDocumentEvent);
}

The LC asset has an evidence array data field, which contains all the document proofs for the entire process. When a seller presents a written document to the confirming bank, the document will be added to the LC evidence using the JavaScript push function: letter.evidence.push(request.evidence). As you know, the push() method adds new items to the end of an array.

..................Content has been hidden....................

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