internal final class DTT_InventJournalName_F_Extension
{
public int active()
{
int ret = next active();
{
this.object(fieldNum(InventJournalName,DTT_SiteMandatory)).allowEdit(true);
}
else
{
this.object(fieldNum(InventJournalName,DTT_SiteMandatory)).allowEdit(false);
}
return ret;
}
}
{
[FormDataSourceEventHandler(formDataSourceStr(InventJournalName, InventJournalName), FormDataSourceEventType::Activated)]
{
InventJournalName _table = sender.cursor();
FormDataSource table_ds=sender.formRun().dataSource(/InventJournalName/);
FormRun element = sender.formRun();
FormControl ControlName =element.design(0).controlName(/DTT_SiteNotMandatory_DTT_SiteMandatory/);
/* if(_table.JournalType == InventJournalType::Count || _table.JournalType == InventJournalType::Movement)
ControlName.allowEdit(true);
else
ControlName.allowEdit(false);*/
}
public final class DTT_InventCountCreate_C_Extension
{
public DialogField dialogSplit;
public DTT_SplitJournalPerWarehouse splitPerWarehouse;
public JournalId journalIdToCreate;
#LOCALMACRO.CurrentList
splitPerWarehouse
#ENDMACRO
{
InventJournalName inventJournalName;
InventJournalTable inventJournalTableForDialog = InventJournalTable::find(this.parmJournalId());
DialogRunbase thisDialog = next dialog();
dialogSplit = thisDialog.addField(extendedTypeStr(DTT_SplitJournalPerWarehouse));
{
if (!inventJournalTableForDialog.InventLocationId)
{
dialogSplit.value(true);
dialogSplit.allowEdit(true);
}
}
else
{
dialogSplit.value(false);
dialogSplit.allowEdit(false);
}
}
{
boolean ret = next getFromDialog();
}
{
container packedClassLocal = next pack();
return SysPackExtensions::appendExtension(packedClassLocal, classStr(DTT_InventCountCreate_C_Extension), this.myPack());
}
{
boolean result = next unpack(_packedClass);
{
container myState = SysPackExtensions::findExtension(_packedClass, classStr(DTT_InventCountCreate_C_Extension));
if (!this.myUnpack(myState))
{
result = false;
}
}
}
{
return [#CurrentVersion, #CurrentList];
}
{
Integer version = RunBase::getVersion(_packedClass);
switch (version)
{
case #CurrentVersion:
[version, #CurrentList] = _packedClass;
break;
default:
return false;
}
return true;
}
{
next run();
{
this.splitJournalPerWarehouse();
}
}
{
InventJournalTable fromInventJournalTable = InventJournalTable::find(this.parmJournalId());
InventJournalTrans inventJournalTrans;
InventDim inventDim;
// To loop on how many unique warehouses from the journal
while select inventDim
group by InventLocationId
exists join inventJournalTrans
where inventJournalTrans.JournalId == this.parmJournalId()
&& inventJournalTrans.InventDimId == inventDim.inventDimId
{
this.createNewHeader(fromInventJournalTable);
this.createNewLines(inventDim.InventLocationId);
this.postProcessing(inventDim.InventLocationId);
}
}
{
if (_fromInventJournalTable)
{
InventJournalTable toInventJournalTable;
toInventJournalTable.JournalId = NumberSeq::newGetNum(InventParameters::numRefInventJournalId(),false).num();
toInventJournalTable.SessionId = 0;
toInventJournalTable.SessionLoginDateTime = utcDateTimeNull();
toInventJournalTable.RecId = 0;
toInventJournalTable.NumOfLines = 0;
toInventJournalTable.SystemBlocked = NoYes::No;
{
toInventJournalTable.insert();
journalIdToCreate = toInventJournalTable.JournalId;
}
}
}
{
InventJournalTrans inventJournalTransLines;
InventDim inventDimLines;
int lineCounter;
while select inventJournalTransLines
join inventDimLines
where inventJournalTransLines.JournalId == this.parmJournalId()
&& inventJournalTransLines.InventDimId == inventDimLines.inventDimId
&& inventDimLines.InventLocationId == _inventLocationId
{
lineCounter++;
InventJournalTrans inventJournalTransToCreate;
inventJournalTransToCreate.JournalId = journalIdToCreate;
inventJournalTransToCreate.LineNum = lineCounter;
inventJournalTransToCreate.RecId = 0;
{
inventJournalTransToCreate.insert();
}
}
}
{
this.updateHeaderNumOfLines(_inventLocationId);
}
{
InventJournalTable inventJournalTableLocal;
InventJournalTrans inventJournalTransLocal;
where inventJournalTransLocal.JournalId == journalIdToCreate;
{
inventJournalTableLocal = InventJournalTable::find(journalIdToCreate);
if (inventJournalTableLocal)
{
ttsbegin;
inventJournalTableLocal.selectForUpdate(true);
inventJournalTableLocal.NumOfLines = inventJournalTransLocal.RecId; // To assign the number of lines to the header
inventJournalTableLocal.update();
ttscommit;
}
}
}
{
InventJournalTrans inventJournalTransToDelete;
InventJournalTable inventJournalTableToUpdate;
where inventJournalTransToDelete.JournalId == this.parmJournalId();
{
ttsbegin;
inventJournalTableToUpdate.selectForUpdate(true);
inventJournalTableToUpdate.NumOfLines = 0;
inventJournalTableToUpdate.update();
ttscommit;
}