2021-10-18 15:00:38 +09:00
@using BTCPayServer.Client.Models
2024-05-01 10:22:07 +09:00
@using BTCPayServer.Payouts
2021-10-22 04:17:40 +02:00
@using BTCPayServer.Views.Stores
2021-12-07 16:40:24 +01:00
@using BTCPayServer.Client
2021-10-22 04:17:40 +02:00
@model BTCPayServer.Models.WalletViewModels.PayoutsModel
2021-04-13 10:36:49 +02:00
2024-05-01 10:22:07 +09:00
@inject PayoutMethodHandlerDictionary PayoutHandlers;
2020-06-24 10:34:09 +09:00
@{
2022-04-24 05:19:34 +02:00
var storeId = Context.GetRouteValue("storeId") as string;
2024-10-25 15:48:53 +02:00
ViewData.SetActivePage(StoreNavPages.Payouts, string.IsNullOrEmpty(Model.PullPaymentName) ? StringLocalizer["Payouts"] : StringLocalizer["Payouts for pull payment {0}", Model.PullPaymentName], Context.GetStoreData().Id);
2021-11-08 08:21:07 +01:00
Model.PaginationQuery ??= new Dictionary<string, object>();
Model.PaginationQuery.Add("pullPaymentId", Model.PullPaymentId);
2024-05-01 10:22:07 +09:00
Model.PaginationQuery.Add("payoutMethodId", Model.PayoutMethodId);
2021-11-08 08:21:07 +01:00
Model.PaginationQuery.Add("payoutState", Model.PayoutState);
2021-06-30 08:59:01 +01:00
var stateActions = new List<(string Action, string Text)>();
2024-05-01 10:22:07 +09:00
if (PayoutMethodId.TryParse(Model.PayoutMethodId, out var payoutMethodId))
2021-10-22 04:17:40 +02:00
{
2024-05-01 10:22:07 +09:00
var payoutHandler = PayoutHandlers.TryGet(payoutMethodId);
2021-10-22 04:17:40 +02:00
if (payoutHandler is null)
return;
stateActions.AddRange(payoutHandler.GetPayoutSpecificActions().Where(pair => pair.Key == Model.PayoutState).SelectMany(pair => pair.Value));
}
2024-04-15 13:25:17 +02:00
2021-06-30 08:59:01 +01:00
switch (Model.PayoutState)
{
case PayoutState.AwaitingApproval:
2024-10-25 15:48:53 +02:00
if (!Model.HasPayoutProcessor) stateActions.Add(("approve-pay", StringLocalizer["Approve & Send"]));
stateActions.Add(("approve", StringLocalizer["Approve"]));
stateActions.Add(("cancel", StringLocalizer["Cancel"]));
2021-06-30 08:59:01 +01:00
break;
case PayoutState.AwaitingPayment:
2024-10-25 15:48:53 +02:00
if (!Model.HasPayoutProcessor) stateActions.Add(("pay", StringLocalizer["Send"]));
stateActions.Add(("cancel", StringLocalizer["Cancel"]));
stateActions.Add(("mark-paid", StringLocalizer["Mark as already paid"]));
2021-06-30 08:59:01 +01:00
break;
}
2020-06-24 10:34:09 +09:00
}
2022-06-02 11:03:06 +02:00
@section PageHeadContent {
<style>
#Payouts .badge.rounded-pill {
font-size: var(--btcpay-font-size-s);
color: inherit;
}
</style>
}
2021-05-19 04:39:27 +02:00
@section PageFootContent {
<script>
2021-10-05 08:52:14 +02:00
delegate('click', '.selectAll', e => {
const { payoutState } = e.target.dataset;
document.querySelectorAll(`.selection-item-${payoutState}`).forEach(checkbox => {
checkbox.checked = e.target.checked;
});
});
2021-05-19 04:39:27 +02:00
</script>
}
2021-04-13 10:36:49 +02:00
2024-06-19 15:23:10 +02:00
<div class="sticky-header">
<h2 class="my-1">
2023-02-13 00:25:24 -08:00
@ViewData["Title"]
<a href="#descriptor" data-bs-toggle="collapse">
<vc:icon symbol="info" />
</a>
</h2>
</div>
<div id="descriptor" class="collapse">
<div class="d-flex px-4 py-4 mb-4 bg-tile rounded">
<div class="flex-fill">
2023-05-11 01:37:28 -07:00
<p class="mb-3">
2024-10-25 15:48:53 +02:00
<span text-translate="true">Payouts allow you to process pull payments, in the form of refunds, salary payouts, or withdrawals.</span>
<span permission="@Policies.CanModifyStoreSettings">You can also <a id="PayoutProcessors" asp-action="ConfigureStorePayoutProcessors" asp-controller="UIPayoutProcessors" asp-route-storeId="@storeId">configure payout processors</a> to automate payouts.</span>
2023-05-11 01:37:28 -07:00
</p>
2024-10-17 15:51:40 +02:00
<a href="https://docs.btcpayserver.org/Payouts/" target="_blank" rel="noreferrer noopener" text-translate="true">Learn More</a>
2023-02-13 00:25:24 -08:00
</div>
2024-10-25 15:48:53 +02:00
<button type="button" class="btn-close ms-auto" data-bs-toggle="collapse" data-bs-target="#descriptor" aria-expanded="false" aria-label="@StringLocalizer["Close"]">
2023-02-13 00:25:24 -08:00
<vc:icon symbol="close" />
</button>
</div>
</div>
<partial name="_StatusMessage" />
2022-04-24 05:19:34 +02:00
2024-04-15 13:25:17 +02:00
@if (!Model.HasPayoutProcessor)
2022-04-24 05:19:34 +02:00
{
2023-12-01 09:12:02 +01:00
<div class="alert alert-info mb-5" role="alert" permission="@Policies.CanModifyStoreSettings">
2024-10-25 15:48:53 +02:00
<span text-translate="true">Pro tip: There are supported but unconfigured Payout Processors for this payout payment method.</span><br/>
<span text-translate="true">Payout Processors help automate payouts so that you do not need to manually handle them.</span>
2024-10-17 15:51:40 +02:00
<a class="alert-link p-0" asp-action="ConfigureStorePayoutProcessors" asp-controller="UIPayoutProcessors" asp-route-storeId="@storeId" text-translate="true">Configure now</a>
2022-04-24 05:19:34 +02:00
</div>
}
2021-12-16 11:04:04 +01:00
2022-06-02 11:03:06 +02:00
<form method="post" id="Payouts">
2024-05-01 10:22:07 +09:00
<input type="hidden" asp-for="PayoutMethodId" />
2023-02-13 00:25:24 -08:00
<input type="hidden" asp-for="PayoutState" />
2022-01-11 00:15:23 -08:00
<div class="d-flex justify-content-between mb-4">
2023-02-21 03:06:27 +01:00
<ul class="nav mb-1 gap-2">
2024-05-01 10:22:07 +09:00
@foreach (var state in Model.PayoutMethods)
2022-01-11 00:15:23 -08:00
{
<li class="nav-item py-0">
<a asp-action="Payouts" asp-route-storeId="@Context.GetRouteValue("storeId")"
asp-route-payoutState="@Model.PayoutState"
2024-05-01 10:22:07 +09:00
asp-route-payoutMethodId="@state.ToString()"
2022-01-11 00:15:23 -08:00
asp-route-pullPaymentId="@Model.PullPaymentId"
2024-05-01 10:22:07 +09:00
class="btcpay-pill position-relative me-0 @(state.ToString() == Model.PayoutMethodId ? "active" : "")"
2022-01-11 00:15:23 -08:00
id="@state.ToString()-view"
2022-04-24 05:19:34 +02:00
role="tab">
2024-04-04 16:31:04 +09:00
@state.ToString()
2024-05-01 10:22:07 +09:00
@if (Model.PayoutMethodCount.TryGetValue(state.ToString(), out var count) && count > 0)
2022-04-24 05:19:34 +02:00
{
2022-06-02 11:03:06 +02:00
<span class="badge rounded-pill fw-semibold pe-0">@count</span>
2022-04-24 05:19:34 +02:00
}
</a>
2022-01-11 00:15:23 -08:00
</li>
}
</ul>
2021-06-30 08:59:01 +01:00
</div>
2022-01-21 02:35:12 +01:00
<nav id="SectionNav" class="mb-3">
<div class="nav">
@foreach (var state in Model.PayoutStateCount)
{
<a id="@state.Key-view"
asp-action="Payouts"
asp-route-storeId="@Context.GetRouteValue("storeId")"
asp-route-payoutState="@state.Key"
asp-route-pullPaymentId="@Model.PullPaymentId"
2024-05-01 10:22:07 +09:00
asp-route-payoutMethodId="@Model.PayoutMethodId"
2022-04-24 05:19:34 +02:00
class="nav-link @(state.Key == Model.PayoutState ? "active" : "")" role="tab">
2023-02-13 00:25:24 -08:00
@state.Key.GetStateString()
2022-06-02 11:03:06 +02:00
@if (state.Value > 0)
{
2022-06-05 14:40:39 +02:00
<span class="badge rounded-pill fw-semibold ms-1 bg-medium">@state.Value</span>
2022-06-02 11:03:06 +02:00
}
2022-04-24 05:19:34 +02:00
</a>
2022-01-21 02:35:12 +01:00
}
</div>
2022-01-11 00:15:23 -08:00
</nav>
@if (Model.Payouts.Any())
{
<div class="table-responsive">
2023-11-02 08:12:28 +01:00
<table class="table table-hover mass-action">
<thead class="mass-action-head">
2023-02-13 00:25:24 -08:00
<tr>
2023-11-02 08:12:28 +01:00
@if (stateActions.Any())
{
<th class="only-for-js mass-action-select-col" permission="@Policies.CanModifyStoreSettings">
<input type="checkbox" class="form-check-input mass-action-select-all" data-payout-state="@Model.PayoutState.ToString()" />
</th>
}
<th class="date-col">
<div class="d-flex align-items-center gap-1">
2024-10-17 15:51:40 +02:00
<span text-translate="true">Date</span>
2024-05-20 01:57:46 +02:00
<button type="button" class="btn btn-link p-0 switch-time-format only-for-js" title="Switch date format">
<vc:icon symbol="time" />
</button>
2023-11-02 08:12:28 +01:00
</div>
2023-02-13 00:25:24 -08:00
</th>
2024-10-17 15:51:40 +02:00
<th text-translate="true">Source</th>
<th text-translate="true">Destination</th>
<th text-translate="true" class="amount-col">Amount</th>
2021-06-30 08:59:01 +01:00
@if (Model.PayoutState != PayoutState.AwaitingApproval)
2021-05-19 04:39:27 +02:00
{
2024-10-17 15:51:40 +02:00
<th text-translate="true" class="text-end">Transaction</th>
2021-06-30 08:59:01 +01:00
}
</tr>
2023-02-13 00:25:24 -08:00
</thead>
2023-11-02 08:12:28 +01:00
@if (stateActions.Any())
{
<thead class="mass-action-actions" permission="@Policies.CanModifyStoreSettings">
<tr>
<th class="mass-action-select-col only-for-js">
<input type="checkbox" class="form-check-input mass-action-select-all" />
</th>
<th colspan="5">
<div class="d-flex flex-wrap align-items-center justify-content-between gap-3">
<div>
<strong class="mass-action-selected-count">0</strong>
2024-10-17 15:51:40 +02:00
<span text-translate="true">selected</span>
2023-11-02 08:12:28 +01:00
</div>
<div class="d-inline-flex align-items-center gap-3">
@foreach (var action in stateActions)
{
<button type="submit" id="@Model.PayoutState-@action.Action" name="Command" class="btn btn-link" value="@Model.PayoutState-@action.Action">@action.Text</button>
}
</div>
</div>
</th>
</tr>
</thead>
}
2023-02-13 00:25:24 -08:00
<tbody>
2023-11-02 08:12:28 +01:00
@for (var i = 0; i < Model.Payouts.Count; i++)
2023-02-13 00:25:24 -08:00
{
var pp = Model.Payouts[i];
2023-11-02 08:12:28 +01:00
<tr class="payout mass-action-row">
@if (stateActions.Any())
{
2023-11-09 10:17:52 +01:00
<td class="only-for-js mass-action-select-col align-middle" permission="@Policies.CanModifyStoreSettings">
2023-11-02 08:12:28 +01:00
<input type="checkbox" class="selection-item-@Model.PayoutState.ToString() form-check-input mass-action-select" asp-for="Payouts[i].Selected" />
2023-02-13 00:25:24 -08:00
<input type="hidden" asp-for="Payouts[i].PayoutId" />
2023-11-02 08:12:28 +01:00
</td>
}
2023-11-09 10:17:52 +01:00
<td class="date-col align-middle">
2023-11-02 08:12:28 +01:00
@pp.Date.ToBrowserDate()
2023-02-13 00:25:24 -08:00
</td>
2023-11-09 10:17:52 +01:00
<td class="align-middle">
2023-07-24 11:37:18 +02:00
@if (pp.SourceLink is not null && pp.Source is not null)
{
<a href="@pp.SourceLink" rel="noreferrer noopener">@pp.Source</a>
}
else if (pp.Source is not null)
{
<span>@pp.Source</span>
}
2023-02-13 00:25:24 -08:00
</td>
2023-11-09 10:17:52 +01:00
<td class="align-middle">
<vc:truncate-center text="@pp.Destination" classes="truncate-center-id" />
2023-02-13 00:25:24 -08:00
</td>
2023-11-09 10:17:52 +01:00
<td class="amount-col align-middle">
2023-05-11 10:35:51 +02:00
<span data-sensitive>@pp.Amount</span>
2023-02-13 00:25:24 -08:00
</td>
@if (Model.PayoutState != PayoutState.AwaitingApproval)
{
2023-11-09 10:17:52 +01:00
<td class="text-end align-middle">
@if (!string.IsNullOrEmpty(pp.ProofLink))
2023-02-13 00:25:24 -08:00
{
2024-10-17 15:51:40 +02:00
<a class="transaction-link" href="@pp.ProofLink" rel="noreferrer noopener" text-translate="true">Link</a>
2023-02-13 00:25:24 -08:00
}
</td>
}
</tr>
}
2022-01-11 00:15:23 -08:00
</tbody>
</table>
</div>
2023-02-13 00:25:24 -08:00
<vc:pager view-model="Model" />
2022-01-11 00:15:23 -08:00
}
else
{
2024-10-25 15:48:53 +02:00
<p class="text-muted mb-0" id="@Model.PayoutState-no-payouts" text-translate="true">There are no payouts matching these criteria.</p>
2022-01-11 00:15:23 -08:00
}
2020-06-24 10:34:09 +09:00
</form>