Wiki Markup
{noprint}{float:right|width=300px|background=lightgrey|border=solid blue 2px|margin=10px|padding=8px}
*Contents*
{toc:all=true|depth=4|excerpt=true|indent=14px}
{float}{noprint}{table-plus:enableSorting=false|width=665}



*Change log:*
|| Date: || Author: || Version: || Changes: || Completed || Ext. || Int. || Is in Core || Jira Ref. ||
| {page-info:created-date|dateFormat=dd MMMM yyyy} | {page-info:created-user} | 1.0 | Doc. created | Yes | x | | N/A | |
----


h2. Introduction

The current page describes (technically) the elements which are part of the process of closing _running_ invoices.

* *[Customers:Invoice Batch Engine]* \- controls the closing of invoices and makingmakes invoices ready for beingexport exporting to third party, PDF generation etc.
* *Invoice Export Engine* \- processprocesses requests for exporting invoices, and also have the responsibility of makingprepares invoices ready for beingpublishing.
published.* *Invoice Close GUI* is\- responsiblehandles formarking markingof invoices as being published.

The state of invoice batches are described below.
{gliffy:name=invoice_close_process|version=18}





h4. Process descriptionDescription

{table-plus:heading=1|border=0|multiple=false|enableSorting=false|enableHeadingAttributes=false}

{table-plus}

{table-plus}




|| State || Who || Description ||
| Pending Close | Invoice Batch Engine \\
[Invoice Close GUI|RatorInterface:Invoice Close (Invoice Management)] | If a batch is requested to be closed immediately the state change is done immediately, otherwise the process is handled by the Invoice Batch Engine |
| Closing | Invoice Batch Engine | InvoicesInvoice schedules are closed as long as they end before 'now' (i.e. the execution time). \\
Invoices are closed but not locked, meaningi.e. it is possible to adjust the balance, if needed (adding minimum invoice usage, fees, etc.). |
| Closed | Invoice Batch Engine | PerIt billingis cyclepossible itper isbilling possiblecycle to define a hookpoint key that will allow calling a hookpoint to be called. If this hookpoint does not exist or does not return FAILURE, any not non-closed invoicesinvoice within a closed invoice schedule is moved to the next invoice schedule. Invoices may not be closed duebecause they fail to fulfill the minimum invoice usage requirements not being fulfilled. |
| Aggregating | Invoice Batch Engine | The actual aggregation of invoice detail lines areis handled by an external process, located in the database. Hence this process only checks ifthat all invoices are aggregated before processing continues. This is done by counting the non-aggregated invoices by an SQL located in the resource file "{{/com/CDRator/billing/financial/invoiceBatch/countUnaggregatedInvoices}}". \\
When all invoices are aggregated, the invoices are locked so that no invoice detail lines may be created for the invoices. |
| Ready for sending | Invoice Batch Engine | If there are no invoices in the batch, the batch goes into error. \\
A hookpoint is called, as well asand a pending record for the exporting process is created. |
| Ordered | Invoice Export Engine | A workflow is invoked which haveprocesses the responsibility of processing the export queue, asand well aschanges change the state of the corresponding invoice batch. |
| Ready for publish | [Invoice Close GUI|RatorInterface:Invoice Close (Invoice Management)] | IfThe export of invoices aredoes exportednot theyindicate mightthat notthey beare ready for being publishedpublishing. This is controlled withinin the Invoice Close GUI which allows the batch to be marked as 'Published'. |
{table-plus}

{table-plus}


h4. Object modelModel
{gliffy:name=invoice_close_classes|align=left|size=L|version=7}

Billing cycles, invoice schedules and invoice batch are maintained in the [Invoice Close/Invoice Management Tab|Customers:Invoice Management].