You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
42 lines
1.1 KiB
import json
|
|
from typing import List, Dict, Union, Any
|
|
from app import create_app, db
|
|
from models import Payments, PaymentBatch, SinglePayments, PaymentPlans
|
|
from splynx import Splynx, SPLYNX_URL, SPLYNX_KEY, SPLYNX_SECRET
|
|
from services import log_activity
|
|
|
|
|
|
splynx = Splynx(url=SPLYNX_URL, key=SPLYNX_KEY, secret=SPLYNX_SECRET)
|
|
|
|
results = {
|
|
"deleted": 0,
|
|
"error": 0
|
|
}
|
|
|
|
|
|
|
|
def splynx_invoices(splynx_id: int) -> List[Dict[str, Any]]:
|
|
#result = splynx.get(url=f"/api/2.0/admin/finance/invoices?main_attributes[customer_id]={splynx_id}&main_attributes[status]=paid&main_attributes[date]=2025-08-21")
|
|
params = {
|
|
'main_attributes': {
|
|
'customer_id': splynx_id,
|
|
'status': ['IN', ['not_paid', 'pending']]
|
|
},
|
|
}
|
|
query_string = splynx.build_splynx_query_params(params)
|
|
result = splynx.get(url=f"/api/2.0/admin/finance/invoices?{query_string}")
|
|
|
|
print(f"Count: {len(result)} - {json.dumps(result,indent=2)}")
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app = create_app()
|
|
|
|
customer_id = '1219464'
|
|
results = splynx_invoices(customer_id)
|
|
|
|
print(json.dumps(results,indent=2))
|
|
|
|
|