Example #1
0
    def find_by_id(identifier: int, pay_id: int = None):
        """Find invoice by id."""
        invoice_dao = InvoiceModel.find_by_id(
            identifier
        ) if not pay_id else InvoiceModel.find_by_id_and_payment_id(
            identifier, pay_id)

        if not invoice_dao:
            raise BusinessException(Error.PAY012)

        invoice = Invoice()
        invoice._dao = invoice_dao  # pylint: disable=protected-access

        current_app.logger.debug('>find_by_id')
        return invoice
Example #2
0
    def find_by_id(identifier: int, pay_id: int = None, skip_auth_check: bool = False):
        """Find invoice by id."""
        invoice_dao = InvoiceModel.find_by_id(identifier) if not pay_id else InvoiceModel.find_by_id_and_payment_id(
            identifier, pay_id)
        if not invoice_dao:
            raise BusinessException(Error.INVALID_INVOICE_ID)

        if not skip_auth_check:
            Invoice._check_for_auth(invoice_dao)

        invoice = Invoice()
        invoice._dao = invoice_dao  # pylint: disable=protected-access

        current_app.logger.debug('>find_by_id')
        return invoice