M18 ERP Decorators (Frontend Interface)

Version: 1.1 | Release Date: 7/12/2018

AccountEditorDecorator

Interface Definition

This decorator is used to handle field change actions in [Account] editor.

public interface AccountEditorDecorator extends ViewDecorator {

	public default void afterUpdateAccountSetting(String triggerFieldName) {
	}
}

Usage

In [Account] Editor, when fields are updated (like change the value of < Parent A/C > or < Bank Account >), M18 will notify AccountEditorDecorator afterUpdateAccountSetting function.

	private void updateAcccountSetting(String triggerFieldName) {
		...
		
		controller.notifyDecorator(AccountEditorDecorator.class, (decorator, params) -> decorator.afterUpdateAccountSetting((String) params[0]), new Object[] { triggerFieldName });

		WebUtil.update(getMTName() + "_bankAcc", getMTName() + "_cashAcc", getMTName() + "_adjExAcc", ...);
	}

In 3PD App, you can set your backingBean or viewListener implements AccountEditorDecorator , And Override afterUpdateAccountSetting function.

public class AccountListener implements AccountEditorDecorator {
	
	@Override
	public void afterUpdateAccountSetting(String triggerFieldName) {
		// do something, like "WebUtil.setDisabled(true, field);
	}
    
	...
}	

Detail Description

Update Account Fields

	public default void afterUpdateAccountSetting(String triggerFieldName) {
	}

Description

It will trigger when update account fields in [Account] Editor.

Parameters

Name Type Description
triggerFieldName String The trigger field name

BatchGenDataDecorator

Interface Definition

This decorator is used to handle footer table data in [Turbo Document Generation] editor.

public interface BatchGenDataDecorator extends ViewDecorator {
	public void afterLoadData(SqlTable sourceTable);
}

Usage

In [Turbo Document Generation], when data is loaded, M18 will notify BatchGenDataDecorator afterLoadData function.

	public void loadBatchGenData(SqlTable sourceTable, JSONObject extraParam) {
    	...
		getController().notifyDecorator(BatchGenDataDecorator.class,
			(decorator, params) -> decorator.afterLoadData((SqlTable) params[0]), 
            	new Object[] { sourceTable });
	}

In 3PD App, you can set your backingBean or viewListener implements BatchGenDataDecorator , and override afterLoadData function.

public class XxxListener implements BatchGenDataDecorator {

	@Override
	public void afterLoadData(SqlTable sourceTable) {
		//do something data loaded
	}
	...
}

Detail Description

Loading data to be generated

	public default void afterLoadData(SqlTable sourceTable) {

	}

Description

It will be triggered after footer table data loaded in [Turbo Document Generation].

Parameters

Name Type Description
sourceTable SqlTable selected data source

ITradingCalcDecorator

Interface Definition

This decorator is used to handle common field change actions in trading editors.

public interface ITradingCalcDecorator extends ViewDecorator {

	public default void before_update_adisc(IMacCalculateHelper calcHelper) {

	}

	public default void after_update_adisc(IMacCalculateHelper calcHelper) {

	}
	...
}	

Usage

In Trading App, when common fields are updated, M18 will notify ItradingCalcDecorator before_update_xxx function and after_update_xxx functions.

	public void calc_update_adisc() {
		controller.notifyDecorator(ITradingCalcDecorator.class, (decorator, params) -> decorator.before_update_adisc((IMacCalculateHelper) params[0]), new Object[] { calcHelper });

		efe_calc_update_adisc();

		controller.notifyDecorator(ITradingCalcDecorator.class, (decorator, params) -> decorator.after_update_adisc((IMacCalculateHelper) params[0]), new Object[] { calcHelper });
	}

In 3PD App, you can set your backingBean or viewListener implements ItradingCalcDecorator, And Override before_update_xxx and after_update_xxx functions.

public class TrdgVatTradeMainFooterListener implements ITradingCalcDecorator {

	@Override
	public void before_update_xxx(IMacCalculateHelper calcHelper) {
		//do something
	}

	@Override
	public void after_update_xxx(IMacCalculateHelper calcHelper) {
		//do something
	}
	...
}

