1. SalesTable form SalesLine data source ValidateWrite() :-
/// <summary>
/// Class for SalesTable form data source
/// </summary>
[ExtensionOf(formDataSourceStr(SalesTable,SalesLine))]
final class BASSalesTableSalesLineDS_Extension
{
/// <summary>
///Checks if the Physical inventory is available for items
///If not give check failed warnning to the user
/// </summary>
/// /// <returns>Check failed warnning.</returns>
public boolean validateWrite()
{
boolean ret = next validateWrite();
FormDataSource formDataSource = this;
SalesLine salesLineDs = formDataSource.cursor();
InventTable inventTable;
select firstonly BASCheckInvent from inventTable
where inventTable.ItemId == SalesLineds.ItemId;
if(inventTable.BASCheckInvent == NoYes::Yes)
{
InventSum inventSum;
select firstonly PhysicalInvent from inventSum
where inventSum.ItemId == salesLineDs.ItemId
&& inventSum.InventDimId == salesLineDs.InventDimId;
if(inventSum.PhysicalInvent < salesLineDs.SalesQty)
{
ret = checkFailed(strFmt("Only '%1' inventory available for item '%2'",inventSum.PhysicalInvent,salesLineDs.ItemId));
}
}
return ret;
}
}
2. active() :-
/// <summary>
/// This class is an extension of Sales table list page
/// </summary>
[ExtensionOf(formDataSourceStr(SalesTableListPage,SalesTable))]
final class BASPOcreationButtonControl_Extension
{
/// <summary>
///Checks Salestatus in sales table list page form if Status is Invoiced
///Disable the Create purchase order buttom
/// </summary>
/// <returns>active()</returns>
public int active()
{
int ret;
ret = next active();
SalesTable salesTable = this.cursor();
FormControl poCreate = this.formRun().design().controlName(formControlStr(SalesTableListPage,BAS_POCreation));
if(salesTable.SalesStatus == SalesStatus::Invoiced)
{
poCreate.enabled(false);
}
else
{
poCreate.enabled(true);
}
return ret;
}
}
3. active () :-
/// <summary>
/// This class is an extension of Purchtable list page
/// </summary>
[ExtensionOf(formDataSourceStr(PurchTable,PurchTable))]
final class BASPurchTableFormButton_Extension
{
/// <summary>
///Checks Purchstatus in purch table table list page form if Status is Invoiced
///Disable the Receive items buttom
/// </summary>
/// <returns>active()</returns>
public int active()
{
int ret;
PurchTable purchTable = this.cursor();
FormControl itemReceive = this.formRun().design().controlName(formControlStr(PurchTable,BAS_ItemReceive));
if(purchTable.PurchStatus == PurchStatus::Received || purchTable.PurchStatus == PurchStatus::Invoiced)
{
itemReceive.enabled(false);
}
else
{
itemReceive.enabled(true);
}
ret = next active();
return ret;
}
}
4. write() :-
[ExtensionOf(FormDataSourcestr(PurchTable, PurchLine))]
final class BASSupplimenteryItemInsert_Extension
{
public void write()
{
next write();
PurchLine purchLine,supplementLine,purchLineLoc;
SuppItemTable supplementItem;
FormDataSource purchLine_ds = this;
purchLine = this.cursor();
select count(RecId) from supplementItem
where supplementItem.ItemRelation == purchLine.ItemId;
if(supplementItem.RecId != 0)
{
DialogButton dialogButton;
//Initial focus is on the No button.
dialogButton = Box::yesNo('Do you want to add supplementery items',dialogButton::Yes, "Proceed or Dont");
if(dialogButton == DialogButton::Yes)
{
PurchTable purchTable = PurchTable::find(purchLine.PurchId);
while select SuppItemId from supplementItem
where supplementItem.ItemRelation == purchLine.ItemId
notexists join purchLineLoc
where purchLineLoc.ItemId == supplementItem.SuppItemId
&& purchTable.PurchId == purchLineLoc.PurchId
{
ttsbegin;
supplementLine.initFromPurchTable(purchTable);
supplementLine.PurchId = purchLine.PurchId;
supplementLine.ItemId = supplementItem.SuppItemId;
supplementLine.InventDimId = purchLine.InventDimId;
supplementLine.skipDataSourceValidateWrite(true);
supplementLine.insert();
//supplementLine.createLine(true, true, true, true, true, false);
supplementLine.clear();
ttscommit;
}
purchLine_ds.research();
info("Supplementery items have been added");
}
else if (dialogButton == DialogButton::No)
{
error("Supplementery items must be added");
}
}
}
5. ValidateDelete() :-
public boolean validateDelete()
{
boolean ret;
ret = next validateDelete();
FormDataSource formDataSource = this;
PurchLine selectedPurchLine = formDataSource.cursor();
purchLine purchLine,purch;
SuppItemTable supplementItem,supplyItem;
//Master item validation
//here ItemRelation field is master item and SuppitemId is Supplement Item
while select ItemRelation,SuppItemId from supplementItem
where supplementItem.ItemRelation == selectedPurchLine.ItemId
{
delete_from purchLine where purchLine.ItemId == supplementItem.SuppItemId
&& purchLine.PurchId == selectedPurchLine.PurchId;
//ret = info(strFmt("Master item %1",selectedPurchLine.ItemId));
}
//Supplement item validation
while select ItemRelation,SuppItemId from supplementItem
where supplementItem.SuppItemId == selectedPurchLine.ItemId
{
while select ItemId from purchLine
where purchLine.PurchId == selectedPurchLine.PurchId
&& purchLine.ItemId == supplementItem.ItemRelation
{
if(supplementItem.ItemRelation && purchLine.ItemId)
{
ret = checkFailed(strFmt("cannot delete Item %1 has master item %2",selectedPurchLine.ItemId,purchLine.ItemId));
}
}
}
formDataSource.research();
return ret;
}
}
6. initValue() and Create() :-
[ExtensionOf(FormDataSourceStr(PurchTable,PurchLine))]
final class BAS_PurchTableForm_Extension
{
public void initValue()
{
next initValue();
FormDataSource fmDS = this;
PurchLine ptable = this.cursor();
ptable.ItemId = "0088";
}
public void create(boolean append)
{
next create();
FormDataSource ds = this;
PurchLine pdtable = this.cursor();
pdtable.ItemId = "0101";
pdtable.LineDisc = 12.22;
pdtable.LinePercent = 60.66;
}
}
7. active() :-
[ExtensionOf(formDataSourceStr(SalesCopying,CustInvoiceTrans))]
//Where we are doing operation
final class BAS_ReturnAbleItemInventTable_Extension
{
public int active()
{
int ret = next active();
FormDataSource ds = this;
FormDataSource FDS = ds.formRun().dataSource("CustInvoiceTrans");
CustInvoiceTrans custinvoicetrans = FDS.cursor();
InventTable inventtable;
select BAS_Returnable from inventtable
where inventtable.ItemId == CustInvoiceTrans.ItemId;
FormControl formcontol = this.formRun().design().controlName(formControlStr(SalesCopying,OK));
if( inventtable.BAS_Returnable == NoYes::No)
//Here i want to disable that BAS_Calculate button After Clicking that BAS_Calculate then it will popup that BAS_LineAmount
{
formcontol.enabled(false);
}
else
{
formcontol.enabled(true);
}
return ret;
}
}
[ExtensionOf(FormDataSourcestr(MarkupTrans,MarkupTrans))]
final class BASBBRSalesOrderMaintainDelete_Extension
{
void delete()
{
next delete();
FormDataSource formDataSource = any2Object(this) as FormDataSource;
FormRun formRun = formDataSource.formRun();
SalesTable salesTable = formRun.args().record();
if(salesTable.getRetailChannelName())
{
SalesOrdersEventsLog salesOrdersEventLog;
ttsbegin;
salesOrdersEventLog.clear();
salesOrdersEventLog.SalesId = salesTable.SalesId;
salesOrdersEventLog.EventType = BASBBREventType::BAS_DeletionOfChargeAmount;
salesOrdersEventLog.CreatedDateAndTime = DateTimeUtil::getSystemDateTime();
salesOrdersEventLog.insert();
ttscommit;
}
}
}
Comments
Post a Comment