# Invoice Scheduling

* The Provider Invoice Number is blank
* If you select Reflect Plan Dates, the invoices will be generated **going forward** based on the Plan Date Range
  * This essentially defines the period, or book ends, for which the batch should generate Invoices
  * The Maica batch creates Invoice records based on the Next\_Scheduled\_Date\_\_c on Invoice
    * This date is calculated by our logic in the relevant Maica trigger and gets populated with +1 month (for Monthly frequency) until it’s less than TODAY starting from the Schedule\_Start\_Date\_\_c
* Then Schedule\_Start\_Date\_\_c is the base for the calculation
  * In a loop we add 1 month to the Schedule\_Start\_Date\_\_c until it’s greater than or equals to TODAY then we set the Next\_Scheduled\_Date\_\_c with the value
  * Using the Plan Start Day (not Date) as the Anchor Date
* The screenshot below should help with all of this the Plan Start Date was **10/06/2021**
* See the mapping for reference:
  * Invoice.Schedule\_Start\_Date\_\_c = Invoice.Schedule\_Plan\_\_c.Start\_Date\_\_c
  * Invoice.Schedule\_End\_Date\_\_c  = Invoice.Schedule\_Plan\_\_c.End\_Date\_\_c
* Essentially, the invoice series will use the first invoice as a template and clone this based on the period, i.e. monthly
  * The Schedule Source Invoice is populated with this first Invoice record

CC: @Dmitry Lisovsky if I have missed anything!