Detail Description

	public default void before_update_qup(IMacCalculateHelper calcHelper, int rec, SqlTable srcTable, boolean must_update) {

	}

	public default void after_update_qup(IMacCalculateHelper calcHelper, int rec, SqlTable srcTable, boolean must_update) {

	}

Description

It will be triggered when update the value of < Quoted Price > field in product table of trading transactions.

Parameters

Name Type Description
calcHelper IMacCalculateHelper MacCalculateHelper
rec int The row index of Footer Table
srcTable SqlTable The Footer Table
must_update boolean If reload_price_one_pro , must_update is true; else must_update is false.

	public default void before_a_mainfooter_disc(IMacCalculateHelper calcHelper, int rec, double inOldValue) {

	}

	public default void after_a_mainfooter_disc(IMacCalculateHelper calcHelper, int rec, double inOldValue) {

	}

Description

It will be triggered when update the value of < Disc. (%) > field in product table of trading transactions.

Parameters

Name Type Description
calcHelper IMacCalculateHelper MacCalculateHelper
rec int The row index of Footer Table
inOldValue double The old value of < Disc. (%) > field

	public default void before_a_mainfooter_amt(IMacCalculateHelper calcHelper, int rowIndex) {

	}

	public default void after_a_mainfooter_amt(IMacCalculateHelper calcHelper, int rowIndex) {

	}

Description

It will be triggered when update the value of < Amount > field in product table of trading transactions.

Parameters

Name Type Description
calcHelper IMacCalculateHelper MacCalculateHelper
rowIndex int The row index of Footer Table

	public default void before_mainfooter_up(IMacCalculateHelper calcHelper, int rowIndex, SqlTable srcTable, boolean fromUc) {

	}

	public default void after_mainfooter_up(IMacCalculateHelper calcHelper, int rowIndex, SqlTable srcTable, boolean fromUc) {

	}

Description

It will be triggered when update the value of < Unit Price > field in product table in trading transactions. For example it will be triggered with price is loaded from price origin.

Parameters

Name Type Description
calcHelper IMacCalculateHelper MacCalculateHelper
rowIndex int The row index of Footer Table
srcTable SqlTable The Pro Price Origin Table
fromUc boolean Use upField or ucField In srcTable

	public default void before_a_mainfooter_up(IMacCalculateHelper calcHelper, int rec) {

	}

	public default void after_a_mainfooter_up(IMacCalculateHelper calcHelper, int rec) {

	}

Description

It will be triggered when update the value of < Unit Price > field in product table of trading transactions.

Parameters

Name Type Description
calcHelper IMacCalculateHelper MacCalculateHelper
rec int The row index of Footer Table

	public default void before_mainfooter_desc(IMacCalculateHelper calcHelper, int rowIndex, SqlTable srcTable) {

	}

	public default void after_mainfooter_desc(IMacCalculateHelper calcHelper, int rowIndex, SqlTable srcTable) {

	}

Description

It will be triggered when update the value of < Brief Desc >, < Detailed Desc > fields in product footer of trading transactions. For example it is triggered when the descriptions are loaded from description origin.

Parameters

Name Type Description
calcHelper IMacCalculateHelper MacCalculateHelper
rowIndex int The row index of Footer Table
srcTable SqlTable The Pro Desc Origin Table

	public default void before_a_mainfooter_qty(IMacCalculateHelper calcHelper, int rowIndex) {

	}

	public default void after_a_mainfooter_qty(IMacCalculateHelper calcHelper, int rowIndex) {

	}

Description

It will be triggered when update the value of < Quantity > field in product table of trading transactions.

Parameters

Name Type Description
calcHelper IMacCalculateHelper MacCalculateHelper
rowIndex int The row index of Footer Table

	public default void before_a_mainfooter_lotnoOutQty(IMacCalculateHelper calcHelper, int rowIndex) {

	}

	public default void after_a_mainfooter_lotnoOutQty(IMacCalculateHelper calcHelper, int rowIndex) {

	}

Description

It will be triggered when update the value of < Quantity (w/o Lot No.) > field in product table of trading transactions.

Parameters

