In Inventory mgt > Periodic > Closing and adjustment there is the Recalculation function which I've been asked to customise so that on a daily batch the parameter "Recalculate inventory up to:" date is always today's date.
The request is that I add a checkbox directly below the date field and that (when checked) ignores the Period code or date supplied and sets the transaction date to today before running the calc (InventCostClosingRecalc).
I'm assuming that another "Period code" cannot be setup to cover this requirement but I've not looked at that a lot.
InventCostClosingRecalc extends InventCostClosing. To get the parameter to appear in the desired position I decided to extend InventCostClosing.
It seems to work ok (after Compiling forward of InventCostClosing) and I debugged the CIL batch code in VS to ensure the logic in run() is working.
But I have 2 questions...
1. Why, when you review the batch job history (Sys admin > Inquiries) clicking on View tasks and then Parameters, the parameter value of the checkbox is unchecked instead of being checked?
2. Why, when you click on Log in the same form, nothing happens but there is an error that is handled in the CIL? What should happen here? Not sure of the purpose of this Log button.
The main code changes are below because I think I must have missed something to get the above behaviour?
class InventCostClosing extends RunBaseBatch
{
// ...
DialogField dialogDateDefaultCheck;
NoYesId useDefaultDate;
// ...
#DEFINE.CurrentVersion(7)
#LOCALMACRO.CurrentList
TransDate,
Specification,
ProdJournal,
UpdateLedger,
FreeTxt,
MaxIterations,
MinTransferValue,
adjustmentType,
cancelRecalculation,
runRecalculation,
collapseGroups,
// <GEERU>
periodCode,
inventTransCurrency,
// </GEERU>
useDefaultDate
#ENDMACRO
}
public Object dialog()
{
// ...
dialogDateDefaultCheck = dialog.addField(extendedTypeStr(NoYesId), "Default date to batch date", "help text here");
// ...
}
public boolean getFromDialog()
{
//...
useDefaultDate = dialogDateDefaultCheck.value();
//...
}
public void run()
{
// ...
try
{
this.initTransDate(false);
if(useDefaultDate)
{
transDate = systemDateGet();
}
// ...
}