extools.report.printers

class extools.report.printers.APChequePrinter(batchno)[source]

Bases: object

Print cheques for an AP Batch.

This class provides a one-call interface for all the operations required to correctly print cheques for an A/P Payment batch through the AP and BK processing views.

from accpac import *

from extools.ui.bare import bareui
from extools.report.printers import (
    APChequePrinter, SetupError,
    ChequeCommitError, ReportGenerationError, )

batchno = 81

def main(*args, **kwargs):
    printer = APChequePrinter(batchno)
    try:
        check_report_path = printer.print()
    except SetupError as e:
        # handle a failure to setup the temp tables.
        # e contains details on the failing operation
    except ReportGenerationError as e:
        # handle a failure to generate the report.
    except ChequeCommitError as e:
        # handle a failure to write information back to AP/BK.
        # e contains details on the failing operation
Parameters:batchno (int) – A/P Payment batch number
APBTA_PROCESSCMD_LOCK_EXCL = 2
APBTA_PROCESSCMD_UNLOCK = 0
APCHK_BATCH_PROCESS = 2
APCHK_SET_BATCHNO = 4
APCHK_STATUS_ABORT = 1
APCHK_STATUS_SUCCESS = 0
APCHK_UPDATE_STATUS = 3
APTCR_PROCESSCMD_VOID_CHEQUE = 4
BKPRFUN_FUNC_FIND_MATCHING = 1
BKPRFUN_FUNC_MARK_ENTIRE_RANGE = 4
BKPRFUN_FUNC_POST_ALL_IN_SUBRUN = 5
BKPRFUN_FUNC_PREP_SUBRUN = 2
BKPRFUN_LANG_SELECT_ANY = 1
BKPROC_PRINT_CHEQUE = 1
BKPROC_PROC_COMPLETE = 1
BKREG_STATUS_ADVICE_NOT_PRINTED = -1
BKREG_STATUS_NOT_PRINTED = -2
BKREG_STATUS_POSTED = 999
BKREG_STATUS_PRINTED = 9
BTCHSTAT_CQ_PR_INPR = 8
BTCHSTAT_READY_TO_POST = 7
PAYMTYPE = 'PY'
abort_apchk()[source]

Abort AP cheque processing - undoes all print related flags.

bkprfun_mark_printed()[source]

Mark entire run printed.

bkprfun_post_cheques()[source]

Post all checks for run.

Creates bank transaction for each cheque issued.

complete_apchks()[source]

Complete the APCHK processing - write back check numbers.

end_cheque_printing()[source]

Tell BKPROC that cheque printing is over.

Initial state dosen’t matter, reliably returns 0.

generate_cheque_report(path=None)[source]

Generate the cheque report and save to file.

get_serials()[source]

Get the start and end serials for this batch sub run.

prepare_bkprfun()[source]

Prepare the sub-run - sets cheque numbers.

After execution BKREG is full populated and ready for report generation.

print(path=None)[source]

Print cheques for a batch and write back details to AP and BK.

Call me! This is the public interface into the class. When called, it will generate the cheques for an A/P batch to PDF through the proper Sage processing views.

Parameters:

path (pathlib.Path) – cheque printing output path.

Returns:

Path() to cheque report PDF

Return type:

pathlib.Path or None on error.

Raises:
set_batch_rtp()[source]

Set the batch status to Ready to Post.

setup_apchk()[source]

Setup the APADV table using the APCHK view.

setup_batch()[source]

Set the batch status to Cheque Printing in Progress.

setup_bkprfun()[source]

Setup the Bank Printing Functions for the batch.

Mainly setting up the view with the correct values, as well as kicking the partially composed views that don’t share a first key.

start_cheque_printing()[source]

Tell BKPROC that cheque printing is starting.

Initial state dosen’t matter, reliably returns 0.

void_batch_cheques()[source]

Void all cheques in the batch.

exception extools.report.printers.APOpenError(trigger_exc=None)[source]

Bases: extools.report.printers.ExReportPrinterError

exception extools.report.printers.ChequeCommitError(trigger_exc=None)[source]

Bases: extools.report.printers.ExReportPrinterError

exception extools.report.printers.ExReportPrinterError(trigger_exc=None)[source]

Bases: extools.errors.ExToolsError

exception extools.report.printers.NoChequesMatchedError(trigger_exc=None)[source]

Bases: extools.report.printers.ExReportPrinterError

exception extools.report.printers.ReportGenerationError(trigger_exc=None)[source]

Bases: extools.report.printers.ExReportPrinterError

exception extools.report.printers.SetupError(trigger_exc=None)[source]

Bases: extools.report.printers.ExReportPrinterError