support: Update billing modality for remote server current plan.

This commit is contained in:
Lauryn Menard 2023-12-04 22:44:04 +01:00 committed by Tim Abbott
parent 9f8fe7989a
commit f5ab9419d2
2 changed files with 19 additions and 0 deletions

View File

@ -389,6 +389,9 @@ def remote_servers_support(
discount: Optional[Decimal] = REQ(default=None, converter=to_decimal), discount: Optional[Decimal] = REQ(default=None, converter=to_decimal),
sponsorship_pending: Optional[bool] = REQ(default=None, json_validator=check_bool), sponsorship_pending: Optional[bool] = REQ(default=None, json_validator=check_bool),
approve_sponsorship: bool = REQ(default=False, json_validator=check_bool), approve_sponsorship: bool = REQ(default=False, json_validator=check_bool),
billing_modality: Optional[str] = REQ(
default=None, str_validator=check_string_in(VALID_BILLING_MODALITY_VALUES)
),
) -> HttpResponse: ) -> HttpResponse:
context: Dict[str, Any] = {} context: Dict[str, Any] = {}
@ -424,6 +427,11 @@ def remote_servers_support(
support_type=SupportType.attach_discount, support_type=SupportType.attach_discount,
discount=discount, discount=discount,
) )
elif billing_modality is not None:
support_view_request = SupportViewRequest(
support_type=SupportType.update_billing_modality,
billing_modality=billing_modality,
)
if support_view_request is not None: if support_view_request is not None:
billing_session = RemoteServerBillingSession( billing_session = RemoteServerBillingSession(
support_staff=acting_user, remote_server=remote_server support_staff=acting_user, remote_server=remote_server

View File

@ -107,6 +107,17 @@
<b>End date</b>: {{ plan_data[remote_server.id].current_plan.end_date.strftime('%d %B %Y') }}<br /> <b>End date</b>: {{ plan_data[remote_server.id].current_plan.end_date.strftime('%d %B %Y') }}<br />
{% endif %} {% endif %}
</div> </div>
<form method="POST" class="remote-server-form">
<b>Billing collection method</b><br />
{{ csrf_input }}
<input type="hidden" name="remote_server_id" value="{{ remote_server.id }}" />
<select name="billing_modality" class="billing-modality-select" required>
<option value="charge_automatically" {% if plan_data[remote_server.id].current_plan.charge_automatically %}selected{% endif %}>Charge automatically</option>
<option value="send_invoice" {% if not plan_data[remote_server.id].current_plan.charge_automatically %}selected{% endif %}>Pay by invoice</option>
</select>
<button type="submit" class="btn btn-default support-submit-button">Update</button>
</form>
{% endif %} {% endif %}
</div> </div>
{% endfor %} {% endfor %}