strRTrim(conpeek(c,1)); enrollmentId = subStr(conpeek(c,1),0,strLen(conPeek(c,1))-1); in AX 2012 X++
static void AWEREProcessCancelAgreements(Args _args)
{
fileIOpermission permission;
TextIo textiO;
FilenameOpen sfileName = "D:\\Enrollment\\Cancelled Enrollments.csv";
container c;
int i=1;
SalesAgreementId enrollmentId;
AgreementConfirm agreementConfirm;
SalesAgreementHeader salesAgreementHeader;
//CS - AWE_DF_22153 - LBautista - 1 Oct 2015
AgreementLine agreementLine;
//CE - AWE_DF_22153 - LBautista - 1 Oct 2015
boolean updateStatusAndExpireDate;//C - AWE_DF_23232 - narasid - Dec 28 2015
AweEnrollmentCancellationTaskService taskService = new AweEnrollmentCancellationTaskService();
#file
;
permission = new fileIOpermission(sfileName,#io_read);
permission.assert();
textIO = new TextIO(sfileName,#io_read);
textIO.inRecordDelimiter("\n");
startLengthyOperation();
while(textIO.status() == IO_Status::Ok)
{
c = textIO.read();
if(conLen(c) > 0)
{
//enrollmentId = strRTrim(conpeek(c,1));
enrollmentId = subStr(conpeek(c,1),0,strLen(conPeek(c,1))-1);
select salesAgreementHeader
where salesAgreementHeader.SalesNumberSequence == enrollmentId
&& salesAgreementHeader.AgreementState == AgreementState::OnHold
&& salesAgreementHeader.IsDeleted == NoYes::No
&& salesAgreementHeader.AweCancel == NoYes::Yes
&& salesAgreementHeader.CustomerDataAreaId == appl.company().dataArea(tablenum(CustTable));
if (salesAgreementHeader)
{
updateStatusAndExpireDate = true;
//ATuli
/*if (salesAgreementHeader.AweCancellationDate <= systemDateGet()) // - Awe_CR_10925 - Backdated Cancelled Enrollments - LBautista - 13 Jul 2015
{
updateStatusAndExpireDate = AweCreateReleaseOrderTaskService::cancelOpenPackingSlipAndOpenSalesOrder(salesAgreementHeader.RecId);
}*///ATuli
if (updateStatusAndExpireDate == true)
{
updateStatusAndExpireDate = taskService.cancelReleaseOrderSchedule(salesAgreementHeader.RecId, salesAgreementHeader.AweCancellationDate) &&
taskService.cancelRevenueRecognitionSchedule(salesAgreementHeader.RecId, salesAgreementHeader.AweCancellationDate, salesAgreementHeader.AweEarningsDate);
}
if (updateStatusAndExpireDate)
{
ttsBegin;
//CS - AWE_DF_22153 - LBautista - 1 Oct 2015
update_recordSet agreementLine
setting
ExpirationDate = salesAgreementHeader.AweCancellationDate
where
agreementLine.Agreement == salesAgreementHeader.RecId &&
agreementLine.ExpirationDate > salesAgreementHeader.AweCancellationDate;
//CE - AWE_DF_22153 - LBautista - 1 Oct 2015
ttsCommit;
ttsBegin;
taskService.processCancellationAdjustments(salesAgreementHeader);
agreementConfirm = AgreementConfirm::newAgreementConfirm(salesAgreementHeader, true);
agreementConfirm.parmAweMakeEffective();
ttsCommit;
// CE - Enrollment Cancellation Optimization - LBautista - 22 Jul 2015
}
info(strFmt("Line No- %1- for Enrolment- %2 is processed", i, enrollmentId));
}
else
{
info(strFmt("Enrolment- %1 matching condition failed for Line No- %2",enrollmentId, i));
}
i++;
}
}
endLengthyOperation();
}
*This post is locked for comments