Financial Functions

From Javul
Jump to navigation Jump to search

This page is intended for developers.

Here's a basic diagram showing the flow of funds on the website:

General flow of finances

We can see:

  • A logged-in user or anonymous person can donate in different ways using Paypal. These flows are shown by Black arrows. Every Donation that comes in goes to the main Javul Paypal account. Donation can be made to a specific Unit, Objective or User. It can also be made into the General Purpose fund.
  • Once that donation is completed, transfer of funds can be done internally using the red arrows. For these internal transfers Paypal is not involved.
  • Here is an example scenario: An anonymous user donates $100 to a Unit ABC using Paypal. What actually happens is that the money goes to Javul's main Paypal account. So now we have $100 in Javul's main Paypal account. In our database we record that $100 was donated to Unit ABC and the donation balance for Unit ABC is updated. From there we can assign $20 from the Unit's funds into a specific Objective that belongs to that Unit. The Objective can assign funds to a Task. When a user completes that tasks, they get an external payment using Paypal for completing that task. The $20 is transferred from the main Javul Paypal account to the user's Paypal account.

The following is the details for what happens when an anonymous user sends a donation to a Unit and a Unit's task is completed by a user:

  1. User (not logged-in) clicks on "+" icon on a Unit's home page.
  2. They are shown a donation page that gives them an empty text box for the amount of donation to enter. Also show them a section that says "You can donate as an anonymous user or Login if you have an account". If the user is logged-in, they are given option to either donate anonymously or not. Anonymous means their username will not appear in the Global activity logs for the donation, only the amount and the Target unit.
  3. When any donation happens, there is a line in the Activity log of the Unit that says "User ABC donated XYZ dollars". When a non-logged in user donates, or a logged-in user donates with the anonymous option, the 'user ABC' is replaced with "Anonymous" in the activity log.
  4. After the amount is entered, they can click on "Pay with Paypal" and the API for Paypal is run.
  5. For example if its $100 dollars, this money was transferred to Javul's main Paypal account.
  6. The database for Unit ABC is updated so there is now $100 in Unit ABC's account.
  7. Any user creates an Objective and assigns $30 to that objective. The available balance for the Unit is now $70. This is an internal transfer meaning there is no actual Paypal transaction involved. For details of this step, and the next two steps, see the section below.
  8. Any user creates a Task and assigns it $20. This is also an internal transfer. The available balance for the Objective is now $10 (30-20).
  9. Any user completes the task and now they need a Paypal transfer of $20 to their personal Paypal account. This will be an external transfer. The task is marked as complete. The user is shown the option to withdraw funds into their Paypal account. The money goes from the Javul's main Paypal account to the user's Paypal account.

Other donation functions are similar. Donations can be made to an Objective and also to Javul's general purpose fund. If someone is donating but they dont know their specific target, they can just donate to the General purpose fund. From there funds can be transferred to other Units as needed.

Donations can also be made directly to a user. In this case the donation does not go through the Javul Paypal account. It goes directly to that user's Paypal address.

In order for a User to receive a donation they need to have a Paypal address in their account settings.

TASKS These are some tasks related to resolving this issue:

  • Test and implement donation to a user
  • Items 7~9 (how funds are used by an Objective, task and are finally transferred to a User)

Later:

  • General purpose Javul fund so funds can be used for any purpose as necessary. This needs some more specifications in terms of database e.g. maybe special functions for the specific unit of Javul which enables us to transfer funds from that unit to any other unit.


Details of Steps 7-9 from above[edit | edit source]

Variables involved:

  • Global: funds_available, funds_awarded
  • User: funds_balance, funds_awarded
  • Unit, Objective: funds_balance, funds_awarded
  • Task: financial_reward

A Unit has many objectives. The idea is that funds in a Unit can be used for Objectives and Tasks within that Unit. An objective is completed when all of its tasks are completed.

Scenario 1[edit | edit source]

  1. Someone donates $100 to a Unit. They will actually donate e.g. 102 to cover for the fees but Javul receives the amount after fees are charged. This money $100 goes to Javul's main Paypal account. Now the Unit's 'funds_available' are now +100. This means increase current amount of that DB field by 100.
  2. There is a Global database field 'funds_available' that is now also +100. This is displayed at the bottom of the website in the page footer (funds available). This means the total funds available on the website for all Units and Objectives.
  3. Someone assigns $30 to an Objective in that Unit. This is how it happens. When we click on 'add funds' for any Objective and there are funds available in that Unit (>0), we can see two options. One is the regular "Donate via Paypal". The other is a 'Transfer from Unit' button. There is a place to enter the money which has to be less then the Unit's funds_available. The person presses the Transfer button with $30 entered. The Unit 'funds_available' is now 70. The Objective 'funds_available' are updated to be 30.
  4. Each Task has an 'financial_reward' database field. User 'A' creates a task with $20 as the Financial reward (for completing the task). Every user has a "Funds_balance" database field. User 'A' completes a Task belonging to that Objective. After the task is completed by the User and approved by the Site admin, the Funds_balance is +20.

When this happens these three database fields get a +20: The Objectives 'funds_Awarded', Unit's 'funds_Awarded' and the Global website 'funds_awarded' (displayed in website's Footer).
Until now the money has remained in Javul's Paypal account. We're just internally assigning the owner of a specific amount of funds.

  1. "Withdraw" button inside a User's Account settings can allow them to transfer the amount they have in the 'funds_balance' from Javul's Paypal to their own Paypal account. They can enter the amount they want to transfer (0 to the maximum of Funds_available). Suppose they select 20 and transfer. So now $20 is sent to User's Paypal. Paypal fees for the transfer are paid by the User. Their funds_balance is now 0$. The user's funds_Awarded is +20.

Scenario 2[edit | edit source]

Someone donates $30 directly to an Objective. The money goes to Javul's paypal account. The Objectives 'Funds_available' and global 'funds_available' is updated as +30. A Task is created with $20 and is completed by the user. The rest of the process is the same as for Scenario 1. Even in this case when the User is awarded the money, the Unit's 'funds_awarded" will be +20.