Batch Voucher Exports

mockups

https://drive.google.com/drive/folders/1DR0ownDKS14PxhCrHWy14TD8sJA1mnbK

mod-invoice/mod-invoice-storage

Schemas

invoice

  • Add the batchGroupId field.
  • Add enclosureNeeded field

NOTE:  We'll need a UI story to add this to the various invoice forms/views

Property

Type

Default

Required

Notes

batchGroupId
string
NAYesUUID of the batchGroup (aka exportGroup) to associate with this invoice and corresponding voucher
enclosureNeededbooleanfalseNoIndicates that an enclosure is needed for the check - only if payment method is check.

voucher

  • Add the batchGroupId field.
  • Remove the batchNumber field - no longer needed.

Copied over from invoice->batchGroupId

Property

Type

Default

Required

Notes

batchGroupId
string
NAYesUUID of the batchGroup (aka exportGroup) to associate with this invoice and corresponding voucher

adjustment

  • add exportToAccounting

Property

Type

Default

Required

Notes

exportToAccounting
boolean
falseYesWhether or not to show this adjustment in batchedVoucherLines

batch_voucher_export

This record describes an batch voucher export job - metadata about the process which generates and uploads the batch voucher

Property

Type

Default

Required

Notes

id
string
NANoUUID of this export - System generated if not specified.
status
string
PendingYesenum:  Pending, Generated, Uploaded, Error
message
string
NANoField for capturing additional context of status, e.g. an error message
batchGroupId
string
NAYesUUID of the batch (aka exportGroup)
start
datetime
NAYesThis export is for all vouchers between start and end
end
datetime
NAYesThis export is for all vouchers between start and end
batchVoucherId
string
NANoUUID of the batch voucher if one exists yet
metadata
metadata
NANoSystem generated record metadata

batch_voucher

XML and JSON schemas/bindings are needed for this.

Immutable.

Potentially quite large.

Stored as json, but XML and JSON schemas/bindings are needed for this.

XML schema should favor elements over attributes as seen in the abbreviated example below.

 High Level Example

{
  "batchGroup": "LAWLIB",
  "start": "2020-01-26T00:00:00Z",
  "end": "2020-01-27T00:00:00Z",
  "created": "2020-01-27T00:01:23Z",
  "batchedVouchers": [
    {
      ...
      batchedVoucherLines: [
        {
          "fundCodes": [ "HIST", "CANHIST" ],
          ...
        }, ...
      ]
    }, ...
  ]
}

<batchVoucher>
  <batchGroup>LAWLIB</batchGroup>
  <start>2020-01-26T00:00:00Z</start>
  <end>2020-01-27T00:00:00Z</end>
  <created>2020-01-27T00:01:23Z</created>
  <batchedVouchers>
    <batchedVoucher>
      ...
      <batchedVoucherLines>
        <batchedVoucherLine>
          ...
        </batchedVoucherLine>
      </batchedVoucherLines>
    </batchedVoucher>
    ...
  </batchedVouchers>
</batchVoucher>


Property

Type

Default

Required

Notes

id
string
NANUUID for the batch voucher - System generated if not provided.
batchGroup
string
NAYlookup batchGroup→name using invoice.batchGroupId
start
datetime

NA

Yfrom batch_voucher_export→start 
end
datetime
NAYfrom batch_voucher_export→end 
created
datetime
NAYSystem generated - when the batch voucher was generated
batchedVouchers
collection<batched_voucher>
NAYarray of batch_voucher
totalRecords
integer
NAYtotal number of records in the array

batched_voucher

Property

Type

Default

Required

Notes

voucherNumber
string
NA

Y

from voucher → voucherNo
vendorInvoiceNo
string
NAYfrom voucher → invoiceId;  dereference to invoice → vendorInvoiceNo
folioInvoiceNo
string
NAYfrom voucher → invoiceId;  dereference to invoice → folioInvoiceNo
accountingCode
string
NAYfrom voucher → accountingCode
voucherDate
datetime
NAYfrom voucher → voucherDate
type
string
NAYenum.  from voucher → type
status
string
NAYenum.  from voucher → status
amount
number
NAYfrom voucher → amount
systemCurrency
string
NAY
invoiceCurrency
string
NAY
exchangeRate
number
NAN
invoiceNote
string
NAN
vendorName
string
NAY
disbursementNumber
string
NAN
disbursementDate
datetime
NANRequired if disbursementNumber is specified
disbursementAmount
number
NAN
enclosureNeeded
boolean
falseNIndicates that an enclosure is needed for the check - only if payment method is check.
batchedVoucherLines
collection<batched_voucher_line>
NAY

