def test_delete_completed_payment(session, auth_mock): """Assert that the payment records are soft deleted.""" payment_account = factory_payment_account() payment = factory_payment(payment_status_code=PaymentStatus.COMPLETED.value) payment_account.save() payment.save() invoice = factory_invoice(payment, payment_account) invoice.save() factory_invoice_reference(invoice.id).save() fee_schedule = FeeSchedule.find_by_filing_type_and_corp_type('CP', 'OTANN') line = factory_payment_line_item(invoice.id, fee_schedule_id=fee_schedule.fee_schedule_id) line.save() transaction = factory_payment_transaction(payment.id) transaction.save() with pytest.raises(Exception) as excinfo: PaymentService.delete_payment(payment.id) assert excinfo.type == BusinessException
def test_delete_payment(session, auth_mock, public_user_mock): """Assert that the payment records are soft deleted.""" payment_account = factory_payment_account() payment = factory_payment() payment_account.save() payment.save() invoice = factory_invoice(payment, payment_account) invoice.save() factory_invoice_reference(invoice.id).save() fee_schedule = FeeSchedule.find_by_filing_type_and_corp_type('CP', 'OTANN') line = factory_payment_line_item(invoice.id, fee_schedule_id=fee_schedule.fee_schedule_id) line.save() transaction = factory_payment_transaction(payment.id) transaction.save() PaymentService.delete_payment(payment.id) payment = Payment.find_by_id(payment.id) assert payment.payment_status_code == PaymentStatus.DELETED.value assert payment.invoices[0].invoice_status_code == InvoiceStatus.DELETED.value