fix(site): Add server side validation for new site and server - #7455
Conversation
|
| def has_unpaid_invoices(self): | ||
| """Two or more unpaid subscription invoices blocks new sites and servers, matching the New Site and New Server forms.""" | ||
| return ( | ||
| frappe.db.count("Invoice", {"team": self.name, "status": "Unpaid", "type": "Subscription"}) >= 2 |
There was a problem hiding this comment.
Cancelled invoices block creation
Cancellation sets docstatus to 2 without changing an invoice's Unpaid status. This count therefore includes cancelled invoices, so two cancelled invoices—or one cancelled and one current invoice—can incorrectly block site and server creation.
| frappe.db.count("Invoice", {"team": self.name, "status": "Unpaid", "type": "Subscription"}) >= 2 | |
| frappe.db.count( | |
| "Invoice", | |
| {"team": self.name, "status": "Unpaid", "type": "Subscription", "docstatus": ("<", 2)}, | |
| ) | |
| >= 2 |
Prompt To Fix With AI
This is a comment left during a code review.
Path: press/press/doctype/team/team.py
Line: 817
Comment:
**Cancelled invoices block creation**
Cancellation sets `docstatus` to 2 without changing an invoice's `Unpaid` status. This count therefore includes cancelled invoices, so two cancelled invoices—or one cancelled and one current invoice—can incorrectly block site and server creation.
```suggestion
frappe.db.count(
"Invoice",
{"team": self.name, "status": "Unpaid", "type": "Subscription", "docstatus": ("<", 2)},
)
>= 2
```
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #7455 +/- ##
===========================================
+ Coverage 61.94% 62.02% +0.07%
===========================================
Files 1067 1067
Lines 102449 102569 +120
Branches 1777 1779 +2
===========================================
+ Hits 63460 63615 +155
+ Misses 38944 38909 -35
Partials 45 45
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Tick the box to add this pull request to the merge queue (same as
|
| if self.apply_limits and self.spending_limit <= self.total_subscribed_amount(): | ||
| why = "You have exceeded your spending limit. Please contact support to increase your limits." | ||
| return (False, why) |
There was a problem hiding this comment.
Invited child teams have apply_limits enabled by default, but this limit check runs before the parent_team exemption. Once a child team reaches its spending limit, it is incorrectly blocked from creating sites despite the existing exemption.
Prompt To Fix With AI
This is a comment left during a code review.
Path: press/press/doctype/team/team.py
Line: 1320-1322
Comment:
**Child Teams Lose Exemption**
Invited child teams have `apply_limits` enabled by default, but this limit check runs before the `parent_team` exemption. Once a child team reaches its spending limit, it is incorrectly blocked from creating sites despite the existing exemption.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.fix(site): Add server side validation for new site and server (backport #7455)
Earlier this validation was only on client side for teams on unpaid invoice, it will now check on server side as well.