Skip to main content
Version: Fleeto

Payment with multi tagging and Wallet Process

Author(s)

  • Reshmi Karan
  • Sayan Mukherjee

Last Updated Date

2024-09-13


SRS References


Version History

VersionDateChangesAuthor
1.02024-09-12Initial draftReshmi Karan, Sayan Mukherjee
2.02024-09-30Service changesReshmi 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

  1. 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.
  2. Display all relevant balances (wallet, due note/credit limit, credit note) at the top for the selected dealer.
  3. 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.
  4. If a user selects any payment mode (cheque, online transfer, UPI, cash, Credit Note), display options to choose multiple invoices or orders.
  5. 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.
  6. 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.
  7. Display the due note option when the combined wallet balance and credit note total will be 0.
  8. Adjust invoices, and orders with normal payment methods and the wallet.
  9. If a user select Credit Note payment mode and there are no invoices or orders present, the user cannot submit button.
  10. 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.
  11. Use wallet balance option in add payment.
  12. 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:

    EndpointMethodParametersResponseResponse 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 - Flow Chart


Development Tasks & Estimates

NoTask NameEstimate (Hours)DependenciesNotes
1Backend: Update system to support tagging multiple invoices or orders per payment8 hoursChange Request: Our system can only single payment accept
2Backend: Implement logic to generate a single due note when multiple invoices or orders are tagged.4 hours1
3Backend: Implement logic to allow selection of only one credit note when multiple invoices or orders are tagged.4 hours1
4Backend: Create two wallet tables mapped with payment information.1 hours1
5Backend: Enable adjustment of invoices/orders with wallet balance across all payment modes, excluding due notes.8 hours
6Backend: Develop API to retrieve wallet balance by consumer.2 hours
7Backend: 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 hours1
8Backend: 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
9Backend: Validation: The due note option is displayed only when the combined wallet balance and credit note total equals zero.1 hours
10Backend: 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
11Backend: Conduct testing for the entire feature set to ensure all functionalities work as intended6 hours1-10
12Frontend: wallet, due-note, credit-note balance visible when dealer choosen on add payment screen redisgn.3hours
13Frontend: move the payment amount to top and after entering any amount greater than 0 will enable payment mode option0.5hours
14Frontend: show due note option only when credit note balance and wallet balance combined will be 01.5hours
15Frontend: wallet section added and wallet api for balance call1.5hours
16Frontend: add a new payment mode wallet in dropdown and enum structure0.8hours
17Frontend: change api structure for payment submit and credit note adjustment0.8hours
18Frontend: if a user selects any payment mode (cheque, online transfer, UPI, cash, Credit Note), display options to choose multiple invoices or orders.3hours
19Frontend: 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
20Frontend: give a option to choose an option to use wallet balance1hours
21Frontend: If a user select Credit Note payment mode and there are no invoices or orders present, the user cannot click submit button.1hours
22Frontend: 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
23testing all scenarios.5hours
Total65.1 hours1-23

Testing & Quality Assurance

  • Unit Tests:

    1. 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.

    1. 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.

    1. Wallet Table Mapping Tests:

    Validate correct mapping of payment data to the newly created wallet tables.

    1. Wallet Balance Adjustment Tests:

    Test adjustment of invoices/orders using wallet balance across different payment modes, ensuring due note exceptions are handled correctly.

    1. Wallet Balance API Tests:

    Verify correct wallet balance retrieval by consumer via the API.

    1. 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.

    1. Excess Payment Handling Tests:

    Validate the transfer of excess payment amounts to the wallet for cheque, online transfer, UPI, or cash modes.

    1. Due Note Option Validation Tests:

    Check that the due note option is selectable only when the combined wallet and credit note balance is zero.

    1. 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.

    1. 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:

    1. Payment Amount and Payment Modes
    2. Balance Display for Dealer
    3. Payment Amount Validation
    4. Multiple Invoice or Order Selection
    5. Handling Payment and Wallet Adjustments
    6. Due Note Option Display
    7. Wallet and Payment Methods Interaction
    8. 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