/// <summary>
/// Thiss Class is an extension of WhsWorkExecuteDisplayMovement
/// </summary>
[ExtensionOf(classStr(WhsWorkExecuteDisplayMovement))]
final class XDDWhsWorkExecuteDisplayMovement_Extension
{
#WHSRF
#Define.JournalName('JournalName')
/// <summary>
/// This method is used to get build the controls
/// </summary>
/// <param name = "_con">container</param>
/// <param name = "_locationId">WMSLocationId</param>
/// <returns>container</returns>
public container buildMovementFrom(container _con, WMSLocationId _locationId)
{
container ret = _con;
ret = next buildMovementFrom(_con,_locationId);
ret = this.buildJournalName(ret, '', false, false, false, pass.lookupStr(#JournalName), false);
int i;
container lastValue = conPeek(ret,conLen(ret));
container tags;
for(i = 1; i <= conLen(ret)-1; i++)
{
if(i!=3)
{
if (i <=3)
{
container field = conPeek(ret,i);
tags = conIns(tags,i,field);
}
else
{
container field = conPeek(ret,i);
tags = conIns(tags,i+1,field);
}
}
else
{
tags = conIns(tags,i,lastValue);
container field = conPeek(ret,i);
tags = conIns(tags,i+1,field);
}
}
return tags ? tags : ret ;
}
/// <summary>
/// This method is used to build journal names
/// </summary>
/// <param name = "_con">container</param>
/// <param name = "_label">str</param>
/// <param name = "_showRemove">boolean</param>
/// <param name = "_showBlank">boolean</param>
/// <param name = "_showOK">boolean</param>
/// <param name = "_selected">str</param>
/// <param name = "_enabled">boolean</param>
/// <returns>container</returns>
public container buildJournalName(
container _con,
str _label = '',
boolean _showRemove = false,
boolean _showBlank = false,
boolean _showOK = true,
str _selected = '',
boolean _enabled = true)
{
container ret = _con;
boolean first = true;
str elements;
ListEnumerator journalname = this.journalNameToShow().getEnumerator();
while (journalname.moveNext())
{
if (first)
{
elements += journalname.current();
first = false;
}
else
{
elements = elements + '||' + journalname.current();
}
}
ret += [this.buildControl(#RFCombobox, #JournalName , "@SYS35283", 1, elements, #WHSRFUndefinedDataType, '', 0, 1, _selected, WHSRFColorText::Default, extendedTypeNum(JournalNameId))];
if (_showRemove)
{
ret += [this.buildControl(#RFButton, "@SYS26394", "@SYS26394", 1, '', #WHSRFUndefinedDataType, '', 0)];
}
if (_showOK)
{
ret += [this.buildControl(#RFButton, #RFOK, "@SYS5473", 1, '', #WHSRFUndefinedDataType, '', 1)];
}
return ret;
}
/// <summary>
/// Returns a list of journal name to show.
/// </summary>
/// <returns>A list of journal Name ids.</returns>
public List journalNameToShow()
{
InventJournalName inventJournalName;
#Define.Empty('')
List result = new List(Types::String);
//result.addStart("");
while select JournalNameId from inventJournalName
where inventJournalName.XDDProcessBudget == NoYes::Yes
&& inventJournalName.JournalType == InventJournalType::Movement
&& inventJournalName.XDDDefaultGeneralJournal != #Empty
{
result.addEnd(inventJournalName.JournalNameId);
}
return result;
}
/// <summary>
/// This method is used to build the values
/// </summary>
/// <param name = "_con">container</param>
/// <param name = "_locationId">WMSLocationId</param>
/// <returns>container</returns>
public container buildMovementTo(container _con, WMSLocationId _locationId)
{
container ret = _con;
ret = next buildMovementTo(_con, _locationId);
int i;
for(i = 1; i <= conlen(ret); i++)
{
container field = conpeek(ret,i);
if (conpeek(field,2)== #locorlp)
{
field = conpoke(field, 5, pass.lookupstr(#locorlp));
ret = conpoke(ret, i,field);
break;
}
}
return ret;
}
}
------------------------------------------------------------------------------------------------------
/// <summary>
/// This class is a COC of WhsWorkExecuteDisplay
/// </summary>
[ExtensionOf(classStr(WhsWorkExecuteDisplay))]
final class XDDWhsWorkExecuteDisplay_Extension
{
/// <summary>
/// This method is used to get error/success logs and post the journal
/// </summary>
/// <param name = "_con">container</param>
/// <param name = "_error">str</param>
/// <param name = "_color">WHSRFColorText</param>
/// <returns>container</returns>
container addErrorLabel(container _con,
str _error,
WHSRFColorText _color)
{
#WHSRF
#Define.JournalName('JournalName')
#Define.ItemMovement('Item Movement')
container ret = _con;
if (pass.exists(#JournalName)
&& _color == WHSRFColorText::Success
&& pass.lookupStr(#MenuItem) == #ItemMovement)
{
//Create movement journal
XDDCreateMovementJournal movementJournal = new XDDCreateMovementJournal();
movementJournal.createjournal(pass.lookupStr(#JournalName),
pass.lookupStr(#ItemId),
pass.lookupNum(#Qty),
pass.lookup(#UOM),
pass.createInventDimFromPass());
}
ret = next addErrorLabel(_con, _error, _color);
return ret;
}
}
----------------------------------------------------------------------------------------
/// <summary>
/// This class is used to create the movement journal
/// </summary>
class XDDCreateMovementJournal
{
/// <summary>
/// This method is used to create the journal
/// </summary>
/// <param name = "_inventJournalNameId">InventJournalNameId</param>
/// <param name = "_itemId">ItemId</param>
/// <param name = "_qty">InventQty</param>
/// <param name = "_uom">UnitOfMeasureSymbol</param>
/// <param name = "_inventDim">InventDim</param>
public void createjournal(InventJournalNameId _inventJournalNameId,
ItemId _itemId, InventQty _qty,
UnitOfMeasureSymbol _uom, InventDim _inventDim)
{
InventJournalName inventJournalName;
InventJournalTable inventJournalTable;
InventJournalTrans inventJournalTrans;
JournalCheckPost journalCheckPost;
inventJournalName = InventJournalName::find(_inventJournalNameId);
inventJournalTable.clear();
inventJournalTable.initFromInventJournalName(inventJournalName);
inventJournalTable.XDDFinancialDimensions = (inventJournalName.XDDProcessBudget == NoYes::Yes) ? inventJournalName.XDDFinancialDimensions : 0;
inventJournalTable.insert();
inventJournalTrans.clear();
inventJournalTrans.initValue();
inventJournalTrans.initFromInventJournalTable(inventJournalTable);
inventJournalTrans.TransDate = DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone());
inventJournalTrans.ItemId = _itemId;
inventJournalTrans.initFromInventTable(InventTable::find(inventJournalTrans.ItemId));
inventJournalTrans.modifiedField(fieldNum(InventJournalTrans, ItemId));
InventDim inventDimloc = InventDim::find(_inventDim.inventDimId);
inventJournalTrans.InventDimId = _inventDim.inventDimId;
inventJournalTrans.modifiedField(fieldNum(inventJournalTrans, InventDimId));
inventJournalTrans.Qty = -abs(_qty);
inventJournalTrans.modifiedField(fieldNum(inventJournalTrans, Qty));
inventJournalTrans.DefaultDimension = inventJournaltable.XDDFinancialDimensions;
InventJournalTrans.Unit = _uom;
inventJournalTrans.modifiedField(fieldNum(inventJournalTrans, Unit));
select firstonly inventJournalName
where inventJournalName.JournalNameId == inventJournalTable.JournalNameId
&& inventJournalName.JournalType == InventJournalType::Movement
&& InventJournalName.XDDProcessBudget == NoYes::Yes;
InventJournalTrans.DefaultDimension = inventJournaltable.XDDFinancialDimensions;
inventJournalTrans.LedgerDimension = InventJournalName.LedgerDimension;
inventJournalTrans.XDDFinancialDimensions = LedgerJournalName::find(inventJournalName.XDDDefaultGeneralJournal).DefaultDimension;
inventJournalTrans.setCostPrice('', inventDimloc);
inventJournalTrans.insert();
InventJournalTrans.reread();
if (InventJournalTrans.CostPrice == 0 && InventJournalTrans.CostAmount == 0)
{
throw error ("@XDD:WithoutCost");
}
//updating number of lines field at header level of Movement Journal
inventJournalTable.NumOfLines = 1;
inventJournalTable.update();
//The below code posts the journal
journalCheckPost = InventJournalCheckPost::newPostJournal(inventJournalTable);
journalCheckPost.runOperation();
}
}
No comments:
Post a Comment