When the finance module of ERP is integrated with production and supply chain module, the accounting vouchers will be generated when these modules are posted. If you can preview the voucher before generating the accounting voucher, it is a friendly design for the user. As shown in the credit notification slip before the account, you can preview the voucher to know the accounting documents that will be generated.
Click the Preview voucher button to see the accounting voucher that will be generated:
To achieve this, share the changes to the system.
The first is the Business Document override button event,
protected Override void Onpreviewvoucher (dictionary<string, voucherentity> voucherlist)
{
base. Onpreviewvoucher (voucherlist);
if (_expenseremibursemententity.amount > 0)
{
Voucherentity voucher = _expenseremibursementmanager.createexpenseremibursementvoucherforpreview (_ expenseremibursemententity);
if null)
Voucherlist.add (Voucher_key, VOUCHER);
}
}
By overriding this method, the base class can obtain the accounting vouchers generated by the current business document. The method prototype for generating the accounting voucher is as follows:
Public Voucherentity Createexpenseremibursementvoucherforpreview (expenseremibursemententity ExpenseRemibursement)
{
null;
using (Dataaccessadapter adapter = Getcompanydataaccessadapter (sessionId))
{
Try
{
Adapter. StartTransaction (isolationlevel.readcommitted, "createexpenseremibursementvoucherforpreview");
Expenseremibursemententity clonedadjustment = (expenseremibursemententity) shared.cloneentity (ExpenseRemibursement );
Ifiscalperiodmanager Fiscalperiodmanager = clientproxyfactory.createproxyinstance<ifiscalperiodmanager> ();
New Excludeincludefieldslist (false);
Fieldslist.add (Fiscalperiodfields.period);
Fieldslist.add (fiscalperiodfields.fiscalyear);
Fieldslist.add (Fiscalperiodfields.periodno);
true);
Clonedadjustment.period = Fiscalperiod.period;
Clonedadjustment.fiscalyear = Fiscalperiod.fiscalyear;
Clonedadjustment.periodno = Fiscalperiod.periodno;
Voucher=generatevoucher (SessionId, clonedadjustment);
}
Finally
{
Adapter. Rollback ();
}
}
return voucher;
}
One of the details here is that there is no direct manipulation of the current business entity, but a deep copy of it. This will not affect the original business entity for this copy of the object.
Second, the need to add an MDI interface, the main interface for hosting the accounting document interface, the subform is the accounting document interface. To achieve this, we load the accounting voucher interface as a subform into a newly created MDI main form interface:
null;
Form form = ComponentCommon.MainForm.GetStandardFunctionForm (Primarykeys[0]);
if null)
as Functionformbase;
this;
false;
true;
true;
true;
false;
false;
false;
false;
false;
false;
false;
false;
false;
false;
false;
Standardfunctionform.show ();
Standardfunctionform.savelayoutonclose = Savelayouts.never;
dictionary<stringstringnew dictionary<stringstring> ();
Refno.add (Primarykeys[1], refno);
Standardfunctionform.findandloaddata (REFNO);
In this case, we can see why it is necessary to use an MDI main interface to load the accounting voucher form, in order to customize some of its functions without destroying the original functionality. For example, this preview voucher form, do not need to save data or post operations, and then see the above code, we will supportedit=false that we do not need to edit the function.
The last three sentences are the MDI child form loading data, passing in the key-value pair to complete the loading of the data. The Findandloaddata method calls the internal loaddata:
protected Override EntityBase2 LoadData (dictionary<stringstring> Refno)
{
base. LoadData (REFNO);
string string. Empty;
if (Refno.trygetvalue ("refno out refno)")
{
New PrefetchPath2 ((int) entitytype.expenseremibursemententity);
Prefetchpath.add (Expenseremibursemententity.prefetchpathexpenseremibursementdetail);
_expenseremibursemententity = _expenseremibursementmanager.getexpenseremibursement (Shared.CurrentUserSessionId, REFNO, Prefetchpath);
}
Else
{
New Expenseremibursemententity ();
}
return _expenseremibursemententity;
}
This allows us to complete the voucher preview function for the Finance module.
Credential preview feature in the Finance module function