public void processStampICPO(PackingSlipId _deliveryNote,
Transdate _deliverydate,
InterCompanyCompanyId _dataAreaID,
custPackingSlipJour _custPackingSlipJour)
{
SalesTable salesTable;
CustPackingSlipJour custPackingSlipJour =_custPackingSlipJour;
CustPackingSlipTrans custPackingSlipTrans;
PurchLine purchLine;
int i,j;
boolean isPosted;
PurchId purchId;
utcDateTime currentDatetime;
date currentDate;
SON_InterCompanyPurchView interPurchTable;
InventTransId interInventTrans;
//currentDatetime = DateTimeUtil::utcNow();
//currentDatetime = DateTimeUtil::applyTimeZoneOffset(currentDatetime,DateTimeUtil::getUserPreferredTimeZone());
//currentDate = DateTimeUtil::date(currentDatetime);
//
//while select forUpdate SON_DDDeliveryNote,DeliveryDate,InterCompanyCompanyId,
//SON_IsIntercompanyPOPosted,PackingSlipId from custPackingSlipJour
//where custPackingSlipJour.SON_IsIntercompanyPOPosted == NoYes::No
//&& custPackingSlipJour.SON_DDDeliveryNote != ''
//&& custPackingSlipJour.DeliveryDate <= currentDate
//join SalesId,SalesStatus from salesTable
//where salesTable.SalesId == custPackingSlipJour.SalesId
//&& salesTable.SalesStatus != SalesStatus::Invoiced
//&& salesTable.SalesStatus != SalesStatus::Canceled
//join InterCompanySalesId,PurchStatus from interPurchTable
//where interPurchTable.InterCompanySalesId == salesTable.SalesId
//&& interPurchTable.PurchStatus == PurchStatus::Backorder
{
//deliveryNote = custPackingSlipJour.SON_DDDeliveryNote;
//deliveryDate = custPackingSlipJour.DeliveryDate;
//interCompany = custPackingSlipJour.InterCompanyCompanyId;
// custPackingSlipJour as _custPackingSlipJour;
deliveryNote = _deliveryNote;
deliveryDate = _deliverydate;
interCompany = _dataAreaID;
if(interCompany == '0001')
{
while select InterCompanyInventTransId,Qty from custPackingSlipTrans
where custPackingSlipTrans.PackingSlipId == custPackingSlipJour.PackingSlipId
{
purchLine.clear();
select forUpdate * from purchLine
where purchLine.InventTransId == custPackingSlipTrans.InterCompanyInventTransId;
if(purchLine)
{
ttsBegin;
purchLine.PurchReceivedNow = custPackingSlipTrans.Qty;
purchLine.setInventReceivedNow();
purchLine.doUpdate();
ttsCommit;
purchId = purchLine.PurchId;
}
}
}
else
{
while select crossCompany InventTransId,Qty from custPackingSlipTrans
where custPackingSlipTrans.PackingSlipId == custPackingSlipJour.PackingSlipId
{
interInventTrans = custPackingSlipTrans.InventTransId;
select forUpdate crossCompany * from purchLine
where purchLine.InterCompanyInventTransId == interInventTrans
&& purchLine.PurchStatus == PurchStatus::Backorder;
if(purchLine)
{
changeCompany(purchLine.dataAreaId)
{
ttsBegin;
purchLine.PurchReceivedNow = custPackingSlipTrans.Qty;
purchLine.setInventReceivedNow();
purchLine.doUpdate();
ttsCommit;
}
purchId = purchLine.PurchId;
}
}
}
isPosted = this.postPurchPackingSlip(purchId);//,custPackingSlipJour.InterCompanyCompanyId);
if(isPosted)
{
info(strFmt("@SON2167", custPackingSlipJour.SalesId));
info(strFmt("@SON2168", custPackingSlipJour.SalesId,purchId));
ttsBegin;
custPackingSlipJour.SON_IsIntercompanyPOPosted = NoYes::Yes;
custPackingSlipJour.doUpdate();
ttsCommit;
i++;
}
else
{
j++;
}
}
//info(strFmt('%1 - ICPO were posted successfully and %2 were failed',i,j));
}
-------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------
public boolean postPurchPackingSlip(PurchId _purchId)
{
PurchFormLetter purchFormLetter = PurchFormLetter::construct(DocumentStatus::PackingSlip);
PurchFormLetter purchFormLetterConfirm;
PurchParmLine parmLine;
PurchTable purchTableUpdate,purchTable;
PurchParmTable purchParmTable;
PurchId purchIdError;
boolean ret = false;
VendPackingSlipJour vendPackingSlipJour;
SON_InterSalesLinesView interSalesLine;
try
{
changeCompany(interCompany)
{
//check and get updated date afterchecking fiscal calender and inventory closing
deliveryDate = this.getinvoicedate(deliveryDate);
//
if(purchIdError != _purchId)
{
purchTable.clear();
purchTable = PurchTable::find(_purchId);
if(purchTable.DocumentState == VersioningDocumentState::Approved)
{
purchFormLetterConfirm = PurchFormLetter::construct(DocumentStatus::PurchaseOrder);
purchFormLetterConfirm.update(purchTable,'InterPurchConf_'+purchTable.PurchId);
}
purchFormLetter.purchTable(purchTable);
purchFormLetter.transDate (deliveryDate);
purchFormLetter.specQty(PurchUpdate::ReceiveNow);
purchFormLetter.initParmDefault();
purchFormLetter.initParameters(purchFormLetter.purchParmUpdate(),Printout::After);
purchFormLetter.initLinesQuery();
select forUpdate Num from purchParmTable
where purchParmTable.ParmId == purchFormLetter.parmId();
if(purchParmTable)
{
ttsBegin;
purchParmTable.Num = deliveryNote;
purchParmTable.update();
ttsCommit;
}
purchFormLetter.run();
if (purchformletter.parmjournalrecord().tableid == tablenum(vendpackingslipjour))
{
ret = true;
}
}
}
}
catch
{
this.insertErrorLog(purchTable.InterCompanySalesId,SON_POPackingSlipDD::HasError());
infolog.clear();
//info(strFmt('%1',SON_POPackingSlipDD::HasError()));
purchIdError = purchTable.PurchId;
ret = false;
retry;
}
return ret;
}
Transdate _deliverydate,
InterCompanyCompanyId _dataAreaID,
custPackingSlipJour _custPackingSlipJour)
{
SalesTable salesTable;
CustPackingSlipJour custPackingSlipJour =_custPackingSlipJour;
CustPackingSlipTrans custPackingSlipTrans;
PurchLine purchLine;
int i,j;
boolean isPosted;
PurchId purchId;
utcDateTime currentDatetime;
date currentDate;
SON_InterCompanyPurchView interPurchTable;
InventTransId interInventTrans;
//currentDatetime = DateTimeUtil::utcNow();
//currentDatetime = DateTimeUtil::applyTimeZoneOffset(currentDatetime,DateTimeUtil::getUserPreferredTimeZone());
//currentDate = DateTimeUtil::date(currentDatetime);
//
//while select forUpdate SON_DDDeliveryNote,DeliveryDate,InterCompanyCompanyId,
//SON_IsIntercompanyPOPosted,PackingSlipId from custPackingSlipJour
//where custPackingSlipJour.SON_IsIntercompanyPOPosted == NoYes::No
//&& custPackingSlipJour.SON_DDDeliveryNote != ''
//&& custPackingSlipJour.DeliveryDate <= currentDate
//join SalesId,SalesStatus from salesTable
//where salesTable.SalesId == custPackingSlipJour.SalesId
//&& salesTable.SalesStatus != SalesStatus::Invoiced
//&& salesTable.SalesStatus != SalesStatus::Canceled
//join InterCompanySalesId,PurchStatus from interPurchTable
//where interPurchTable.InterCompanySalesId == salesTable.SalesId
//&& interPurchTable.PurchStatus == PurchStatus::Backorder
{
//deliveryNote = custPackingSlipJour.SON_DDDeliveryNote;
//deliveryDate = custPackingSlipJour.DeliveryDate;
//interCompany = custPackingSlipJour.InterCompanyCompanyId;
// custPackingSlipJour as _custPackingSlipJour;
deliveryNote = _deliveryNote;
deliveryDate = _deliverydate;
interCompany = _dataAreaID;
if(interCompany == '0001')
{
while select InterCompanyInventTransId,Qty from custPackingSlipTrans
where custPackingSlipTrans.PackingSlipId == custPackingSlipJour.PackingSlipId
{
purchLine.clear();
select forUpdate * from purchLine
where purchLine.InventTransId == custPackingSlipTrans.InterCompanyInventTransId;
if(purchLine)
{
ttsBegin;
purchLine.PurchReceivedNow = custPackingSlipTrans.Qty;
purchLine.setInventReceivedNow();
purchLine.doUpdate();
ttsCommit;
purchId = purchLine.PurchId;
}
}
}
else
{
while select crossCompany InventTransId,Qty from custPackingSlipTrans
where custPackingSlipTrans.PackingSlipId == custPackingSlipJour.PackingSlipId
{
interInventTrans = custPackingSlipTrans.InventTransId;
select forUpdate crossCompany * from purchLine
where purchLine.InterCompanyInventTransId == interInventTrans
&& purchLine.PurchStatus == PurchStatus::Backorder;
if(purchLine)
{
changeCompany(purchLine.dataAreaId)
{
ttsBegin;
purchLine.PurchReceivedNow = custPackingSlipTrans.Qty;
purchLine.setInventReceivedNow();
purchLine.doUpdate();
ttsCommit;
}
purchId = purchLine.PurchId;
}
}
}
isPosted = this.postPurchPackingSlip(purchId);//,custPackingSlipJour.InterCompanyCompanyId);
if(isPosted)
{
info(strFmt("@SON2167", custPackingSlipJour.SalesId));
info(strFmt("@SON2168", custPackingSlipJour.SalesId,purchId));
ttsBegin;
custPackingSlipJour.SON_IsIntercompanyPOPosted = NoYes::Yes;
custPackingSlipJour.doUpdate();
ttsCommit;
i++;
}
else
{
j++;
}
}
//info(strFmt('%1 - ICPO were posted successfully and %2 were failed',i,j));
}
-------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------
public boolean postPurchPackingSlip(PurchId _purchId)
{
PurchFormLetter purchFormLetter = PurchFormLetter::construct(DocumentStatus::PackingSlip);
PurchFormLetter purchFormLetterConfirm;
PurchParmLine parmLine;
PurchTable purchTableUpdate,purchTable;
PurchParmTable purchParmTable;
PurchId purchIdError;
boolean ret = false;
VendPackingSlipJour vendPackingSlipJour;
SON_InterSalesLinesView interSalesLine;
try
{
changeCompany(interCompany)
{
//check and get updated date afterchecking fiscal calender and inventory closing
deliveryDate = this.getinvoicedate(deliveryDate);
//
if(purchIdError != _purchId)
{
purchTable.clear();
purchTable = PurchTable::find(_purchId);
if(purchTable.DocumentState == VersioningDocumentState::Approved)
{
purchFormLetterConfirm = PurchFormLetter::construct(DocumentStatus::PurchaseOrder);
purchFormLetterConfirm.update(purchTable,'InterPurchConf_'+purchTable.PurchId);
}
purchFormLetter.purchTable(purchTable);
purchFormLetter.transDate (deliveryDate);
purchFormLetter.specQty(PurchUpdate::ReceiveNow);
purchFormLetter.initParmDefault();
purchFormLetter.initParameters(purchFormLetter.purchParmUpdate(),Printout::After);
purchFormLetter.initLinesQuery();
select forUpdate Num from purchParmTable
where purchParmTable.ParmId == purchFormLetter.parmId();
if(purchParmTable)
{
ttsBegin;
purchParmTable.Num = deliveryNote;
purchParmTable.update();
ttsCommit;
}
purchFormLetter.run();
if (purchformletter.parmjournalrecord().tableid == tablenum(vendpackingslipjour))
{
ret = true;
}
}
}
}
catch
{
this.insertErrorLog(purchTable.InterCompanySalesId,SON_POPackingSlipDD::HasError());
infolog.clear();
//info(strFmt('%1',SON_POPackingSlipDD::HasError()));
purchIdError = purchTable.PurchId;
ret = false;
retry;
}
return ret;
}