Skip to main content
#P1637

GET /v2/redis-accounting/balance

Get Redis Balance

این اندپوینت مانده حساب را بر اساس نوع و کد حساب از Redis بازیابی می‌کند. مانده‌ها در کلیدهای balance:{type}:{code} ذخیره می‌شوند و شامل سه مقدار debit، credit و remaining هستند.

Request Overview

URL: /v2/redis-accounting/balance
Method: GET
Middleware: authWithJwt, shamsiDate

Query Parameters

Field Type Required Description
type string yes یکی از مقادیر: group، general، account، subsidiary
code integer yes کد حساب موردنظر

Request Example

GET /v2/redis-accounting/balance?type=group&code=10
  

Response (Success)

Field Type Description
success boolean True در صورت موفقیت
data.debit float مقدار بدهکار
data.credit float مقدار بستانکار
data.remaining float debit - credit
{
  "success": true,
  "data": {
    "debit": 450000,
    "credit": 150000,
    "remaining": 300000
  }
}
  

No Balance Found

در صورتی که کلید balance:{type}:{code} وجود نداشته باشد، خروجی بدون ارور و به شکل زیر است:

{
  "success": true,
  "data": {
    "debit": 0,
    "credit": 0,
    "remaining": 0
  }
}
  

Response (Validation Error)

{
  "success": false,
  "message": "خطا در اعتبارسنجی",
  "errors": {
    "type": [
      "The type field is required."
    ]
  }
}
  

Response (Server Error)

{
  "success": false,
  "message": "خطا در دریافت مانده: Redis connection error..."
}
  

Internal Redis Architecture

Key Pattern Type Description
balance:{type}:{code} Hash ساختار مانده حساب
  • debit
  • credit
  • remaining = debit - credit

Process Flow

Validate Inputs (type, code)
Read from Redis (HGETALL)
Convert Fields to float
Compute remaining = debit - credit
Return JSON Payload