Name Type Description
calcHelper IMacCalculateHelper MacCalculateHelper
rowIndex int The row index of Footer Table

	public default void before_up_byUnit(IMacCalculateHelper calcHelper, int rowIndex, long oldUnitId) {

	}

	public default void after_up_byUnit(IMacCalculateHelper calcHelper, int rowIndex, long oldUnitId) {

	}

Description

It will be triggered when update the value of < Unit > field in product table of trading transactions.

Parameters

Name Type Description
calcHelper IMacCalculateHelper MacCalculateHelper
rowIndex int The row index of Footer Table
oldUnitId long The old value of < Unit > field

Total Charge/Discount

	public default void before_update_adisc(IMacCalculateHelper calcHelper) {

	}

	public default void after_update_adisc(IMacCalculateHelper calcHelper) {

	}

Description

It will be triggered when calculate < Total Charge > / < Total Discount > in header of trading transactions.

Parameters

Name Type Description
calcHelper IMacCalculateHelper MacCalculateHelper

Amount in Add. Charge/Discount

	public default void before_a_adisc_amt(IMacCalculateHelper calcHelper, int rec) {

	}

	public default void after_a_adisc_amt(IMacCalculateHelper calcHelper, int rec) {

	}

Description

It will be triggered when change the value of < Amount > field In [Additional Discount/Charge] table.

Parameters

Name Type Description
calcHelper IMacCalculateHelper MacCalculateHelper
rec int The row index of [Additional Discount/Charge] table

Charge/Discount % in Add. Charge/Discount

	public default void before_a_adisc_discrate(IMacCalculateHelper calcHelper, int rec) {

	}

	public default void after_a_adisc_discrate(IMacCalculateHelper calcHelper, int rec) {

	}

Description

It will be triggered when change the value of < Charge/Discount% > field In [Additional Discount/Charge] table.

Parameters

Name Type Description
calcHelper IMacCalculateHelper MacCalculateHelper
rec int The row index of [Additional Discount/Charge] table

ITransactionDecorator

Interface Definition

This decorator is used to handle additional charge / discount field changes during source transaction loading in trading edtiors.

public interface ITransactionDecorator extends ViewDecorator {

	public void beforeAssignDisc(SqlTable lookupTable);

	public void afterAssignDisc();
}

Usage

In Trading App, when loading Additional Discount / Charge data of source transaction, it will notify ITransactionDecorator beforeAssignDisc function and afterAssignDisc function.

	private void assign_so_disc(SqlTable sodisc) {
		if (sodisc != null && sodisc.size() > 0) {
			controller.notifyDecorator(ITransactionDecorator.class,
					(decorator, params) -> decorator.beforeAssignDisc((SqlTable) params[0]), new Object[] { sodisc });
			...
			controller.notifyDecorator(ITransactionDecorator.class,
					(decorator, params) -> decorator.afterAssignDisc(), null);
		}
	}

In 3PD App, you can set your backingBean or viewListener implements ITransactionDecorator, and override beforeAssignDisc function and afterAssignDisc function .

public class TrdgVatTradeMainFooterListener extends TransactionDecorator
		implements ModuleViewListener, ITradingCalcDecorator {
	@Override
	public void beforeAssignDisc(SqlTable lookupTable) {
		if (VatUtil.isVatPerItem(getBeId())) {
			if (lookupTable != null && lookupTable.size() > 0) {
				// handler vat fields (like taxAmt preTaxAmt)
			}
		}
	}
	
	@Override
	public void afterAssignDisc() {
		if (VatUtil.isVatEnabled(getBeId())) {
			updateVatCalFields();
		}
	}
}

Detail Description

Additional Charge/Discount Loading

	public void beforeAssignDisc(SqlTable lookupTable);

	public void afterAssignDisc();

Description

It will be triggered when handler Additional Discount / Charge info of source transaction is loaded.

Parameters

Name Type Description
lookupTable SqlTable The Additional Discount / Charge info of source transaction

PrqGenDecorator

Interface Definition

This decorator is used to handle the extension of [MRP Generation].

public interface PrqGenDecorator extends ViewDecorator {

	public default List<String> getMoreFields() {
		return null;
	}

	public default List<FormatCond> getMoreConds() {
		return null;
	}
  	...
}

Usage

