{
    "header": {
        "version": 1,
        "type": "record"
    },
    "body": {
        "record1": {
            "<1>": "declare function msg, end_window, ar_inv_exp, fieldcount\r\ndeclare subroutine rlist, record_lock\r\n$insert logical\r\n$insert rlist_equates\r\n$insert msg_equates\r\n$insert invoice_equ\r\n$insert invoice_srl_equ\r\n\r\n\r\nCurrentSize = .gasbar->size\r\nNewSize = CurrentSize\r\nNewSize<3> = 0\r\n.gasbar->size = NewSize\r\n.gasbar->visible = 1\r\nopen 'INVOICE' to InvoiceTable else\r\n   Void = msg( '', 'Unable to open INVOICE table...' )\r\n   return 0\r\nend\r\nStatement = 'SELECT INVOICE WITH STATUS = \"O\"'\r\nrlist( Statement, target_activelist$, '', '', '' )\r\n@rn.counter = 0\r\nEof = false$\r\n\r\nOnePercent = iconv( @reccount*.01, 'MD0' )\r\nloop\r\n   readnext Id else Eof = true$\r\nuntil Eof\r\n   record_lock( InvoiceTable, 'Invoice', Id )\r\n   read InvoiceRec from InvoiceTable, Id else\r\n      Void = msg( '', 'Unable to read ':Id:' from invoice table.' )\r\n      return 0\r\n   end\r\n   InvoiceRec<invoice_status$> = 'C' ;* expired\r\n   Balance = xlate( 'INVOICE', Id, 'BALANCE', 'X' )\r\n   if Balance <> 0 then\r\n      CCnt = fieldcount( InvoiceRec<invoice_check_no$>, @vm )\r\n      if CCnt else\r\n         CCnt = fieldcount( InvoiceRec<invoice_check_date$>, @vm )\r\n      end\r\n      if CCnt else\r\n\t\t CCnt = fieldcount( InvoiceRec<invoice_check_amount$>, @vm )      \r\n      end\r\n      InvoiceRec<invoice_check_no$,CCnt+1> = 'System'\r\n      InvoiceRec<invoice_check_date$,CCnt+1> = date()\r\n      InvoiceRec<invoice_check_amount$,CCnt+1> = Balance\r\n   end\r\n   write InvoiceRec on InvoiceTable, Id else\r\n      Void = msg( '', 'Unable to write ':Id:' on invoice table.' )\r\n      return 0\r\n   end\r\n   unlock InvoiceTable, Id else\r\n      Void = msg( '', 'Unable to unlock ':Id:' in invoice table.' )\r\n      return 0\r\n   end\r\n   if mod( @rn.counter, OnePercent ) else\r\n\t   NewWidth = CurrentSize<3> * @rn.counter/@reccount\r\n\t   .percent_complete->text = oconv(iconv( @rn.counter/@reccount*100, 'MD0' ), 'MD0' ):'%'\r\n\t   NewSize<3> = NewWidth\r\n\t   .gasbar->redraw = 0\r\n\t   .gasbar->size = NewSize\r\n\t   .gasbar->redraw = 1\r\n   end\r\nrepeat\r\nif @rn.counter > 0 and @reccount > 0 then\r\n\tNewWidth = CurrentSize<3> * @rn.counter/@reccount\r\n\t.percent_complete->text = oconv(iconv( @rn.counter/@reccount*100, 'MD0' ), 'MD0' ):'%'\r\n\tNewSize<3> = NewWidth\r\n\t.gasbar->redraw = 0\r\n\t.gasbar->size = NewSize\r\n\t.gasbar->redraw = 1\r\nend\r\n\r\n*\r\n* Automatically export the prior day of invoices to the mas90 subdirectory\r\n* if the run day is monday it will subtract three days for the prior friday\r\n* so if we ever invoice on the weekend it would be included.\r\n/**********\r\n* WITH ORACLE NO EXPORTING\r\n*Today = date()\r\n*Day = 'Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday'\r\n*convert ',' to @fm in Day\r\n*CurDay = Day<mod(Today,7)+1>\r\n*if CurDay = 'Monday' then\r\n*   DayToStart = oconv( Today-3, 'D2/' ) ;* to get from last friday\r\n*   DayToEnd   = oconv( Today-1, 'D2/' ) ;* for yesterday\r\n*end else\r\n*  DayToStart = oconv( Today-1, 'D2/' ) ;* for yesterday\r\n*  DayToEnd   = oconv( Today-1, 'D2/' ) ;* for yesterday\r\n*end\r\n*ParamToPass = DayToStart:'*':DayToEnd:'*M:\\90W\\MAS90\\INVOICE.M&S'\r\n*Void = ar_inv_exp(ParamToPass,False$)\r\n***********/\r\nreturn 1"
        }
    }
}