void clicked()
{
super();
//select PurchId from purchtable
//join purchline
//where purchline.ItemId==RentalLinesIntake.Rentalreference // itemid
//
//join PackingSlipId from vendPackingSlipJour
//where vendPackingSlipJour.PurchId == purchtable.PurchId;
select PurchId from purchline
where purchline.ItemId == RentalLinesIntake.Rentalreference;
info(purchline.PurchId);
if (purchline.PurchId)
{
select PackingSlipId from vendPackingSlipJour
where vendPackingSlipJour.PurchId == purchline.PurchId;
createRentalProductmaster.reverseProductReciept(purchline.PurchId,vendPackingSlipJour.PackingSlipId);
}
}
note : class createRentalProductmaster/ reverseProductReciept
public void reverseProductReciept(PurchId _purchid ,ProductReceiptId _productReceiptId)
{
VendPackingSlipJour vendPackingSlipJour;
PurchFormLetter purchFormLetter;
purchTableRevPr = PurchTable::find(_purchid);
//Retrieve existing vend packingslip
select firstOnly vendPackingSlipJour
where vendPackingSlipJour.PackingSlipId == _productReceiptId;
purchFormLetter = PurchFormLetter::construct(DocumentStatus::PackingSlip);
//If the correct VersioningUpdateType is not set
//the system will try to create a new packingslip
PurchFormLetter.parmVersioningUpdateType(VersioningUpdateType::Cancel);
PurchFormLetter.parmCallerTable(vendPackingSlipJour);
//The rows bellow are very important. Not really sure why
PurchFormLetter.allowEmptyTable(true);
PurchFormLetter.initAllowEmptyTable(true);
PurchFormLetter.multiForm(true);
purchFormLetter.update( purchTableRevPr, // Purchase record buffer
vendPackingSlipJour.PackingSlipId, // Packingslip Number
VendPackingSlipJour.DeliveryDate, // Transaction Date
PurchUpdate::ReceiveNow, // Quantity update
AccountOrder::None,
NoYes::No,
NoYes::No,
NoYes::Yes);
//if (purchTable.PurchStatus==PurchStatus::Backorder)
//{
//info(strFmt(" product reciept -%1 has reversed ",_productReceiptId));
//
//}
//else
//{
//info("product reciept reversal failed");
//}
}
No comments:
Post a Comment