In [MRP Generation], the decorator PrqGenDecorator will be notified when loading data, assigning data, or generating transactions.

	public void refreshData() {
		// Fields
		List<String> fieldList = Arrays.asList("tranType", "tranId", "pproId", "proId", "bDesc", 
                                               "lot", "qty", "unitId", "dDate");

		DecorateVisitCallback<PrqGenDecorator> fieldsCallBack = new 
          DecorateVisitCallback<PrqGenDecorator>() {
			@Override
			public boolean visited(PrqGenDecorator decorator, Object returnObject) {
				if (returnObject != null) {
					@SuppressWarnings("unchecked")
					List<String> addFields = (List<String>) returnObject;
					if (addFields != null) {
						for (String field : addFields) {
							if (!fieldList.contains(field)) {
								fieldList.add(field);
							}
						}
					}
				}
				return true;
			}
		};
      	controller.visitDecorator(PrqGenDecorator.class, (decorator, params) -> 
                                  decorator.getMoreFields(), new Object[] {}, fieldsCallBack);
	}

In 3PD App, you can set your viewListener implements PrqGenDecorator, and override the functions.

public class XxxListener implements PrqGenDecorator {
	@Override
	public List<String> getMoreFields() {
		// Get more fields when loading data
	}
  	...
}

Detail Description

Loading Data

	public List<String> getMoreFields() {
        // Define the list of extra fields 
    }

	public List<FormatCond> getMoreConds() {
        // Define the extra conditions to loading data
    }

	public void beforeAssignedData(long beId, SqlTable searchTable) {
        // Do something before system assigning data
    }

	public void assignedShowField(SqlTable showTable, int rec, SqlTable searchTable, int index)
    {
        // Do something after system assigned data to one row
    }

Description

Functions above will be triggered when loading data, in function refreshData() of PrqGenBean.java.

Parameters

Name Type Description
beId long Current Business Entity
searchTable SqlTable Data loaded
rec int The row index of showTable
showTable SqlTable The footer table in [MRP Generation]
index int The row index of searchTable

Generating Transactions

	public default CheckMsg validTableData(SqlTable showTable) {
		// Add checking before generating transactions
	}

	public default List<String> getRequiredFields(String moduleName) {
		// Define extra compulsory fields
	}

	public default void beforeSeparateRecored(SqlTable showTable) {
		// Do something before separating records
	}

Description

Functions above will be triggered when generating transactions, in function batchGenData(ViewActionEvent vae) of PrqGenBean.java.

Parameters

Name Type Description
showTable SqlTable The footer table in [MRP Generation]
moduleName Sting The name of module

UpdatePriceListDecorator

Interface Definition

This decorator is used to handle field changes in [Price List (Matrix)] editor.

public interface UpdatePriceListDecorator extends ViewDecorator {

	public default void afterLoadProductList(SqlTable priceList) {
	}

	public default void beforeSavePriceList(SqlEntity entity, int entityFooterRowIndex, SqlTable priceList, int priceListRowIndex) {
	}

	public default void afterUplBEChanged(long beId) {
	}
}

Usage

In [Price List (Matrix)] Editor, when some fields are changed, M18 will notify UpdatePriceListDecorator afterUplBEChanged function.

	@Override
	public void valueChange(ValueChangeEvent vce) {
		super.valueChange(vce);
		String compId = vce.getComponent().getId();
		if (compId.equals("beList")) {
				...
				controller.notifyDecorator(UpdatePriceListDecorator.class, (decorator, params) -> decorator.afterUplBEChanged((long) params[0]), new Object[] { beId });
				...
			}
		}
	}

In 3PD App, you can set your backingBean or viewListener implements UpdatePriceListDecorator, And Override afterUplBEChanged or other provided functions.

public class TrdgVatUpdatePriceListListener implements ViewListener, UpdatePriceListDecorator {
	
	@Override
	public void afterUplBEChanged(long beId) {
		// handler vat fields
		controller.setVariable("vatEnabled", VatUtil.isVatEnabled(beId));
		controller.setVariable("vatPerItemEnabled", VatUtil.isVatPerItem(beId));
		controller.setVariable("beId", beId);
		WebUtil.update("priceList");
	}
	
	...
}	

Detail Description

