class CustomizedLookup extends RunBase
{
DialogField fieldAccount;
CustAccount custAccount;
DialogField dialogField , dialogText1, dialogText2, dialogText3 , dialogText4;
str refundreason, commentcs, nextOwnership;
DGS_RefundType refundType;
DGS_RefundRegister existingRefund;
real _refundAmount, _maxRefundAmount;
SalesId salesId;
public Object dialog()
{
FormBuildStringControl _stringControl;
//Dialog dialog = new Dialog();
DialogRunbase dialog = super();
str strMessage = strFmt("Are you sure you want to create refund register for %1, please provide below details.", salesId);
str strTitle = "create refund register";
;
DGS_SalesTableCalculation salesTableCal = DGS_SalesTableCalculation::find(SalesId);
select sum(refundamount) from existingRefund where existingRefund.salesid == SalesId;
_refundAmount = (salesTableCal.TotalAmount > existingRefund.refundamount)? (salesTableCal.TotalAmount - existingRefund.refundamount):0;
if(_refundAmount)
{
_maxRefundAmount = _refundAmount;
Dialog.addText(strMessage);
if(salesTableCal.TotalAmount == _refundAmount)
{
dialogField = dialog.addField(enumStr(DGS_RefundType));
DialogField.value(DGS_RefundType::Full);
}
else
{
dialogField = dialog.addField(enumStr(DGS_RefundType));
DialogField.value(DGS_RefundType::Partial);
}
// add lookup on dialog
dialogText1 = dialog.addField(extendedTypeStr(ReasonComment));
_stringControl = dialogText1.control();
_stringControl.registerOverrideMethod(methodStr(FormStringControl, lookup),
methodStr(CustomizedLookup, refundTypelookup), this);
//dialogText1 = dialog.addField(extendedTypeStr(String50), 'Refund Reason');
//dialogText1.value('Internal issue');
dialogText2 = dialog.addField(extendedTypeStr(String50), 'Comment (CS)');
dialogText2.limitText(500);
dialogText3 = dialog.addField(extendedTypeStr(String50),'Next Ownership');
dialogText3.value('compliance');
dialogText4 = dialog.addField(extendedTypeStr(RealBase), 'Refund Amount');
dialogText4.value(_refundAmount);
}
else
{
Error(strFmt('%1 Full Refunded, please check via Refund Register.', SalesId));
}
return dialog;
}
public boolean getFromDialog()
{
refundType = dialogField.value();
refundreason = dialogText1.value();
commentcs = dialogText2.value();
nextOwnership = dialogText3.value();
_refundAmount = dialogText4.value();
return super();
}
public container pack()
{
return conNull();
}
public void run()
{
if(_refundAmount > _maxRefundAmount)
{
Error(strFmt('Refund amount %1 over max refund amount %2.', _refundAmount , _maxRefundAmount));
}
else
{
DGS_CreateRefundRegister::createRefundRegister(SalesId,refundType,refundreason,commentcs,nextOwnership, _refundAmount);
}
}
public boolean unpack(container _packedClass)
{
return true;
}
public static void main(Args _args)
{
CustomizedLookup custAmountCalculation = new CustomizedLookup();
if (CustAmountCalculation.prompt())
{
CustAmountCalculation.run();
}
}
public SalesId parmSalesId(SalesId _salesId = salesId)
{
SalesId = _salesId;
return SalesId;
}
public void refundTypelookup(FormStringControl _control)
{
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(DGS_ReasonTable),
_control);
// Create lookup
sysTableLookup.addLookupField(fieldNum(DGS_ReasonTable, ReasonType));
sysTableLookup.addLookupField(fieldNum(DGS_ReasonTable, Reason), true);
// Setup query
queryBuildDataSource = query.addDataSource(tableNum(DGS_ReasonTable));
queryBuildDataSource.addRange(fieldNum(DGS_ReasonTable,ReasonType)).value(enum2Str(DGS_ReasonType::Refund));
sysTableLookup.parmQuery(query);
// Perform lookup
sysTableLookup.performFormLookup();
}
}
留言列表