- New SubscriptionMatrixService for billing matrix generation - Products grouped by product number with monthly aggregation - Support for archived, draft, sent, booked, paid, unpaid invoices - Fixed amount calculation with fallback logic (grossAmount, unitNetPrice) - Status mapping based on invoice type (draft, invoiced, paid) - Frontend tab on customer detail page with dynamic table rendering - Fixed Blåhund customer economic number linking
48 lines
1.3 KiB
Python
48 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
"""Create test draft invoice for customer 702007707 (Blåhund)"""
|
|
|
|
import asyncio
|
|
import aiohttp
|
|
import json
|
|
import os
|
|
|
|
async def create_invoice():
|
|
secret = os.getenv("ECONOMIC_APP_SECRET_TOKEN", "wy8ZhYBLsKhx8McirhvoBR9B6ILuoYJkEaiED5ijsA8")
|
|
grant = os.getenv("ECONOMIC_AGREEMENT_GRANT_TOKEN", "5AhipRpMpoLx3uklPMQZbtZ4Zw4mV9lDuFI264II0lE")
|
|
|
|
headers = {
|
|
"X-AppSecretToken": secret,
|
|
"X-AgreementGrantToken": grant,
|
|
"Content-Type": "application/json"
|
|
}
|
|
|
|
invoice_data = {
|
|
"customer": {
|
|
"customerNumber": 702007707
|
|
},
|
|
"date": "2026-01-20",
|
|
"lines": [
|
|
{
|
|
"product": {
|
|
"productNumber": "ABONNEMENT-BLAHUND"
|
|
},
|
|
"description": "Abonnement Blåhund",
|
|
"quantity": 1,
|
|
"unitNetPrice": 695.00
|
|
}
|
|
]
|
|
}
|
|
|
|
async with aiohttp.ClientSession() as session:
|
|
async with session.post(
|
|
"https://restapi.e-conomic.com/invoices/drafts",
|
|
headers=headers,
|
|
json=invoice_data
|
|
) as resp:
|
|
print(f"Status: {resp.status}")
|
|
data = await resp.json()
|
|
print(json.dumps(data, indent=2, default=str)[:800])
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(create_invoice())
|