while select InvoicedNow from psaProjProposalProj
where psaProjProposalProj.ProjProposalId == projProposalJour.ProposalId
{
if( psaProjProposalProj.InvoicedNow <= 0)
{
select firstonly projParameters
where projParameters.DataAreaId == projProposalJour.DataAreaId;
select Reason from reasonTableRef
where reasonTableRef.RecId == projProposalJour.ReasonTableRef;
if(projParameters.DTOriginalInvoiceMandatory == NoYes::Yes && projProposalJour.DTOriginalTaxInvoiceNo == '')
{
if(projParameters.DTReasonCodeMandatory == NoYes::Yes && ReasonTableRef.Reason == '')
{
throw error("The Original Invoice field & Reason Code field is mandatory. Cannot proceed further.");
}
else
{
throw error("The Original Invoice field is mandatory. Cannot proceed further.");
}
}
if(projParameters.DTReasonCodeMandatory == NoYes::Yes && ReasonTableRef.Reason == '')
{
throw error("The Reason Code field is mandatory. Cannot proceed further.");
}
}
}
if( PSAProjProposalProj.InvoicedNow <= 0)
{
select Reason,RecId from reasonTableRef
where reasonTableRef.RecId == projProposalJour.ReasonTableRef;
if(projParameters.DTReasonCodeMandatory == NoYes::Yes && ReasonTableRef.Reason == '')
{
Info("The Reason Code field is mandatory. Cannot proceed further.");
//ret = ret && false;
}
}
[ExtensionOf(classStr(PSAProjInvoiceProposalSubmitToWF))]
final class DTPSAProjInvoiceProposalSubmitToWF_Extension
{
// Description : test if the invoice proposal can be submitted to workflow
public static void main(Args _args)
{
RecID recID = _args.record().RecId;
TableId tableId = _args.record().TableId;
ProjProposalJour projProposalJour = _args.record();
WorkflowWorkItemTable workItem = _args.caller().getActiveWorkflowWorkItem();
WorkflowSubmitDialog workflowSubmitDialog;
WorkflowComment wfComment;
workflowTypeName workflowTemplateName = workFlowTypeStr('PSAProjInvoiceProposal');
PSAProjProposalProj pSAProjProposalProj;
ReasonTableRef reasonTableRef;
ProjParameters projParameters;
// The method has not been called correctly.
if (tableId != tablenum(ProjProposalJour) ||
recId == 0)
{
throw error(strfmt("@SYS19306", funcname()));
}
if (projProposalJour.RecId != 0)
{
while select InvoicedNow from pSAProjProposalProj
where pSAProjProposalProj.ProjProposalId == projProposalJour.ProposalId
{
select firstonly projParameters
where projParameters.DataAreaId == projProposalJour.DataAreaId;
if( PSAProjProposalProj.InvoicedNow <= 0)
{
select Reason,RecId from reasonTableRef
where reasonTableRef.RecId == projProposalJour.ReasonTableRef;
if(projParameters.DTOriginalInvoiceMandatory == NoYes::Yes && projProposalJour.DTOriginalTaxInvoiceNo == ''
&& projParameters.DTReasonCodeMandatory == NoYes::Yes && ReasonTableRef.Reason == '')
{
throw error("The Original Invoice field & Reason Code field is mandatory. Cannot proceed further.");
//ret = ret && false;
}
else if(projParameters.DTOriginalInvoiceMandatory == NoYes::Yes && projProposalJour.DTOriginalTaxInvoiceNo == '')
{
throw error("The Original Invoice field is mandatory. Cannot proceed further.");
//ret = ret && false;
}
else if(projParameters.DTReasonCodeMandatory == NoYes::Yes && ReasonTableRef.Reason == '')
{
throw error("The Reason Code field is mandatory. Cannot proceed further.");
//ret = ret && false;
}
}
}
}
// Make the form refresh its common workflow UI controls.
PSAProjInvoiceProposalSubmitToWF::refreshCaller(_args);
next Main(_args);
}
}
public static void main(Args _args)
{
RecID recID = _args.record().RecId;
TableId tableId = _args.record().TableId;
ProjProposalJour projProposalJour = _args.record();
WorkflowWorkItemTable workItem = _args.caller().getActiveWorkflowWorkItem();
WorkflowSubmitDialog workflowSubmitDialog;
WorkflowComment wfComment;
workflowTypeName workflowTemplateName = workFlowTypeStr('PSAProjInvoiceProposal');
PSAProjProposalProj pSAProjProposalProj;
ReasonTableRef reasonTableRef;
ProjParameters projParameters;
// The method has not been called correctly.
if (tableId != tablenum(ProjProposalJour) ||
recId == 0)
{
throw error(strfmt("@SYS19306", funcname()));
}
if (projProposalJour.RecId != 0)
{
while select InvoicedNow from pSAProjProposalProj
where pSAProjProposalProj.ProjProposalId == projProposalJour.ProposalId
{
select firstonly projParameters
where projParameters.DataAreaId == projProposalJour.DataAreaId;
if( PSAProjProposalProj.InvoicedNow <= 0)
{
if(projParameters.DTOriginalInvoiceMandatory == NoYes::Yes && projProposalJour.DTOriginalTaxInvoiceNo == ''
&& projParameters.DTReasonCodeMandatory == NoYes::Yes && ReasonTableRef.Reason == '')
{
info("The Original Invoice field & Reason Code field is mandatory. Cannot proceed further.");
//ret = ret && false;
}
}
if( PSAProjProposalProj.InvoicedNow <= 0)
{
if(projParameters.DTOriginalInvoiceMandatory == NoYes::Yes && projProposalJour.DTOriginalTaxInvoiceNo == '')
{
info("The Original Invoice field is mandatory. Cannot proceed further.");
//ret = ret && false;
}
}
if( PSAProjProposalProj.InvoicedNow <= 0)
{
select Reason,RecId from reasonTableRef
where reasonTableRef.RecId == projProposalJour.ReasonTableRef;
if(projParameters.DTReasonCodeMandatory == NoYes::Yes && ReasonTableRef.Reason == '')
{
Info("The Reason Code field is mandatory. Cannot proceed further.");
//ret = ret && false;
}
}
}
else
{
// The journal does support workflow approvals.
workflowSubmitDialog = WorkflowSubmitDialog::construct(_args.caller().getActiveWorkflowConfiguration());
workflowSubmitDialog.run();
}
André Arnaud de Cal... 291,391 Super User 2024 Season 2
Martin Dráb 230,445 Most Valuable Professional
nmaenpaa 101,156