Esempio n. 1
0
def test_get_statement_report_for_empty_invoices(session):
    """Assert that the get statement report works for statement with no invoices."""
    bcol_account = factory_premium_payment_account()
    bcol_account.save()

    payment = factory_payment()
    payment.save()
    i = factory_invoice(payment_account=bcol_account)
    i.save()
    factory_invoice_reference(i.id).save()
    factory_payment_line_item(invoice_id=i.id, fee_schedule_id=1).save()

    settings_model = factory_statement_settings(
        payment_account_id=bcol_account.id,
        frequency=StatementFrequency.DAILY.value)
    statement_model = factory_statement(
        payment_account_id=bcol_account.id,
        frequency=StatementFrequency.DAILY.value,
        statement_settings_id=settings_model.id)

    payment_account = PaymentAccount.find_by_id(bcol_account.id)
    statements = StatementService.find_by_account_id(
        payment_account.auth_account_id, page=1, limit=10)
    assert statements is not None

    report_response, report_name = StatementService.get_statement_report(
        statement_id=statement_model.id,
        content_type='application/pdf',
        auth=get_auth_premium_user())
    assert report_response is not None
Esempio n. 2
0
def test_statement_find_by_account(session):
    """Assert that the statement settings by id works."""
    bcol_account = factory_premium_payment_account()
    bcol_account.save()

    payment = factory_payment()
    payment.save()
    i = factory_invoice(payment_account=bcol_account)
    i.save()
    factory_invoice_reference(i.id).save()

    settings_model = factory_statement_settings(
        payment_account_id=bcol_account.id,
        frequency=StatementFrequency.DAILY.value)
    statement_model = factory_statement(
        payment_account_id=bcol_account.id,
        frequency=StatementFrequency.DAILY.value,
        statement_settings_id=settings_model.id)
    factory_statement_invoices(statement_id=statement_model.id,
                               invoice_id=i.id)

    payment_account = PaymentAccount.find_by_id(bcol_account.id)
    statements = StatementService.find_by_account_id(
        payment_account.auth_account_id, page=1, limit=10)
    assert statements is not None
    assert statements.get('total') == 1