Purchase order confirmation, product receipt, Invoice, cancel classes and methods
Let's assume that we have the requirement to send business events after purchase order confirmation, cancel, product receipt and invoice Fully (header level)
1) purchase order cancel
=================
[ExtensionOf(classstr(PurchCancel))]
public final class TestPurchCancel_Extension
{
public void run()
{
PurchTable purchTableOrig, purhtableLoc;
next run();
purchTableOrig = this.parmPurchTable();
select firstonly purhtableLoc
where purhtableLoc.PurchId == purchTableOrig.PurchId
&& purhtableLoc.PurchStatus == PurchStatus::Canceled;
if(purhtableLoc.RecId)
{
//Write your logic
}
}
}
[ExtensionOf(classstr(PurchFormletter))]
public final class TestPurchFormLetter_Extension
{
public void run()
{
PurchTable purchTableOrig, purhtableLoc;
next run();
purchTableOrig = purchFormLetterContract.parmPurchTable();
select firstonly purhtableLoc
where purhtableLoc.PurchId == purchTableOrig.PurchId
&&(purhtableLoc.PurchStatus == PurchStatus::Received||
purhtableLoc.PurchStatus == PurchStatus::Invoiced);
if(purhtableLoc.RecId)
{
//Write your logic
}
}
}
3) purchase order confirmation
===========================
[ExtensionOf(classstr(SourceDocumentStateInProcess))]
public final class TestSourceDocumentStateInProcess_Extension
{
protected boolean doTransition()
{
next doTransition();
if (targetSourceDocumentAccountingStatus == SourceDocumentAccountingStatus::Completed)
{
PurchTable purchTable = PurchTable::findSourceDocumentHeader(sourceDocumentHeader.RecId);
VendPurchOrderJour vendPurchOrderJour = VendPurchOrderJour::findByPurchId(purchTable.PurchId);
if(vendPurchOrderJour.RecId)
{
//Write your logic
}
}
return true.
}
}