Exemplo n.º 1
0
def test_statements_for_empty_results(session):
    """Test dailiy statement generation works.

    Steps:
    1) Create a payment for day before yesterday
    2) Mark the account settings as DAILY settlement starting yesterday
    3) Generate statement and assert that the statement does not contains payment records
    """
    day_before_yday = get_previous_day(datetime.now()) - timedelta(days=1)
    bcol_account = factory_premium_payment_account()
    invoice = factory_invoice(payment_account=bcol_account,
                              created_on=day_before_yday)
    inv_ref = factory_invoice_reference(invoice_id=invoice.id)
    factory_statement_settings(pay_account_id=bcol_account.id,
                               from_date=day_before_yday,
                               frequency='DAILY')
    factory_payment(completed_on=day_before_yday,
                    invoice_number=inv_ref.invoice_number)

    StatementTask.generate_statements()

    statements = Statement.find_all_statements_for_account(
        auth_account_id=bcol_account.auth_account_id, page=1, limit=100)
    assert statements is not None
    invoices = StatementInvoices.find_all_invoices_for_statement(
        statements[0][0].id)
    assert len(invoices) == 0
Exemplo n.º 2
0
def test_statements(session):
    """Test dailiy statement generation works.

    Steps:
    1) Create a payment for yesterday
    2) Mark the account settings as DAILY settlement starting yesterday
    3) Generate statement and assert that the statement contains payment records
    """
    previous_day = get_previous_day(datetime.now())
    bcol_account = factory_premium_payment_account()
    payment = factory_payment(created_on=previous_day)
    invoice = factory_invoice(payment=payment, payment_account=bcol_account)
    factory_invoice_reference(invoice_id=invoice.id)
    factory_statement_settings(pay_account_id=bcol_account.account_id,
                               from_date=previous_day,
                               frequency='DAILY')
    StatementJob.generate_statements()

    pay_account = PaymentAccount.find_by_id(bcol_account.account_id)

    statements = Statement.find_all_statements_for_account(
        auth_account_id=pay_account.auth_account_id, page=1, limit=100)
    assert statements is not None
    invoices = StatementInvoices.find_all_invoices_for_statement(
        statements[0][0].id)
    assert invoices is not None
    assert invoices[0].id == invoice.id
Exemplo n.º 3
0
def factory_statement_invoices(statement_id: str, invoice_id: str):
    """Return Factory."""
    return StatementInvoices(statement_id=statement_id,
                             invoice_id=invoice_id).save()