Load Product's Price List

	public default void afterLoadProductList(SqlTable priceList) {
	}

Description

It will be triggered when load product's price list in [Price List (Matrix)] Editor.

Parameters

Name Type Description
priceList SqlTable The product price list

Save Price List

	public default void beforeSavePriceList(SqlEntity entity, int entityFooterRowIndex, SqlTable priceList, int priceListRowIndex) {
	}

Description

It will be trigger when save price list in [Price List (Matrix)] Editor.

Parameters

Name Type Description
entity SqlEntity The entity
entityFooterRowIndex int The row index of Footer Table in entity
priceList SqlTable The product price list
priceListRowIndex int The row index of price list

BE Switch

	public default void afterUplBEChanged(long beId) {
	}

Description

It will be trigger when change the value of < BE > in [Price List (Matrix)] Editor.

Parameters

Name Type Description
beId long The BE id

EcnpDecorator

Interface Definition

This decorator is used to extend the front end operation of [Engineering Change Note (Work Process)].

public interface EcnpDecorator extends ViewDecorator {
	public default void afterClearMainFooterInfo(int rowIndex) {
	}
}

Usage

In [Engineering Change Note (Work Process)], after clearing the data of the footer table, M18 will notify EcnpDecorator afterClearMainFooterInfo function.

	public void clearMainFooterInfo(int rowIndex) {
		...
		controller.notifyDecorator(EcnpDecorator.class,
				(decorator, params) -> decorator.afterClearMainFooterInfo((int) params[0]),
				new Object[] { rowIndex });
		...
	}

In 3PD App, you can set your backingBean or viewListener implements EcnpDecorator, And Override afterClearMainFooterInfoor function.

public class XxxListener implements EcnpDecorator {

	@Override
	public void afterClearMainFooterInfo(int rowIndex) {
		
	}
	...
}

Detail Description

	public void afterClearMainFooterInfo(int rowIndex) {
	}

Description

It will be trigger after clear [Engineering Change Note (Work Process)] footer table data.

Parameters

Name Type Description
rowIndex int The row index of footer table

EcnmDecorator

Interface Definition

This decorator is used to extend the front end operation of [Engineering Change Note (Material)].

public interface EcnmDecorator extends ViewDecorator {
	public default void afterClearMainFooterInfo(int rowIndex) {
	}
}

Usage

In [Engineering Change Note (Material)], after clearing the data of the footer table, M18 will notify EcnmDecorator afterClearMainFooterInfo function.

	public void clearMainFooterInfo(int rowIndex) {
		...
		controller.notifyDecorator(EcnmDecorator.class,
				(decorator, params) -> decorator.afterClearMainFooterInfo((int) params[0]),
				new Object[] { rowIndex });
		...
	}

In 3PD App, you can set your backingBean or viewListener implements EcnmDecorator, And Override afterClearMainFooterInfoor function.

public class XxxListener implements EcnmDecorator {

	@Override
	public void afterClearMainFooterInfo(int rowIndex) {
	}
	...
}

Detail Description

	public void afterClearMainFooterInfo(int rowIndex) {
	}

Description

It will be trigger after clear [Engineering Change Note (Material)] footer table data.

Parameters

Name Type Description
rowIndex int The row index of footer table

ERPViewDecorator

Interface Definition

This decorator is used to customize the change of new document data when the document "Save As" new document.

public interface ERPViewDecorator extends ViewDecorator {
	public void handlerSaveAsAction();
}

Usage

When saving a document as a new document, M18 will notify ERPViewDecorator handlerSaveAsAction function.

	@Override
	public void beforeSave(ModuleAction action) {
		...
		if (saveas) {
			controller.notifyDecorator(ERPViewDecorator.class,
				(decorator, params) -> decorator.handlerSaveAsAction(), new Object[] {});
		}
	}

In 3PD App, you can set your backingBean or viewListener implements ERPViewDecorator, And Override handlerSaveAsAction function.

public class XxxListener implements ERPViewDecorator {

	@Override
	public void handlerSaveAsAction() {
		super.handlerSaveAsAction();
	}
	...
}

Detail Description

Process data for the "Save As" new document.

public void handlerSaveAsAction() {
}

Description

It will be trigger before "Save As" new document.