# Split payment
Split payment allows customers to divide their payment for a single transaction across multiple payment methods. This feature provides flexibility and convenience, accommodating customers who may have different sources of funds or prefer to use multiple payment methods.
# Split Payment UI Solutions
## Split Payment Method Page
Below the payment methods, there should be a link for the Split payment method. When the link is clicked, it should navigate to another page where users can select the mode of payment using radio buttons. There should also be input fields to enter the payment amount.
Flow:
1. Items selected
2. Customer
3. Payment method page
4. Option to select split payment
5. New page with radio buttons to select payment option
6. Field to enter the amount
7. Confirm payment
8. Print bill
9. Back to billing dashboard
Changes needed:
- Add a link for split payment
- Create a new page with split payment method (radio buttons and input fields)
Impact: Additional work required to implement the new page with split payment functionality.
## Split Payment Button
On the payment page, add a button for split payment. When clicked, it should display a pop-up with payment options listed, along with input fields to enter the amount for each payment option. A "Save" button should be included in the pop-up to return to the previous payment page and continue the normal flow.
Flow:
1. Items selected
2. Customer
3. Payment method page
4. Split payment button
5. Pop-up with payment options and input fields
6. Enter the amount for each payment mode
7. Save button
8. Back to normal billing flow
Changes needed:
- Add a button for split payment
- Create a new pop-up with split payment method (input fields)
Additional work:
- Implement the new pop-up functionality
- Create functions to retrieve payment methods and their amounts, and save the context
- Handle the list of payment methods and input fields
## Split Payment with Multiple Options
Add a button for split payment that allows the selection of two or more payment options simultaneously. Input fields should be included for entering the amount for each selected payment option. The normal billing procedures should be followed after entering the amounts.
Flow:
1. Items selected
2. Customer
3. Payment method page
4. Split payment button
5. Enter the amount for each selected payment mode (same as the cash balance)
6. Follow the normal billing flow
Changes needed:
- Add a button for split payment
- Include conditional input fields in all payment methods
Additional work:
- Implement the button for split payment
- Include conditional input fields in all payment methods
- Create functions to retrieve payment methods and their amounts, and save the context
## Split payment icon
An icon for split payment on the payment page. When clicked on the icon a drawer appears with options to select the payment modes with the input fields to enter the amount and a button to save. When clicked save button, we are back to print bill option.
### Flow:
1. Items selected
2. Customer
3. Payment method page
4. Split payment icon
5. Drawer appears
6. Enter the amount for each selected payment mode
7. Save it
8. Follow the normal billing flow
Changes needed:
- Add an icon for split payment in the payment select page
- Create a drawer
- Include conditional input fields in all payment methods
Additional work:
- Implement the icon for split payment
- Include conditional input fields in all payment methods
- Create functions to retrieve payment methods and their amounts, and save the context.
# Back-end Solutions
## Add New Choice and JSON Field
1. Add "split" as a payment method choice.
2. Add a JSON field named "payments" in the order.
Example:
```json
"payments": [
{"Cash": 120},
{"Upi": 120},
{"Card": 120}
]
```
The "payments" JSON field will only be filled if the payment choice is split.
3. When creating transactions, generate as many transactions as there are payment options in the "payments" JSON field.
4. Payment statistics can be obtained from the transaction API without significant changes.
5. If orders are filtered by the split payment method, statistics can also be obtained for split payments.
6. When an order is canceled, all related transactions are already deleted.
Flow:
- For orders without split payment:
- Normal backend flow with no changes required.
- For orders with split payment:
- Normal backend flow until the transaction creation function.
- Create transactions for each payment option.
Changes needed:
- Add a new payment choice, "split," to the payment choices.
- Add a new JSON field, "payments," in the order.
- If any payment statistics are using the order object, change them to use transactions instead.
Additional work:
- Implement the "split" payment choice in the payment choices.
- Implement the new JSON field, "payments."
- Add a condition to check if the payment method is "split" and generate the related transactions.
- If any payment statistics are using the order object, change them to use transactions instead.
Impact:
- Does not affect current existing orders and transactions.
- Income statistics can rely completely on transactions.
- Orders with split payment statistics can be filtered and displayed in statistics and reports.
- No need to worry about canceling orders because all related transactions are already deleted.
## Change Payment Method to JSON
1. Change the current "payment_method" field to a JSON field.
Example:
```json
"payment_method": {
"Cash": 120,
"Upi": 120,
"Card": 120
}
```
The "payment_method" JSON field will be filled as shown in the example.
2. Completely change the current transaction creation function to accommodate the new JSON field.
3. Update the order statistics (report generating API functions) to reflect the changes.
4. Update the frontend wherever the order is displayed.
5. Modify the frontend logic for creating orders.
Flow:
- When an order is placed and paid, if the "payment_method" JSON field is not empty, call the functions for creating transactions.
Changes needed:
- Change the current "payment_method" field to a JSON field.
- Completely change the current transaction creation function.
- Modify the order statistics API (report).
Additional work:
- Implement the new JSON field, "payment_method."
- Completely change the transaction creation function.
- Update the order statistics API (report).
- Modify the frontend wherever the order is displayed.
- Adjust the frontend logic for creating orders.
Impact:
- May affect current existing orders and transactions.
- Income statistics can rely completely on transactions.
- Order statistics with split payments will be more difficult to handle.
- Report API functions will need to be updated.
## Impact & scope
**UI Solutions**
| Name | Flow | Changes Needed | Additional Work | Impact |
|-----------------------------|-------------------------------------------------------|---------------------------------------------|---------------------------------------------|-----------------------------------------|
| Split Payment Method Page | Items selected >> Customer >> Payment method page >> option to select split payment >> New page >> Radio buttons >> Amount field >> Confirm payment >> Print bill >> Back to billing dashboard | Add split payment link <br> Create new page with radio buttons and amount field | Implement new page functionality <br> Create functions for radio buttons and amount field | Additional work for implementation |
| Split Payment Button | Items selected >> Customer >> Payment method page >> Split payment button >> Pop-up >> Enter amount >> Save button >> Back to normal billing flow | Add split payment button <br> Create pop-up with payment method input fields | Implement pop-up functionality <br> Create functions for input fields | Additional work for implementation |
| Split Payment with Multiple Options | Items selected >> Customer >> Payment method page >> Split payment button >> Enter amount for each payment option >> Follow normal billing flow | Add split payment button <br> Include conditional input fields in payment methods | Implement split payment button <br> Implement conditional input fields | Additional work for implementation |
**Backend Solutions**
| Name | Flow | Changes Needed | Additional Work | Impact |
|-----------------------------|-------------------------------------------------------|---------------------------------------------|---------------------------------------------|-----------------------------------------|
| Add New Choice and JSON Field | Normal flow for non-split payment choice <br> For split payment choice, create transactions for each payment option | Add split payment choice <br> Add payment_methods JSON field <br> Handle split payment in transaction creation | Implement split payment logic <br> Update order statistics API | No impact on existing orders <br> Enhanced income statistics and reporting |
| Change Payment Method to JSON | Call transaction creation functions if payment_method JSON field is not empty | Change payment_method field to JSON <br> Modify transaction creation function | Update order statistics API <br> Update frontend display | May affect existing orders <br> Improved income statistics and reporting |