In OMNINxG the Approvals process is centralized - unlike OMNI each specific functionality will not be managing the approvals. Thus earlier we used to develop code and insert records into the main table to denote whether approval is completed or not. In OMNINxG this will be handled by a centralized Approval management system.
Architecture
Approval is applicable on the basis of Document Type. Document Types are defined in Setup > Approvals > Document Types
Thus for Journal Voucher (Document Type = JV) there is a rule, for Material Requistion (MR) there is another approval rule. These approval rules can be defined in OMNINxG from the UI in the menu : Setup > Approvals > Rules
Each approval rule can either be Job based or Accounting Centre based. A Job based approval rule means ONLY those users who have a specific Role AND belong to a Job has the rights to approve the document / request. An accounting centre based approval rule means ONLY those users who have a specific Role AND belong to an accounting centre has the rights to approve the document / request.
User role management and which Accounting Centres and Jobs he/she belongs to is managed in the menu Setup > Users
The Role that will have the right must be defined in advance in the role group OMNI-APPROVAL-ROLES
Implementation Process
In order to implement an approval rule for a new document type the following process must be followed:
Define the Document Type. When the document type is defined the following parameters must be defined too:
Note the two parameters @acId and @docId - @docId is supplied at runtime to identify the document for which the approval rule is being executed. @acId is the variable that is used to store the account centre id of the document at runtime. If the query is job-based then instead of @acId the variable used will be @jobId
Approve Query: This is an SQL statement that is executed when the document is approved. This query is used to mark the core table as approved. For instance for JV this would be:
update omni_account_voucher set
Authorised_On = @approveTime,
Authorised_By = @userId,
Authorised_Comments = @notes
where account_voucher_id = @docId
Note the parameters:
@approveTime - which is the time of approval
@userId - the user who approved the document
@notes - any comments the user entered when approving the doucument
@docId - the document id - in this case the account voucher id.
Define the Roles that are to have the approval rights - in the role group OMNI-APPROVAL-ROLES
Define the Rule. A Rule consists of a combination of Document Type and Role.
Call the SP omni_sp_approval_createApprovalRequest in the SP/Code that is being executed for the step/process for which approval is required. This SP initiates an Approval Request. For example lets say we want to initiate an approval request for a JV when its is created then in the SP omni_sp_finance_add_Voucher - where the Voucher is being created we call the SP omni_sp_approval_createApprovalRequest - after the voucher header and entries are saved into the DB.
-- now add the approval request
declare @approvalDocCode varchar(255)
select @approvalDocCode= Voucher_type_Code from omni_account_voucher_type_master vt
where vt.voucher_type_id = @voucherType
exec omni_sp_approval_createApprovalRequest
@docId = @voucherId,
@docCode = @voucherNo,
@docTypeCode = @approvalDocCode,
@userId = @userId
This will then create an approval request which will be visible on the Home Page - "My Approvals Tab" for the Users that belong to the Role and the Accounting Centre (for Account Centre Based Permissions) or Job (for Job Based Permissions) .
At runtime the Users belonging to the Job or Accounting Centre can be defined in Setup > Users.
Document Type: This is a description of the Document Type and should be something like : "Journal Voucher"
Document Type Code: This is a 2 letter code that uniquely identifies the Document Type and should be something like : "JV"
Permission Based On: Can be one of "Job Based" or "Accounting Centre Based". If Job based this means that the Approval Request is sent to those Users who belong to a Job and have the Role (for the document type), If accounting centre based this means that the Request is sent to those Users who belong to an Accounting Centre and have the Role (for the document type).
Rule Query: This is an SQL statement that returns the Job (if Job-based is chosen) or Accounting Centre (if Accounting Centre is chosen). This query is required to identify which Job / Accounting Centre the document belongs to. For example for JV the query would be:
select @acId = av.account_centre_id from omni_account_voucher av
where av.account_voucher_id = @docId