The Financial & Accounting Journal Module (/v1/financial) governs General Ledger (GL) posting, journal entries lifecycle management, debit/credit balance reconciliation, and asynchronous synchronization with SAP Business One (OJDT / JDT1). It provides a resilient, two-stage architectural model allowing financial operations to draft, audit, bulk-import, and asynchronously queue complex multi-line accounting transactions.
Financial operations adhere to strict double-entry bookkeeping rules. The backend provides two interaction flows: direct SAP B1 inspection/cancellation and a staged draft-to-queue pipeline:
/journal-entry-drafts) or in bulk (/journal-entry-import/bulk) in local staging tables.sum(debit) == sum(credit)), currency matching, branch ID (BPLId), and cost-center allocations (profit_code to profit_code5).POST /journal-entry-import/confirm/{id} transforms the draft into an asynchronous LegacyJournalImportJob, dispatches it through EnqueueExternalAction, marks the draft status as ENQUEUED, and records the tracking queue_id.OJDT/JDT1, creating the permanent fiscal voucher./v1/financial
routes/v1/backend/financial/financial.php included in routes/v1/backend/backend.php.App\Http\Controllers\V1\Backend\Financial\Journal\JournalControllerApp\Http\Controllers\SB1\Financial\JournalEntryDraftControllerApp\Http\Controllers\SB1\Financial\JournalEntryImportControllerAuthorization: Bearer <access_token>
x-app-stage: <stage>
x-app-uid: <application_uuid>
Company-Id: <company_id>
Content-Type: application/json
Accept: application/json
All endpoints enforce company-validator middleware. The target company may be provided via the Company-Id HTTP header, query parameter ?companyId={id}, or JSON payload attribute company_id.
ActionResult)All endpoints conform to App\Values\Core\ActionResult:
{
"success": true,
"message": "Operación exitosa.",
"data": { ... }
}
/v1/financial/journals)App\Http\Controllers\V1\Backend\Financial\Journal\JournalControllerroutes/v1/backend/financial/journal.phpcompany-validator| Method | Endpoint | Description |
|---|---|---|
GET |
/v1/financial/journals |
Health and connectivity check |
POST |
/v1/financial/journals/import |
Direct multi-entry CSV file parser, balance validator, and SAP dispatcher |
GET |
/v1/financial/journals/{id} |
Detailed SAP B1 journal entry viewer with line accounts and 2-digit class groupings |
GET |
/v1/financial/journals/{id}/cancel |
Queue reversal cancellation for a journal entry (TransType = 30) |
POST |
/v1/financial/journals |
Direct journal entry creation |
PUT |
/v1/financial/journals/{id} |
Direct journal entry update |
DELETE |
/v1/financial/journals/{id} |
Direct journal entry deletion |
/{id})Loads the authoritative accounting entry directly from SAP Business One tables (OJDT header, JDT1 lines, OACT chart of accounts, and OCRD partner card names), computing summary aggregations grouped by the first two digits of the account code (element/class classification).
GET /v1/financial/journals/45892?companyId=1
200 OK{
"success": true,
"message": "El diario se ha cargado correctamente",
"data": {
"transId": 45892,
"transType": 30,
"createdBy": "SAP_ADMIN",
"baseRef": "45892",
"transCode": "AJUST",
"refDate": "2026-10-10 00:00:00",
"taxDate": "2026-10-10 00:00:00",
"dueDate": "2026-10-10 00:00:00",
"memo": "Ajuste de inventario por desmedro",
"locTotal": 12500.00,
"series": 14,
"seriesName": "DI-2026",
"userCode": "MGONZALO",
"lines": [
{
"periodo": "202610",
"TransType": 30,
"TransId": 45892,
"line": 0,
"account": "6911101",
"accountName": "COSTO DE VENTAS - MERCADERIAS",
"DebCred": "D",
"debit": 12500.00,
"credit": 0.00,
"ShortName": "6911101",
"profitCode": "CC-LIMA",
"ref1": "AJUSTE-01"
},
{
"periodo": "202610",
"TransType": 30,
"TransId": 45892,
"line": 1,
"account": "2011101",
"accountName": "MERCADERIAS ALMACEN CENTRAL",
"DebCred": "C",
"debit": 0.00,
"credit": 12500.00,
"ShortName": "2011101",
"profitCode": "CC-LIMA",
"ref1": "AJUSTE-01"
}
],
"grouped": [
{
"Code": "69",
"Account": "6911101",
"Debit": 12500.00,
"Credit": 0.00,
"Balance": 12500.00,
"AcctName": "COSTO DE VENTAS - MERCADERIAS"
},
{
"Code": "20",
"Account": "2011101",
"Debit": 0.00,
"Credit": 12500.00,
"Balance": -12500.00,
"AcctName": "MERCADERIAS ALMACEN CENTRAL"
}
]
}
}
/import)Uploads a multi-entry CSV file. The engine groups lines by TransId, verifies that total debits equal total credits (Debit == Credit), posts compliant vouchers directly into SAP, and returns an itemized rejection list for unbalanced transactions.
POST /v1/financial/journals/import
Content-Type: multipart/form-data
file (file, required): CSV file containing journal entries.TransId, Account, Debit, Credit, SYSDeb, FCDebit, Balance, Memo, RefDate, DueDate, TaxDate, ProfitCode
200 OK{
"message": "File Changed",
"name": "asientos_octubre_2026.csv",
"extension": "csv",
"entries": 50,
"posted": 48,
"rejected": 2,
"rejection": [
{
"TransId": "1004",
"Account": "1011101",
"Debit": 500.00,
"Credit": 0.00,
"Error": "Debito y Credito no coinciden o no hay Debito"
}
]
}
/{id}/cancel)Queues an automated reversal entry in SAP Business One. Verifies that the document TransType == 30 (reversal candidate).
GET /v1/financial/journals/{id}/cancel?companyId=1
200 OK{
"message": "Queue to cancel"
}
/v1/financial/journal-entry-drafts)App\Http\Controllers\SB1\Financial\JournalEntryDraftControllerroutes/v1/backend/financial/journal-entry-draft.phpApp\Models\Accounting\JournalEntries\JournalEntryDraftApp\Models\Accounting\JournalEntries\JournalEntryDraftLine| Method | Endpoint | Description |
|---|---|---|
GET |
/v1/financial/journal-entry-drafts |
Paginated listing of drafts with eager-loaded lines |
GET |
/v1/financial/journal-entry-drafts/{id} |
Retrieve specific draft details and lines |
POST |
/v1/financial/journal-entry-drafts |
Create a new journal entry draft with lines |
PUT |
/v1/financial/journal-entry-drafts/{id} |
Update existing draft header and line details |
DELETE |
/v1/financial/journal-entry-drafts/{id} |
Permanently delete draft and cascade delete lines |
POST /v1/financial/journal-entry-drafts
Company-Id: 1
Content-Type: application/json
{
"ref_date": "2026-10-13",
"due_date": "2026-10-13",
"tax_date": "2026-10-13",
"memo": "Reclasificación mensual de gastos de combustible",
"ref1": "REF-COM-01",
"ref2": "OCTUBRE-2026",
"ref3": "RUC-20556677889",
"bpl_id": 1,
"lines": [
{
"account_code": "6591101",
"short_name": "6591101",
"debit": 3500.00,
"credit": 0.00,
"currency": "PEN",
"profit_code": "CC-DIST-01",
"profit_code2": "FLOTA-NORTE",
"line_memo": "Gasto combustible vehículos distribución norte"
},
{
"account_code": "1041101",
"short_name": "1041101",
"debit": 0.00,
"credit": 3500.00,
"currency": "PEN",
"line_memo": "Salida Banco BCP Operaciones"
}
]
}
200 OK{
"success": true,
"message": "Asiento contable borrador creado con éxito",
"data": {
"id": 182,
"company_id": 1,
"ref_date": "2026-10-13T00:00:00.000000Z",
"due_date": "2026-10-13T00:00:00.000000Z",
"tax_date": "2026-10-13T00:00:00.000000Z",
"memo": "Reclasificación mensual de gastos de combustible",
"ref1": "REF-COM-01",
"bpl_id": 1,
"status": "CREATED",
"queue_id": null,
"lines": [
{
"id": 490,
"draft_id": 182,
"account_code": "6591101",
"debit": 3500.00,
"credit": 0.00,
"profit_code": "CC-DIST-01",
"line_memo": "Gasto combustible vehículos distribución norte"
},
{
"id": 491,
"draft_id": 182,
"account_code": "1041101",
"debit": 0.00,
"credit": 3500.00,
"line_memo": "Salida Banco BCP Operaciones"
}
]
}
}
Drafts transition across the following states:
| Status Code | Meaning |
|---|---|
CREATED |
Freshly created draft; editable and pending confirmation. |
ENQUEUED |
Verified and dispatched to RabbitMQ / Redis background worker queue. |
ENQUEUED_ERROR |
Failed during enqueueing or validation pre-flight. |
PROCESSED |
Successfully written to SAP Business One OJDT as an official entry. |
/v1/financial/journal-entry-import)App\Http\Controllers\SB1\Financial\JournalEntryImportControllerroutes/v1/backend/financial/journal-entry-import.php/bulk)Ingests multiple complete journal entry draft structures in a single payload.
POST /v1/financial/journal-entry-import/bulk
Company-Id: 1
Content-Type: application/json
{
"drafts": [
{
"ref_date": "2026-10-13",
"memo": "Ajuste Masivo 1",
"bpl_id": 1,
"lines": [
{ "account_code": "6591101", "debit": 100.00, "credit": 0.00 },
{ "account_code": "1041101", "debit": 0.00, "credit": 100.00 }
]
},
{
"ref_date": "2026-10-13",
"memo": "Ajuste Masivo 2",
"bpl_id": 1,
"lines": [
{ "account_code": "6591101", "debit": 250.00, "credit": 0.00 },
{ "account_code": "1041101", "debit": 0.00, "credit": 250.00 }
]
}
]
}
200 OK{
"success": true,
"message": "Borradores importados correctamente",
"data": {
"total_imported": 2,
"draft_ids": [183, 184]
}
}
/confirm/{id})Locks the specified draft, converts header and lines into SAP B1 DI-API OJDT/JDT1 payload structure, and enqueues the LegacyJournalImportJob to background workers.
POST /v1/financial/journal-entry-import/confirm/182
Company-Id: 1
200 OK{
"success": true,
"message": "Asiento contable borrador encolado correctamente",
"data": {
"id": 182,
"company_id": 1,
"status": "ENQUEUED",
"queue_id": "queue_sb1_journal_670c5b3829e1a",
"memo": "Reclasificación mensual de gastos de combustible",
"updated_at": "2026-10-13T17:10:00.000000Z"
}
}
400 Bad Request)If the draft was already processed:
{
"success": false,
"message": "El asiento ya ha sido procesado",
"data": null
}