MGCLatticeExpenseReportService
Custom service for expense reports (Expense management): creating an expense report with its lines from an expense tool, optionally submitting it to its approval workflow, and posting an approved expense report.
Methods
new
Initializes a new instance of the MGCLatticeExpenseReportService class.
- Visibility:
public - Returns:
void
No parameters.
construct
Creates a new instance of the MGCLatticeExpenseReportService class.
- Visibility:
public - Returns:
MGCLatticeExpenseReportServiceA new MGCLatticeExpenseReportService instance.
No parameters.
canCreateFor
Whether the calling user may create expense reports for a worker, by the rule the expense report page applies (TrvAccessHelper::userHasCurrentDelegateAccessFor): the worker's own user, a user with the expense administrator or system administrator role or the expense agent role, or a current delegate of the worker. Separate only so a test can stand in for the check.
- Visibility:
protected - Returns:
booleanTrue when the user may create expense reports for the worker.
| Name | Type | Optional | Description |
|---|---|---|---|
_worker | HcmWorkerRecId | No | The worker. |
createExpenseReport
Creates an expense report with its lines for a worker, the way the expense report page does (see the class remarks), and with SubmitToWorkflow submits it to its expense report approval workflow the way its Submit does. The report and its lines are created in one transaction; the submit runs after it, with the standard submit checks outside a transaction as the standard requires.
- Visibility:
public - Returns:
MGCLatticeOrderOperationResponseContractAn MGCLatticeOrderOperationResponseContract: DocumentId is the expense report number; with SubmitToWorkflow, PostedDocumentId is the correlation id of the workflow instance (lower case, without braces), the key the workflow service's approveWorkItem, rejectWorkItem, recallWorkflow and getWorkflowStatus take.
| Name | Type | Optional | Description |
|---|---|---|---|
_request | MGCLatticeExpenseReportCreateRequestContract | No | The request: WorkerPersonnelNumber (empty = the calling user's worker), Purpose, Description, Location, Dimensions, Lines, SubmitToWorkflow, Comment, and standard header fields. |
submitExpenseReport
Submits a committed draft expense report to the expense report workflow that applies to it, the way its Submit does without the comment dialog (TrvSubmitExpenseReportToWorkflow.submitEntityToWorkflow(true), as Microsoft's own expense service submits): the standard submit checks (TrvExpTable.validateSubmit: categories, dates, distributions, policies, budget, itemization), then the workflow activation with the report set to Pending.
- Visibility:
protected - Returns:
strThe correlation id of the workflow instance, lower case and without braces.
| Name | Type | Optional | Description |
|---|---|---|---|
_expenseReport | TrvExpTable | No | The expense report, read from the database. |
_comment | WorkflowComment | No | The workflow comment; empty = the integration service's default comment. |
postExpenseReport
Posts an approved expense report the way the expense report's Post button and the workflow's automated posting do (TrvExpTable.validatePost, then the standard TrvPost::post, which posts the whole report through TrvPostExpenseHeader: the vendor, ledger or bank transactions of each line's payment method, the project transactions of project lines, sales tax, and the report and lines set to Posted), in one transaction: the report either posts completely or stays as it was.
- Visibility:
public - Returns:
MGCLatticeOrderOperationResponseContractAn MGCLatticeOrderOperationResponseContract: DocumentId is the expense report number, PostedDocumentId the posting voucher (of the first line; the message lists every voucher).
| Name | Type | Optional | Description |
|---|---|---|---|
_request | MGCLatticeExpenseReportPostRequestContract | No | The request containing ExpenseReportNumber and standard header fields. |
createExpenseReportBatch
Creates several expense reports in a single bulk operation; each item is created (and submitted) on its own, with its own result.
- Visibility:
public - Returns:
MGCLatticeBulkOperationResponseContractAn MGCLatticeBulkOperationResponseContract containing per-item results.
| Name | Type | Optional | Description |
|---|---|---|---|
_requests | List | No | List of MGCLatticeExpenseReportCreateRequestContract. |
postExpenseReportBatch
Posts several approved expense reports in a single bulk operation; each item is posted on its own, with its own result.
- Visibility:
public - Returns:
MGCLatticeBulkOperationResponseContractAn MGCLatticeBulkOperationResponseContract containing per-item results.
| Name | Type | Optional | Description |
|---|---|---|---|
_requests | List | No | List of MGCLatticeExpenseReportPostRequestContract. |