Send PDF statement

  • entityId – internal ID of the customer. NOTE: I have had errors in the past which were solved by using parseInt(customer).
  • printMode – the print mode to render this statement in (eitherrender.PrintMode.HTML or render.PrintMode.PDF)
  • formId – internal ID of the form to use to print the statement. Leave this option off to use the default statement form.
  • startDate – If you choose to enter a date, this is the date of the oldest transaction that appears on the statement. If you choose to note enter a date, all transactions in the customer’s history appear on the statement.
  • statementDate – Statement date. The date in this field is the date used to calculate aging and the date that appears on the statement form.
  • openTransactionsOnly – Select this option to include only open transactions on statements. If you have entered a start date, open transactions from that start date appear. If you have not entered a start date, all open transactions appear. The Show Only Open Transaction option is most useful for statements printed as of your current today date. If you select Show Only Open Transactions and are using a date other that today’s date, you may have balance discrepancies.

Here is an code snippet. It uses the moment.js for calculating the dates of the first and last day of the previous month.

var startDate = format.format({
  value: moment().subtract(1, 'months').startOf('month').toDate(),
  type: format.Type.DATE
});

var statementDate = format.format({
  value: moment().subtract(1, 'months').endOf('month').toDate(),
  type: format.Type.DATE
});

var statement = render.statement({
  entityId: parseInt(customer),
  printMode: render.PrintMode.PDF,
  startDate: startDate,
  statementDate: statementDate
});

Leave a comment

Your email address will not be published. Required fields are marked *