orionapi 2.26.0__tar.gz → 2.27.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
__version__ = "2.
|
|
1
|
+
__version__ = "2.27.0"
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
4
|
import re
|
|
@@ -159,6 +159,31 @@ BILLING_BILL_TYPES = [
|
|
|
159
159
|
"AdvanceCreditDebit",
|
|
160
160
|
]
|
|
161
161
|
|
|
162
|
+
# Fields of the Orion API ReceiveableSummaryDto, the body of
|
|
163
|
+
# POST /Billing/SyncCashtoEclipse. Identical to the CashFundingGridDto rows
|
|
164
|
+
# returned by get_cash_funding(), except the grid's "id" is "accountId" here.
|
|
165
|
+
RECEIVABLE_SUMMARY_FIELDS = (
|
|
166
|
+
"accountId",
|
|
167
|
+
"registrationName",
|
|
168
|
+
"registrationId",
|
|
169
|
+
"fundFamily",
|
|
170
|
+
"productName",
|
|
171
|
+
"moneyMarketBalance",
|
|
172
|
+
"balanceDue",
|
|
173
|
+
"difference",
|
|
174
|
+
"payMethod",
|
|
175
|
+
"clientId",
|
|
176
|
+
"clientLastName",
|
|
177
|
+
"clientName",
|
|
178
|
+
"accountType",
|
|
179
|
+
"accountNumber",
|
|
180
|
+
"managementStyle",
|
|
181
|
+
"accountIsActive",
|
|
182
|
+
"representativeName",
|
|
183
|
+
"feeReqSrc",
|
|
184
|
+
"instanceType",
|
|
185
|
+
)
|
|
186
|
+
|
|
162
187
|
|
|
163
188
|
class OrionAPIError(Exception):
|
|
164
189
|
"""Base exception for Orion API errors."""
|
|
@@ -1655,10 +1680,13 @@ class OrionAPI(BaseAPI):
|
|
|
1655
1680
|
if not isinstance(take, int) or take < 1:
|
|
1656
1681
|
raise ValueError("take must be a positive integer")
|
|
1657
1682
|
|
|
1683
|
+
# forecast is a boolean: Orion's own docs claim "1 = Forecast Bill,
|
|
1684
|
+
# 0 = Live Bill", but the endpoint 400s on 0/1 and only accepts
|
|
1685
|
+
# true/false.
|
|
1658
1686
|
params = {
|
|
1659
1687
|
"startDate": start_date,
|
|
1660
1688
|
"endDate": end_date,
|
|
1661
|
-
"forecast":
|
|
1689
|
+
"forecast": "true" if is_forecast else "false",
|
|
1662
1690
|
"take": take,
|
|
1663
1691
|
}
|
|
1664
1692
|
if skip > 0:
|
|
@@ -1699,6 +1727,42 @@ class OrionAPI(BaseAPI):
|
|
|
1699
1727
|
res = self.api_request(url, requests.post)
|
|
1700
1728
|
return res.json()
|
|
1701
1729
|
|
|
1730
|
+
def sync_cash_to_eclipse(self, account):
|
|
1731
|
+
"""Export one cash funding row to Eclipse as a cash set-aside.
|
|
1732
|
+
|
|
1733
|
+
This is the API equivalent of the Cash Funding grid's export action:
|
|
1734
|
+
Orion creates (or updates) a set-aside in Eclipse for the account's
|
|
1735
|
+
balance due, so the fee cash is reserved from trading.
|
|
1736
|
+
|
|
1737
|
+
Orion documents this as a draft endpoint that takes a single account
|
|
1738
|
+
per call, so exporting a whole report means looping over the rows of
|
|
1739
|
+
get_cash_funding().
|
|
1740
|
+
|
|
1741
|
+
Args:
|
|
1742
|
+
account: A cash funding row as returned by get_cash_funding().
|
|
1743
|
+
The row's ``id`` is the Orion account ID and is sent as
|
|
1744
|
+
``accountId``. A dict already keyed ``accountId`` is also
|
|
1745
|
+
accepted. Keys outside ReceiveableSummaryDto are dropped.
|
|
1746
|
+
|
|
1747
|
+
Returns:
|
|
1748
|
+
dict: The created/updated Eclipse set-aside
|
|
1749
|
+
(EclipseCashFundingResponse) with id, accountId, cashAmount,
|
|
1750
|
+
cashAmountTypeId, description, expirationTypeId, etc.
|
|
1751
|
+
"""
|
|
1752
|
+
if not isinstance(account, dict):
|
|
1753
|
+
raise ValueError("account must be a cash funding row dict")
|
|
1754
|
+
|
|
1755
|
+
account_id = account.get("accountId", account.get("id"))
|
|
1756
|
+
if account_id is None:
|
|
1757
|
+
raise ValueError("account must have an 'id' (or 'accountId') field")
|
|
1758
|
+
|
|
1759
|
+
payload = {k: account[k] for k in RECEIVABLE_SUMMARY_FIELDS if k in account}
|
|
1760
|
+
payload["accountId"] = account_id
|
|
1761
|
+
|
|
1762
|
+
url = f"{self.base_url}/Billing/SyncCashtoEclipse"
|
|
1763
|
+
res = self.api_request(url, requests.post, json=payload)
|
|
1764
|
+
return res.json()
|
|
1765
|
+
|
|
1702
1766
|
# -------------------------------------------------------------------------
|
|
1703
1767
|
# Bill Management
|
|
1704
1768
|
# -------------------------------------------------------------------------
|
|
File without changes
|