Skip to content

Commit 59d9b76

Browse files
committed
add wise payouts rst
1 parent 925d322 commit 59d9b76

File tree

4 files changed

+71
-4
lines changed

4 files changed

+71
-4
lines changed

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Welcome to django-referral-system's documentation!
1515
promoter
1616
referral
1717
referral_service
18+
wise_payouts
1819

1920

2021
Key Features

docs/referral_service.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@ The `send_referral_invitation_email` method allows promoters to send an email in
101101

102102
1. **Environment Variables**:
103103

104-
Make sure to set the following environment variables in your `.env` file before sending referral invitation emails:
104+
Make sure to set the following environment variables in your `.env` file before sending referral invitation emails:
105105

106106
.. code-block:: bash
107107
108108
BASE_REFERRAL_LINK=
109109
BASE_EMAIL=
110+
These variables are necessary for generating the referral link and setting the "from" email address.
110111

111-
These variables are necessary for generating the referral link and setting the "from" email address.
112112

113113
2. **Correct Template Path**:
114114

docs/wise_payouts.rst

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
Wise Payouts
2+
============
3+
4+
This section explains how the `PromoterPayoutService` handles sending payouts via Wise to eligible promoters.
5+
6+
1. Sending Wise Payouts
7+
------------------------
8+
9+
The `send_wise_csv_for_promoters_payouts` method is responsible for generating a CSV file for Wise payouts and processing payouts for eligible promoters. It checks which promoters have a balance that meets or exceeds their minimum withdrawal amount and creates payouts for those promoters.
10+
11+
- **Method**: `send_wise_csv_for_promoters_payouts`
12+
13+
.. code-block:: python
14+
15+
promoter_payout_service.send_wise_csv_for_promoters_payouts()
16+
17+
### Example
18+
19+
Assume a promoter has a balance of $100, which meets or exceeds their minimum withdrawal balance of $50. The system will generate a Wise payout for that promoter and include the following data in the CSV file:
20+
21+
.. code-block:: csv
22+
23+
name,recipientEmail,amount,sourceCurrency,targetCurrency,amountCurrency,type
24+
John Doe,[email protected],100.00,USD,USD,target,EMAIL
25+
26+
### Key Points:
27+
28+
- **Payout Method**: The `payout_method` for these payouts is set to `'wise'`, and the `EMAIL` type is used, meaning payouts are processed based on the recipient’s email address.
29+
- **Currency**: The payout currency is set to USD by default, but it can be changed by passing additional arguments to the method.
30+
- **Balance Check**: Only promoters with a balance greater than or equal to their `min_withdrawal_balance` will be included in the payout.
31+
32+
2. CSV Generation
33+
------------------
34+
35+
The method generates the CSV data for Wise using a pandas DataFrame. The resulting CSV string can be sent to Wise for processing.
36+
37+
### Example CSV Data
38+
39+
.. code-block:: csv
40+
41+
name,recipientEmail,amount,sourceCurrency,targetCurrency,amountCurrency,type
42+
Jane Smith,[email protected],150.00,USD,USD,target,EMAIL
43+
John Doe,[email protected],100.00,USD,USD,target,EMAIL
44+
45+
This CSV file contains all the necessary information to process payouts through Wise, ensuring that the correct amount is paid to the corresponding recipient via email.
46+
47+
3. Payout Creation
48+
-------------------
49+
50+
After generating the payout data, the service automatically creates a payout record for each eligible promoter and marks their pending commissions as paid.
51+
52+
- **Method**: `create_payout`
53+
54+
.. code-block:: python
55+
56+
promoter_payout_service.create_payout(
57+
promoter=promoter_instance,
58+
amount=promoter_instance.current_balance,
59+
payout_method='wise'
60+
)
61+
62+
This method saves a `PromoterPayout` record for each promoter, and any commissions marked as "pending" are updated to "paid".
63+
64+
.. note::
65+
66+
Ensure that the promoters have a valid payout method (Wise) and that their balance meets the minimum withdrawal requirement to process payouts. The system will skip promoters who do not meet these conditions.

referrals/services/promoter_payout_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,14 @@ def calculate_commission_amount(amount_paid: int, referral_commission_rate: Deci
140140
return math.floor(Decimal(price) * commission_rate)
141141

142142
@staticmethod
143-
def create_payout(promoter: Promoter, amount: float, payout_method):
143+
def create_payout(promoter: Promoter, amount: float, payout_method: str):
144144
"""
145145
Creates a payout record for a promoter and marks their pending commissions as paid.
146146
147147
Args:
148148
promoter (Promoter): The promoter receiving the payout.
149149
amount (float): The payout amount.
150-
payout_method (str): The method used for the payout (e.g., 'wise', 'crypto').
150+
payout_method (str): The method used for the payout (e.g ., 'wise', 'crypto').
151151
152152
Returns:
153153
None

0 commit comments

Comments
 (0)