Payment with multi tagging and Wallet Process
Author(s)
- Reshmi Karan
- Sayan Mukherjee
Last Updated Date
2024-09-13
SRS References
Version History
| Version | Date | Changes | Author |
|---|---|---|---|
| 1.0 | 2024-09-12 | Initial draft | Reshmi Karan, Sayan Mukherjee |
| 2.0 | 2024-09-30 | Service changes | Reshmi Karan |
Feature Overview
Objective:
Enable users to register multiple invoices and order payments, allowing for extra payments to be added to the wallet and enabling payments via mixed modes.
Scope:
The feature is specifically for Fleeto and Distributors, allowing them to handle payments at defined stages, including invoice and order adjustments, as well as managing a wallet for the buyer at each stage.
Dependencies:
Existing Payment Api
Requirements
- Move the payment amount field to the top of the payment mode section and display payment modes only when the payment amount is greater than 0.
- Display all relevant balances (wallet, due note/credit limit, credit note) at the top for the selected dealer.
- Allow the entry of a payment amount that can exceed the adjusted invoice and order pending amounts, with the condition that the amount must be greater than 0.
- If a user selects any payment mode (cheque, online transfer, UPI, cash, Credit Note), display options to choose multiple invoices or orders.
- If a user selects any payment mode (cheque, online transfer, UPI, cash) and there are invoices or orders present, the user must choose at least one. If no invoices or orders are available, the user can submit the payment, and the total amount will be added to the wallet.
- If user choose payment mode like (cheque,online transfer, upi, cash) and adjusted invoice or order pending amount is less than payment amount then remaining one goes to wallet.
- Display the due note option when the combined wallet balance and credit note total will be 0.
- Adjust invoices, and orders with normal payment methods and the wallet.
- If a user select Credit Note payment mode and there are no invoices or orders present, the user cannot submit button.
- A user can choose wallet if wallet balance is greater than 0. Payment amount is greater than wallet balance then he cannot show wallet option.
- Use wallet balance option in add payment.
- Every time, the user can choose whether to adjust with the wallet or not, except for due notes.
Design Specifications
-
UI/UX Design:
-
Data Models:
public class InitiatePaymentReceipt
{
public required PaymentReceipt Receipt { get; set; }
public List<PaymentReceiptDetails>? PaymentReceiptDetails { get; set; }
public PaymentReceiptDetails? AdjustedCrInvoice { get; set; }
}
public class PaymentReceipt
{
#region Transaction related common data
[JsonIgnore]
public Guid TransactionId { get; set; }
[JsonIgnore]
public DateTime InitTimestamp { get; set; }
[JsonIgnore]
public DateTime TransactionDate { get; set; }
[JsonIgnore]
public DateTime TransactionTimeout { get; set; } = DateTime.MaxValue;
[JsonIgnore]
public PaymentTransactionStatus PaymentTransactionStatus { get; set; } = PaymentTransactionStatus.Unknown;
public PaymentType PaymentType { get; set; } = PaymentType.Unknown;
[Range(0.01, double.MaxValue, ErrorMessage = "Amount must be greater than zero.")]
public decimal Amount { get; set; }
#endregion
#region Transaction type related data
public PaymentManualStruct? ManualTransDetails { get; set; }
public PaymentGatewayTransaction? PgTransactionDetails { get; set; }
public UPITransaction? UPITransactionDetails { get; set; }
#endregion
#region Consumer and user related
public required Guid ConsumerId { get; set; }
[Required(AllowEmptyStrings = false)]
public string ConsumerName { get; set; }
[Required(AllowEmptyStrings = false)]
public string ConsumerCode { get; set; }
public Guid? LogUserId { get; set; }
public string? LogUserName { get; set; }
public bool? IsWalletPay { get; set; } = false;
public decimal? WalletPaidAmount { get; set; }
#endregion
public PaymentReceipt()
{
TransactionId = Guid.NewGuid();
InitTimestamp = DateTime.UtcNow;
TransactionDate = InitTimestamp;
PaymentTransactionStatus = PaymentType == PaymentType.PaymentGateway || PaymentType == PaymentType.UPI
? PaymentTransactionStatus.Initiated
: PaymentTransactionStatus.Success;
}
}
public class PaymentReceiptDetails
{
[JsonIgnore]
public Guid TransactionId { get; set; }
public Guid? OrderId { get; set; }
public string? OrderNumber { get; set; }
public Guid? InvoiceId { get; set; }
public string? InvoiceNumber { get; set; }
public decimal Amount { get; set; }
public decimal? PaidAmount { get; set; }
public decimal? DueAmount { get; set; }
public Guid ConsumerId { get; set; }
public string? ConsumerName { get; set; }
public string? ConsumerCode { get; set; }
public InvoicePaymentStatus CurrentPaymentStatus { get; set; }
}
public enum PaymentType
{
Any,
Unknown,
[Description("Cheque")]
Cheque,
[Description("Online Transfer")]
OnlineTransfer,
[Description("Payment Gateway")]
PaymentGateway,
UPI,
[Description("Cash")]
Cash,
[Description("Credit Note")]
CreditNote,
Expense,
[Description("Credit Note for Sales Return")]
CrNoteForSalesReturn,
[Description("Due Note")]
DueNote,
[Description("Wallet")]
Wallet
} -
API Interfaces:
Endpoint Method Parameters Response Response Status Codes get/wallet/balanceGETcustomerId(required, uuid)decimal(Currentbalance)200,204,500/process/payment/manualPostInitiatePaymentReceipt(required, object)String200,400,500,404,409 -
Third-Party Integrations:
-
Workflow:
Flow Chart -
Development Tasks & Estimates
| No | Task Name | Estimate (Hours) | Dependencies | Notes |
|---|---|---|---|---|
| 1 | Backend: Update system to support tagging multiple invoices or orders per payment | 8 hours | Change Request: Our system can only single payment accept | |
| 2 | Backend: Implement logic to generate a single due note when multiple invoices or orders are tagged. | 4 hours | 1 | |
| 3 | Backend: Implement logic to allow selection of only one credit note when multiple invoices or orders are tagged. | 4 hours | 1 | |
| 4 | Backend: Create two wallet tables mapped with payment information. | 1 hours | 1 | |
| 5 | Backend: Enable adjustment of invoices/orders with wallet balance across all payment modes, excluding due notes. | 8 hours | ||
| 6 | Backend: Develop API to retrieve wallet balance by consumer. | 2 hours | ||
| 7 | Backend: If a user selects any payment mode (cheque, online transfer, UPI, cash) and there are invoices or orders present, the user must choose at least one. If no invoices or orders are available, the user can submit the payment, and the total amount will be added to the wallet. | 5 hours | 1 | |
| 8 | Backend: If user choose payment mode like (cheque,online transfer, upi, cash) and adjusted invoice or order pending amount is less than payment amount then remaining one goes to wallet. | 3 hours | ||
| 9 | Backend: Validation: The due note option is displayed only when the combined wallet balance and credit note total equals zero. | 1 hours | ||
| 10 | Backend: Validation: A user can choose wallet if wallet balance is grater than 0. Payment amount is greater than wallet balance then he cannot choose wallet option. | 1 hours | ||
| 11 | Backend: Conduct testing for the entire feature set to ensure all functionalities work as intended | 6 hours | 1-10 | |
| 12 | Frontend: wallet, due-note, credit-note balance visible when dealer choosen on add payment screen redisgn. | 3hours | ||
| 13 | Frontend: move the payment amount to top and after entering any amount greater than 0 will enable payment mode option | 0.5hours | ||
| 14 | Frontend: show due note option only when credit note balance and wallet balance combined will be 0 | 1.5hours | ||
| 15 | Frontend: wallet section added and wallet api for balance call | 1.5hours | ||
| 16 | Frontend: add a new payment mode wallet in dropdown and enum structure | 0.8hours | ||
| 17 | Frontend: change api structure for payment submit and credit note adjustment | 0.8hours | ||
| 18 | Frontend: if a user selects any payment mode (cheque, online transfer, UPI, cash, Credit Note), display options to choose multiple invoices or orders. | 3hours | ||
| 19 | Frontend: if a user selects any payment mode (cheque, online transfer, UPI, cash) and there are invoices or orders present, the user must choose at least one. If no invoices or orders are available, the user can submit the payment, and the total amount will be added to the wallet. | 1hours | ||
| 20 | Frontend: give a option to choose an option to use wallet balance | 1hours | ||
| 21 | Frontend: If a user select Credit Note payment mode and there are no invoices or orders present, the user cannot click submit button. | 1hours | ||
| 22 | Frontend: A user can choose wallet if wallet balance is greater than 0. Payment amount is greater than wallet balance then he cannot show wallet option. | 3hours | ||
| 23 | testing all scenarios. | 5hours | ||
| Total | 65.1 hours | 1-23 |
Testing & Quality Assurance
-
Unit Tests:
- Payment Tagging Tests:
Test multiple invoice or order tagging per payment to ensure correct associations. Validate system behavior when only one invoice/order is tagged.
- Due Note and Credit Note Tests:
Verify the creation of a single due note when multiple items are tagged. Ensure only one credit note can be selected when multiple items are tagged.
- Wallet Table Mapping Tests:
Validate correct mapping of payment data to the newly created wallet tables.
- Wallet Balance Adjustment Tests:
Test adjustment of invoices/orders using wallet balance across different payment modes, ensuring due note exceptions are handled correctly.
- Wallet Balance API Tests:
Verify correct wallet balance retrieval by consumer via the API.
- Payment Mode Validation Tests:
Ensure that users must select at least one invoice/order for specific payment modes or have the payment amount added to the wallet if no invoices/orders exist.
- Excess Payment Handling Tests:
Validate the transfer of excess payment amounts to the wallet for cheque, online transfer, UPI, or cash modes.
- Due Note Option Validation Tests:
Check that the due note option is selectable only when the combined wallet and credit note balance is zero.
- Wallet Option Validation Tests:
Confirm that the wallet option appears only when the balance is greater than zero and is hidden when the payment amount exceeds the wallet balance.
- Comprehensive Feature Testing:
Combine individual unit tests into comprehensive test cases covering end-to-end scenarios for all payment modes and wallet adjustments.
-
Integration Tests:
- Payment Amount and Payment Modes
- Balance Display for Dealer
- Payment Amount Validation
- Multiple Invoice or Order Selection
- Handling Payment and Wallet Adjustments
- Due Note Option Display
- Wallet and Payment Methods Interaction
- Credit Note Mode and No Invoices/Orders
-
Acceptance Criteria:
-
Testing Tools:
Deployment Considerations
- Configuration Changes:
CREATE TABLE tblWallet (
walletid uuid NOT NULL,
consumerid uuid NOT NULL,
balance numeric(10,2) NOT NULL DEFAULT 0,
lastupdated timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT tblwallet_pkey PRIMARY KEY (walletid),
CONSTRAINT tblwallet_consumerid_key UNIQUE (consumerid)
);
CREATE TABLE public.tblwalletdetails
(
transactionid uuid NOT NULL primary Key,
walletid uuid NOT NULL,
consumerId uuid NOT NULL,
walletbalance decimal(10,2) NOT NULL default 0,
amount decimal(10,2) NOT NULL default 0,
entrytype VARCHAR(10) NOT NULL CHECK (entrytype IN ('Debit', 'Credit')),
logdts timestamp with time zone NOT NULL default current_timestamp,
CONSTRAINT tblwalletdetails_fkey FOREIGN KEY (walletid)
REFERENCES public.tblwallet (walletid) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
);
- Rollout Plan:
Risks & Mitigations
Review & Approval
-
Reviewer:
Abhishak Kumar Roy -
Approval Date:
2024-09-16
Notes