portal: dues = the co-op's share, not the donor's OC total
ci/woodpecker/push/woodpecker Pipeline was canceled
ci/woodpecker/push/woodpecker Pipeline was canceled
totalAmount includes the buyer's optional Open Collective tip, so a member who tips showed a higher dues level than they pay us. Use amount.value — the base contribution that reaches the co-op — and fetch it alongside totalAmount. The webhook credit-pack path made this same mistake and already resolves it via the public order API.
This commit is contained in:
1 parent
a814a5f7f9
commit
f7f6946207
1 file changed
+6
-4
+6
-4
@@ -7365,7 +7365,7 @@ async def fetch_member_orders() -> dict[str, list[dict]]:
|
|||||||
query = (
|
query = (
|
||||||
'{ collective(slug: "%s") { orders(limit: 200) { totalCount nodes { '
|
'{ collective(slug: "%s") { orders(limit: 200) { totalCount nodes { '
|
||||||
"frequency status createdAt lastChargedAt nextChargeDate "
|
"frequency status createdAt lastChargedAt nextChargeDate "
|
||||||
"fromAccount { slug } totalAmount { value currency } } } } }"
|
"fromAccount { slug } amount { value currency } totalAmount { value currency } } } } }"
|
||||||
% OC_COLLECTIVE_SLUG
|
% OC_COLLECTIVE_SLUG
|
||||||
)
|
)
|
||||||
async with httpx.AsyncClient(timeout=30.0) as client:
|
async with httpx.AsyncClient(timeout=30.0) as client:
|
||||||
@@ -7402,8 +7402,10 @@ def _current_dues(orders: list[dict]) -> tuple[float | None, str | None]:
|
|||||||
ONE-TIME order is a credit purchase and never sets dues;
|
ONE-TIME order is a credit purchase and never sets dues;
|
||||||
* only a LIVE one (ACTIVE or PROCESSING) counts — a CANCELLED subscription
|
* only a LIVE one (ACTIVE or PROCESSING) counts — a CANCELLED subscription
|
||||||
is not what the member currently pays;
|
is not what the member currently pays;
|
||||||
* the amount is the order's per-charge total (`totalAmount.value`), the
|
* the amount is the co-op's share — `amount.value`, the base contribution.
|
||||||
same figure OC bills each cycle;
|
`totalAmount` adds the buyer's optional Open Collective tip, which never
|
||||||
|
reaches us (the webhook path made this same mistake once — see the
|
||||||
|
comment at the top of this file);
|
||||||
* no live recurrence, an unparseable amount, or a non-positive amount →
|
* no live recurrence, an unparseable amount, or a non-positive amount →
|
||||||
(None, None). NEVER guess and NEVER fall back to the $15 allowance.
|
(None, None). NEVER guess and NEVER fall back to the $15 allowance.
|
||||||
"""
|
"""
|
||||||
@@ -7414,7 +7416,7 @@ def _current_dues(orders: list[dict]) -> tuple[float | None, str | None]:
|
|||||||
if freq not in ("MONTHLY", "YEARLY") or status not in ("ACTIVE", "PROCESSING"):
|
if freq not in ("MONTHLY", "YEARLY") or status not in ("ACTIVE", "PROCESSING"):
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
amt = float((o.get("totalAmount") or {}).get("value"))
|
amt = float((o.get("amount") or {}).get("value"))
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
continue
|
continue
|
||||||
if amt <= 0:
|
if amt <= 0:
|
||||||
|
|||||||
Reference in new issue
Block a user