batched_voucher_line

Property

Type

Default

Required

Notes

externalAccountNumber
string
NAYfrom voucher-line→externalAccountNumber 
amount
number
NAYfrom voucher-line→amount 
fundCodes
collection<string>
NAYfrom voucher-line→ fundDistributions;  dereferenced to fund → code
adjustments
collection<adjustment>
NAN

need to see:

  • description
  • relationToTotal - excluding separateFrom
  • amount or percentage

export_configuration

Configuration information for a voucher export - there's only one of these for a given batchGroup

Property

Type

Default

Required

Notes

id
string
NAYesUUID of the configuration record - this is the batchGroupId that this configuration is associated with. - Foreign Key
startTime
string

00:00

NoThe time of day to trigger an export if enableScheduledExport == true. Use pattern to restrict to HH:MM
weekdays
collection<string>
NANoAn array of weekdays (enum: Sunday, Monday, etc.) indicating which days to trigger exports on.  If empty, indicates daily exports.  Duplicates are not allowed.
enableScheduledExport
boolean
falseNoWhether or not to enable scheduled batch voucher exports
format
string
Application/jsonNoenum:  Application/json, Application/xml (desired format of the batch voucher)
uploadURI
string
NANoURI (ftp://host:port/path) batch vouchers should be uploaded to - use pattern to restrict to FTP URIs for now.
metadata
metadata
NANoSystem generated record metadata

credentials

Credentials used to upload batch vouchers.  Part of the voucher export configuration, but separated for security reasons (separate permission to access, allows for show/hide button, etc.)

Property

Type

Default

Required

Notes

id
string
NANoUUID of this record - System generated if not provided
exportConfigId
string
NAYesUUID of the export configuration these credentials are associated with, which is also the batchGroupId that the configuration is associated with. - Foreign Key
username
string
NAYesusername
password
string
NANopassword
metadata
metadata
NANoSystem generated record metadata

batch_group

Controlled vocabulary.  This is used when querying vouchers to be included in a batch voucher, e.g. GET /batch-voucher-storage/vouchers?query=invoice.batchGroupId==XYZ and voucherDate>=ABC and voucherDate<DEF

Need a system value that's ALWAYS there - so not reference or sample data...

{
"id": "2a2cb998-1437-41d1-88ad-01930aaeadd5",
"name": "FOLIO",
"description": "default batch identifier for voucher export"
}

NOTE: We'll need a mockup and UI story for adding a settings area for this.

Property

Type

Default

Required

Notes

id
string
NANoUUID for this record - system generated if not specified
name
string
NAYesHuman readable name, e.g. "Ongoing orders" - Unique Index
description
string
NANoFree form description of this batch identifier
metadata
metadata
NANoSystem generated record metadata

APIs

batch-voucher-export-configurations

  • CRUD export configurations on a per-batchGroup basis
    • batchGroupId
    • startTime
    • enableDailyExport (boolean)
    • format (enum)
    • ftp location (host/port/path)
    • username/password

batch-voucher-exports

  • On-demand export of vouchers between start/end date/times
    • Get all vouchers for the specified time period
    • For each
      • Get all voucher lines
      • Pull out relevant info
      • Dereference UUIDs as needed (API lookups likely required)
    • Build batch_voucher with the vouchers that have the specified batchGroupId and voucherDate between the specified start/end date/times.
    • Persist batch_voucher
    • Update voucher_export status as the export progresses (Pending, Generating, Generated, Uploading, Uploaded, Error)
    • Return batch voucher in desired format 
    • Optionally - Upload to FTP server
      • connects to FTP using provided credentials
      • uploads the batch voucher
      • updates batch voucher export (e.g. status = uploaded)
    • Only include vouchers for invoices w/ exportToAccounting=true

_timer

  • calls POST /batch-voucher/batch-voucher-exports/scheduled
  • runs every 5 (?) minutes

mod-invoice

InterfaceMethodPathRequestResponseDescriptionNotes
batch-voucher-exportsPOST/batch-voucher/batch-voucher-exports/scheduledNA

202 batch_voucher_export

204

Conditionally create a batch voucher export

checks configuration, either returns w/ 204 or

call POST /vouchers/export and returns results

batch-voucher-exportsPOST/batch-voucher/batch-voucher-exports

Query args:

  • start (dateTime)
  • end (dateTime)
  • batchGroupId
  • upload (true/false)
batch_voucher_export

Create a batch voucher export for the specified period

if upload == true, and ftp details exist in the export settings for this batchGroupId, upload the resulting batch voucher as the configured format/MIME type (conversion may be needed)
batch-voucher-exportsPOST/batch-voucher/batch-voucher-exports/<id>/uploadNA202 batch_voucher_export(Re)upload the batch voucher associated with this voucher export to the configured URI, using the configured credentials
batch-voucher-exportsGET/batch-voucher/batch-voucher-exportsCQL Querycollection<batch_voucher_export>List/search voucher exports
batch-voucher-exportsGET/batch-voucher/batch-voucher-exports/<id>NAbatch_voucher_exportGet a particular voucher export (data and metadata)
batch-voucher-exportsPUT/batch-voucher/batch-voucher-exports/<id>batch_voucher_export204Update a voucher export probably only needed to update status
batch-vouchersGET/batch-voucher/batch-vouchers/<id>NAbatch_voucherGet a batch voucher by idHonors accept header
batch-voucher.export-configurationsPOST/batch-voucher/export-configurationsexport_configurationexport_configurationCreate a voucher export configurationProxy to storage module
batch-voucher.export-configurationsGET/batch-voucher/export-configurationsCQL Querycollection<export_configuration>List/search voucher export configsProxy to storage module
batch-voucher.export-configurationsGET/batch-voucher/export-configurations/<id>NAexport_configurationGet a voucher export configuration by idProxy to storage module
batch-voucher.export-configurationsPUT/batch-voucher/export-configurations/<id>export_configuration204Edit a voucher export configurationProxy to storage module
batch-voucher.export-configurationsDELETE/batch-voucher/export-configurations/<id>NA204Delete a voucher export configurationProxy to storage module.  
batch-groupsPOST/batch-groupsbatch_groupbatch_groupCreate a batch_groupProxy to storage module
batch-groupsGET/batch-groupsCQL Querycollection<batch_group>List/search batch_groupsProxy to storage module
batch-groupsGET/batch-groups/<id>NAbatch_groupGet a batch_group by idProxy to storage module
batch-groupsPUT/batch-groups/<id>batch_group204Edit a batch_groupProxy to storage module
batch-groupsDELETE/batch-groups/<id>NA204Delete a batch_groupProxy to storage module.  Disallow if batchGroup is in use by any invoice
batch-voucher.export-configurations.credentialsPOST/batch-voucher/export-configurations/<id>/credentialscredentialscredentialsCreate a credentials recordProxy to storage module
batch-voucher.export-configurations.credentialsGET/batch-voucher/export-configurations/<id>/credentialsNAcredentialsGet the credentials for the specified export_configurationProxy to storage module
batch-voucher.export-configurations.credentialsPUT/batch-voucher/export-configurations/<id>/credentialscredentials204Edit a credentials recordProxy to storage module
batch-voucher.export-configurations.credentialsPOST/batch-voucher/export-configurations/<id>/credentials/testNA200Test that you can connect to and log into the uploadURI with the configured credentials

mod-invoice-storage

InterfaceMethodPathRequestResponseDescriptionNotes
batch-voucher-storage.batch-voucher-exportsPOST/batch-voucher-storage/batch-voucher-exports
batch_voucher_export

Create a batch voucher export for the specified period


batch-voucher-storage.batch-voucher-exportsGET/batch-voucher-storage/batch-voucher-exportsCQL Querycollection<batch_voucher_export>List/search batch voucher exports
batch-voucher-storage.batch-voucher-exportsGET/batch-voucher-storage/batch-voucher-exports/<id>NAbatch_voucher_exportGet a particular batch voucher export (data and metadata)
batch-voucher-storage.batch-voucher-exportsDELETE/batch-voucher-storage/batch-voucher-exports/<id>NA204Delete a batch voucher export by idDeletion also removes related batch-voucher if one exists
batch-voucher-storage.batch-voucher-exportsPUT/batch-voucher-storage/batch-voucher-exports/<id>batch_voucher_export204Update a batch voucher export probably only needed to update status
batch-voucher-storage.batch-vouchersPOST/batch-voucher-storage/batch-vouchersbatch_voucherbatch_voucherCreate a batch voucher
batch-voucher-storage.batch-vouchersGET/batch-voucher-storage/batch-vouchers/<id>NAbatch_voucherGet a batch voucher by id
batch-voucher-storage.batch-vouchersDELETE/batch-voucher-storage/batch-vouchers/<id>NA204Delete a batch voucher by idDeletion removes reference from related export record
batch-voucher-storage.export-configurationsPOST/batch-voucher-storage/export-configurationsexport_configurationexport_configurationCreate a voucher export configuration
batch-voucher-storage.export-configurationsGET/batch-voucher-storage/export-configurationsCQL Querycollection<export_configuration>List/search voucher export configs
batch-voucher-storage.export-configurationsGET/batch-voucher-storage/export-configurations/<id>NAexport_configurationGet a voucher export configuration by id
batch-voucher-storage.export-configurationsPUT/batch-voucher-storage/export-configurations/<id>export_configuration204Edit a voucher export configuration
batch-voucher-storage.export-configurationsDELETE/batch-voucher-storage/export-configurations/<id>NA204Delete a voucher export configurationRemoval also results in removal of the associated credentials record in a db transaction
batch-group-storage.batch-groupsPOST/batch-group-storage/batch-groupsbatch_groupbatch_groupCreate a batch_group
batch-group-storage.batch-groupsGET/batch-group-storage/batch-groupsCQL Querycollection<batch_group>List/search batch_groups
batch-group-storage.batch-groupsGET/batch-group-storage/batch-groups/<id>NAbatch_groupGet a batch_group by id
batch-group-storage.batch-groupsPUT/batch-group-storage/batch-groups/<id>batch_group204Edit a batch_group
batch-group-storage.batch-groupsDELETE/batch-group-storage/batch-groups/<id>NA204Delete a batch_group
batch-voucher-storage.export-configurations.credentialsPOST/batch-voucher-storage/export-configurations/<id>/credentialscredentialscredentialsCreate a credentials record
batch-voucher-storage.export-configurations.credentialsGET/batch-voucher-storage/export-configurations/<id>/credentialsNAcredentialsGet the credentials for the specified export_configuration
batch-voucher-storage.export-configurations.credentialsPUT/batch-voucher-storage/export-configurations/<id>/credentialscredentials204Edit a credentials record
batch-voucher-storage.export-configurations.credentialsDELETE/batch-voucher-storage/export-configurations/<id>/credentialsNA204Delete a credentials record

Batch Voucher Generation

Batch voucher generation happens in a background task/job and is triggered via the POST /batch-voucher/batch-voucher-exports endpoint.  

  • Query vouchers
    • exportToAccount=true
    • invoice.batchGroupId=specified batchGroupId
    • voucherDate >= start
    • voucherDate <= end
  • Dereference fields as needed - instead of including UUIDs, retreive those records and use their code/name/etc. in the batchVoucher.  Details TBD

edge-voucher (WIP)

New edge module built upon edge-common

APIs

edge-batch-vouchers

  • Honor Accept header
  • take start/end date/times as params
  • Make this synchronous so the AP system only needs to make a single call.
InterfaceMethodPathRequestResponseDescriptionNotes
edge-batch-vouchersPOST/batch-vouchers

Query args:

  • apiKey
  • start (dateTime)
  • end (dateTime)
  • batchGroup
batch_voucher

Create a voucher export for the specified period and return the resulting batch voucher

Parses API key

Looks up institutional user credentials

Logs into OKAPI

Looks up batchGroupId using batchGroup

Makes a call to POST /batch-voucher/exports

Wait for the batch voucher to be available

Return the batch voucher

Honors Accept header

Stories

mod-invoice-storage

mod-invoice

edge-batch-voucher

  • Project setup
  • Create batch-voucher-export API

Notes

  • Need to add batchGroupId to invoice and voucher
  • Ability to export vouchers between start and end date/time
    • Get all vouchers for the specified time period
    • For each
      • Get all voucher lines
      • Pull out relevant info
      • Dereference UUIDs as needed (API lookups likely required)
    • Build report in json (new schema, details tbd)
    • Persist report
    • Return report in desired format 
  • API for composite voucher ?  Might not be needed
  • Edge API that generates returns voucher report 
    • Honor Accept header
    • take start/end date/times as params
  • Need API to store export settings on a per-batchGroup basis
    • batchGroupId
    • startTime
    • enableDailyExport (boolean)
    • format (enum)
    • ftp location (host/port/path)
    • username/password
  • Need API to store generated reports
    • can be downloaded again
    • can be re-sent (ftp) if configured
    • have status and metadata, maybe indicator of whether they were manually generated or from daily export
  • Need Timer task for each voucher export configuration w/ enableDailyExport = true
    • runs at startTime
    • calls API to generate report
    • connects to FTP using provided credentials
    • uploads the report
    • updates report metadata (e.g. status = uploaded)