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.
Endpoint Details
Base URL:https://joptic.jethings.com
Required Headers
Endpoints
1. Get POS Closing Status
2. Close POS Session
Endpoint 1: Get POS Closing Status
Request
Method:GETPath:
/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 allactualAmountPaidfrom invoicesnetMoneyMovements: Sum of deposits minus sum of withdrawals
How It Works
-
Retrieve Current Session
- Finds the current open session for the given profile and store
- Throws
NotFoundExceptionif no open session exists
-
Fetch Store Information
- Retrieves store name for display purposes
-
Calculate Invoice Data
- Retrieves all POS invoices linked to the session
- For each invoice, calculates:
actualAmountPaid: Sum of all payment allocations for that invoicenumberOfItems: Count of items in the invoice
- Formats date and time for display
-
Fetch Money Movements
- Retrieves all money movements (deposits/withdrawals) for the session
- Formats date and time for display
-
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
- 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:POSTPath:
/pos-session/close-session/:profileId
Path Parameters
Headers
Request Body
Type:ClosePosSessionDto
fundedMoneymust be a numberfundedMoneymust 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
-
Validate Session
- Retrieves the current open session for the given profile and store
- Throws
NotFoundExceptionif no open session exists - Throws
BadRequestExceptionif session is already closed
-
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
-
Calculate Difference
diff = expectedMoney - fundedMoney
-
Create Closing Record
- Creates a
posClosingrecord with:- Same ID as the opening session (for linking)
- Invoice count
- Expected money
- Funded money
- Difference (as string)
- Creates a
-
Link Opening to Closing
- Updates the
posOpeningrecord to link it to the closing record - Sets
posClosingIdon the opening record
- Updates the
-
Return Result
- Returns success response with closing details
Example Request
Example Response
- 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
fundedMoneyis not a number or not positive"fundedMoney must be a number""fundedMoney must be a positive number"
Workflow Example
Typical End-of-Day Process
-
Review Closing Status
- Manager reviews invoices, money movements, and expected money
- Verifies all transactions are accounted for
-
Count Physical Cash
- Manager counts the actual cash in the register
- Determines the
fundedMoneyamount
-
Close Session
- System calculates difference between expected and funded
- Creates closing record
- Session is now closed and cannot be reopened
-
Review Difference
- If
diffis positive: Shortage (investigate missing money) - If
diffis negative: Surplus (investigate extra money) - If
diffis zero: Perfect match
- If
Important Notes
-
Session Must Be Open: Both endpoints require an active open session. Use
GET /pos-session/session-status/:profileIdto check if a session is open. - One Closing Per Session: Once a session is closed, it cannot be closed again. The opening record is permanently linked to the closing record.
-
Expected Money Calculation:
This represents the total cash that should be in the register.
-
Difference Interpretation:
- Positive diff: Shortage - less money than expected
- Negative diff: Surplus - more money than expected
- Zero diff: Perfect match
-
Invoice Linking: Only invoices with
isPosInvoice: trueand linked to the session viaposOpeningIdare included in calculations. - Money Movements: All deposits and withdrawals during the session are included in the calculation. Deposits add to expected money, withdrawals subtract from it.
-
Outstanding Amount: The
outstandingAmountin closing status represents total customer debt (unpaid invoice amounts). This is separate from the expected money calculation. - Atomic Operation: Closing a session is an atomic operation. If any step fails, the entire operation is rolled back.
Related Endpoints
GET /pos-session/session-status/:profileId- Check if a session is openGET /pos-session/current-session/:profileId- Get current open session detailsPOST /pos-session/create-session- Create a new POS sessionGET /pos-session/profiles- Get all POS profiles with their session statusPOST /pos-money-movement- Create money movements (deposits/withdrawals)
Database Schema
posOpening
- Represents an open POS session
- Linked to
posProfileandstore - Has
posClosingIdfield (null when open, set when closed)
posClosing
- Represents a closed POS session
- Has same ID as the corresponding
posOpeningrecord - Stores invoice count, expected money, funded money, and difference
salesInvoice
- Linked to
posOpeningviaposOpeningId - Only invoices with
isPosInvoice: trueare included
paymentAllocation
- Links payments to invoices
- Used to calculate
actualAmountPaidfor each invoice
posMoneyMovement
- Tracks deposits and withdrawals during a session
- Linked to
posOpeningviaposOpeningId - Type: “deposit” or “withdrawal”