Skip to main content

POS Closing API

Created: December 25, 2025The POS Session Closing endpoints provide functionality to retrieve closing status information and close POS sessions for end-of-day reconciliation.
The POS Session Closing endpoints provide functionality to retrieve closing status information and close POS sessions. These endpoints are used for end-of-day reconciliation, allowing store managers to review session activity and officially close a POS session with the actual funded money amount.

Endpoint Details

Base URL: https://joptic.jethings.com

Required Headers


Endpoints

1. Get POS Closing Status

Retrieves comprehensive closing status information for the current open POS session, including invoices, money movements, and calculated totals.

2. Close POS Session

Closes the current open POS session by creating a closing record with the funded money amount and calculating the difference between expected and actual money.

Endpoint 1: Get POS Closing Status

Request

Method: GET
Path: /pos-session/closing-status/:profileId

Path Parameters

Headers

Response

Type: PosClosingStatusResponseDto

Field Descriptions

Session Information

Invoices

Invoices are ordered by creation date (newest first). Each invoice includes its TTC, actual amount paid, creation date/time, and item count.

Money Movements

Movements are ordered by creation date (newest first). Deposits add to expected money, withdrawals subtract from it.

Aggregates

Expected Money Calculation:
  • totalActualPayments: Sum of all actualAmountPaid from invoices
  • netMoneyMovements: Sum of deposits minus sum of withdrawals

How It Works

  1. Retrieve Current Session
    • Finds the current open session for the given profile and store
    • Throws NotFoundException if no open session exists
  2. Fetch Store Information
    • Retrieves store name for display purposes
  3. Calculate Invoice Data
    • Retrieves all POS invoices linked to the session
    • For each invoice, calculates:
      • actualAmountPaid: Sum of all payment allocations for that invoice
      • numberOfItems: Count of items in the invoice
    • Formats date and time for display
  4. Fetch Money Movements
    • Retrieves all money movements (deposits/withdrawals) for the session
    • Formats date and time for display
  5. Calculate Aggregates
    • invoiceCount: Total number of invoices
    • soldCustomersNumber: Distinct customer count (excluding null)
    • ttc: Sum of all invoice TTC values
    • outstandingAmount: Sum of (TTC - actualAmountPaid) for all invoices where debt > 0
    • expectedMoney: Sum of all actual payments + net money movements

Example Request

Example Response

Calculation Breakdown:
  • Total actual payments: 125.50 + 50.00 = 175.50
  • Net money movements: 100.00 (deposit) - 25.00 (withdrawal) = 75.00
  • Expected money: 175.50 + 75.00 = 250.50

Error Responses

404 Not Found

  • No open session: "No open session found for this profile"
    • Occurs when there is no currently open session for the given profile and store
  • Store not found: "Store not found"
    • Occurs when the store ID doesn’t exist

Endpoint 2: Close POS Session

Request

Method: POST
Path: /pos-session/close-session/:profileId

Path Parameters

Headers

Request Body

Type: ClosePosSessionDto
Validation:
  • fundedMoney must be a number
  • fundedMoney must be positive (greater than 0)

Response

Success Response (200 OK)

Field Descriptions

Difference Interpretation:
  • Positive diff: More money expected than funded (shortage)
  • Negative diff: Less money expected than funded (surplus)
  • Zero diff: Exact match

How It Works

  1. Validate Session
    • Retrieves the current open session for the given profile and store
    • Throws NotFoundException if no open session exists
    • Throws BadRequestException if session is already closed
  2. Calculate Session Totals
    • Retrieves all invoices linked to the session
    • Calculates totalActualPayments: Sum of all payment allocations
    • Retrieves all money movements for the session
    • Calculates netMoneyMovements: Deposits minus withdrawals
    • Calculates expectedMoney: totalActualPayments + netMoneyMovements
  3. Calculate Difference
    • diff = expectedMoney - fundedMoney
  4. Create Closing Record
    • Creates a posClosing record with:
      • Same ID as the opening session (for linking)
      • Invoice count
      • Expected money
      • Funded money
      • Difference (as string)
  5. Link Opening to Closing
    • Updates the posOpening record to link it to the closing record
    • Sets posClosingId on the opening record
  6. Return Result
    • Returns success response with closing details
Once a session is closed, it cannot be closed again. The opening record is permanently linked to the closing record.

Example Request

Example Response

Interpretation:
  • Expected money: 250.50
  • Funded money: 250.00
  • Difference: 0.50 (shortage of 0.50)

Error Responses

400 Bad Request

  • Session already closed: "Session is already closed"
    • Occurs when attempting to close a session that has already been closed

404 Not Found

  • No open session: "No open session found for this profile"
    • Occurs when there is no currently open session for the given profile and store

422 Unprocessable Entity

  • Invalid fundedMoney: Validation errors if fundedMoney is not a number or not positive
    • "fundedMoney must be a number"
    • "fundedMoney must be a positive number"

Workflow Example

Typical End-of-Day Process

  1. Review Closing Status
    • Manager reviews invoices, money movements, and expected money
    • Verifies all transactions are accounted for
  2. Count Physical Cash
    • Manager counts the actual cash in the register
    • Determines the fundedMoney amount
  3. Close Session
    • System calculates difference between expected and funded
    • Creates closing record
    • Session is now closed and cannot be reopened
  4. Review Difference
    • If diff is positive: Shortage (investigate missing money)
    • If diff is negative: Surplus (investigate extra money)
    • If diff is zero: Perfect match

Important Notes

  1. Session Must Be Open: Both endpoints require an active open session. Use GET /pos-session/session-status/:profileId to check if a session is open.
  2. One Closing Per Session: Once a session is closed, it cannot be closed again. The opening record is permanently linked to the closing record.
  3. Expected Money Calculation:
    This represents the total cash that should be in the register.
  4. Difference Interpretation:
    • Positive diff: Shortage - less money than expected
    • Negative diff: Surplus - more money than expected
    • Zero diff: Perfect match
  5. Invoice Linking: Only invoices with isPosInvoice: true and linked to the session via posOpeningId are included in calculations.
  6. Money Movements: All deposits and withdrawals during the session are included in the calculation. Deposits add to expected money, withdrawals subtract from it.
  7. Outstanding Amount: The outstandingAmount in closing status represents total customer debt (unpaid invoice amounts). This is separate from the expected money calculation.
  8. Atomic Operation: Closing a session is an atomic operation. If any step fails, the entire operation is rolled back.

  • GET /pos-session/session-status/:profileId - Check if a session is open
  • GET /pos-session/current-session/:profileId - Get current open session details
  • POST /pos-session/create-session - Create a new POS session
  • GET /pos-session/profiles - Get all POS profiles with their session status
  • POST /pos-money-movement - Create money movements (deposits/withdrawals)

Database Schema

posOpening

  • Represents an open POS session
  • Linked to posProfile and store
  • Has posClosingId field (null when open, set when closed)

posClosing

  • Represents a closed POS session
  • Has same ID as the corresponding posOpening record
  • Stores invoice count, expected money, funded money, and difference

salesInvoice

  • Linked to posOpening via posOpeningId
  • Only invoices with isPosInvoice: true are included

paymentAllocation

  • Links payments to invoices
  • Used to calculate actualAmountPaid for each invoice

posMoneyMovement

  • Tracks deposits and withdrawals during a session
  • Linked to posOpening via posOpeningId
  • Type: “deposit” or “withdrawal”