Skip to main content

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: MGCLatticeExpenseReportService A 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: boolean True when the user may create expense reports for the worker.
NameTypeOptionalDescription
_workerHcmWorkerRecIdNoThe 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: MGCLatticeOrderOperationResponseContract An 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.
NameTypeOptionalDescription
_requestMGCLatticeExpenseReportCreateRequestContractNoThe 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: str The correlation id of the workflow instance, lower case and without braces.
NameTypeOptionalDescription
_expenseReportTrvExpTableNoThe expense report, read from the database.
_commentWorkflowCommentNoThe 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: MGCLatticeOrderOperationResponseContract An MGCLatticeOrderOperationResponseContract: DocumentId is the expense report number, PostedDocumentId the posting voucher (of the first line; the message lists every voucher).
NameTypeOptionalDescription
_requestMGCLatticeExpenseReportPostRequestContractNoThe 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: MGCLatticeBulkOperationResponseContract An MGCLatticeBulkOperationResponseContract containing per-item results.
NameTypeOptionalDescription
_requestsListNoList 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: MGCLatticeBulkOperationResponseContract An MGCLatticeBulkOperationResponseContract containing per-item results.
NameTypeOptionalDescription
_requestsListNoList of MGCLatticeExpenseReportPostRequestContract.