Example #1
0
    def find_invoices(business_identifier: str) -> Dict[str, any]:
        """Find invoices by business identifier."""
        invoices: Dict[str, any] = dict(invoices=[])
        invoice_daos: [
            InvoiceModel
        ] = InvoiceModel.find_by_business_identifier(business_identifier)

        for invoice_dao in invoice_daos:
            invoice = Invoice()
            invoice._dao = invoice_dao  # pylint: disable=protected-access
            invoices['invoices'].append(invoice.asdict())

        current_app.logger.debug('>find_invoices')
        return invoices
Example #2
0
async def process_event(event_message, flask_app):
    """Render the payment status."""
    if not flask_app:
        raise QueueException('Flask App not available.')

    with flask_app.app_context():
        if event_message.get('type', None) == INCORPORATION_TYPE \
                and 'tempidentifier' in event_message \
                and event_message.get('tempidentifier', None) is not None:

            old_identifier = event_message.get('tempidentifier')
            new_identifier = event_message.get('identifier')
            logger.debug('Received message to update %s to %s', old_identifier,
                         new_identifier)

            # Find all invoice records which have the old corp number
            invoices = Invoice.find_by_business_identifier(old_identifier)
            for inv in invoices:
                inv.business_identifier = new_identifier
                inv.flush()

            db.session.commit()