New Extension: Invoicing (#733)
* initial commit * add docs * black & prettier * mobile styles * add print view * prettier * make format * initial migrations un-messed * make migrations work for sqlite * add invoices table * clean migrations * add migration to conv * fix card size * hopefully fix test migration * add missing status * timestamp * init testing * remove draft invoice by default on create * what should i test * make format * raise if not invoice * new test and renaming * fix issue reported by @talvasconcelos which prevented users from setting status on creation * readme * run black * trying to make tests work * make it work again * send paid amount * partial pay flow * good coding * can't get these test to work * clean up and commenting * make format * validation for 2 decimals Co-authored-by: ben <ben@arc.wales> Co-authored-by: Tiago vasconcelos <talvasconcelos@gmail.com>
This commit is contained in:
co-authored by
ben
Tiago vasconcelos
parent
197ff7d054
commit
c32ff1de59
@@ -0,0 +1,37 @@
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
|
||||
from lnbits.core.crud import create_account, create_wallet
|
||||
from lnbits.extensions.invoices.crud import (
|
||||
create_invoice_internal,
|
||||
create_invoice_items,
|
||||
)
|
||||
from lnbits.extensions.invoices.models import CreateInvoiceData
|
||||
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
async def invoices_wallet():
|
||||
user = await create_account()
|
||||
wallet = await create_wallet(user_id=user.id, wallet_name="invoices_test")
|
||||
|
||||
return wallet
|
||||
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
async def accounting_invoice(invoices_wallet):
|
||||
invoice_data = CreateInvoiceData(
|
||||
status="open",
|
||||
currency="USD",
|
||||
company_name="LNBits, Inc",
|
||||
first_name="Ben",
|
||||
last_name="Arc",
|
||||
items=[{"amount": 10.20, "description": "Item costs 10.20"}],
|
||||
)
|
||||
invoice = await create_invoice_internal(
|
||||
wallet_id=invoices_wallet.id, data=invoice_data
|
||||
)
|
||||
items = await create_invoice_items(invoice_id=invoice.id, data=invoice_data.items)
|
||||
|
||||
invoice_dict = invoice.dict()
|
||||
invoice_dict["items"] = items
|
||||
return invoice_dict
|
||||
Reference in New Issue
Block a user