When a user saves the global business partner credit line via the REST API, GOAL updates PostgreSQL first, then writes OCRD.CreditLine on the company SAP database (direct SQL, same pattern as payment-term pushes to OCTG).
GOAL (business_partners) |
SAP B1 (OCRD) |
Rule |
|---|---|---|
has_credit_line = Y + credit_limit |
CreditLine |
CreditLine = credit_limit (6 decimal places) |
has_credit_line = N or limit 0 |
CreditLine |
CreditLine = 0 |
balance |
— | Not written (SAP remains source of truth for AR balance) |
business_partners.code → OCRD.CardCode.code fail the request (GOAL credit change is rolled back).code skip SAP (GOAL save succeeds).has_credit_line / credit_limit.gproc.syncronizations is updated for profile SB1_OCRD_CREDIT to align incremental inbound runs.Balance, the update is still applied; the API success message may include a warning.PUT /v1/base/business-partners/{id}/credit-line?companyId={companyId}
Authorization: Bearer <token>
x-app-stage: <stage>
x-app-uid: <uid>
Content-Type: application/json
{
"has_credit_line": "Y",
"credit_limit": 50000
}
| HTTP | When |
|---|---|
200 |
GOAL and SAP updated (or SAP skipped for non-customer without CardCode) |
400 / 422 |
Validation errors (e.g. limit below address reservations) |
4xx / 5xx |
SAP or partner resolution failure after GOAL rollback |
Domain: Domain\Base\BusinessPartner\Credit\UpdateBusinessPartnerCreditLineAction → PushBusinessPartnerCreditToSapAction → SB1Adapter::updateOcrdCreditLine.
Address and sales-team credit reservations are GOAL-only (not pushed to OCRD).
Synchronizes credit limit and outstanding balance from SAP Business One OCRD into GOAL business_partners for credit checks (UI, presale, BEES consumed_line).
SAP B1 (OCRD) |
GOAL (business_partners) |
Rule |
|---|---|---|
CreditLine |
credit_limit, has_credit_line |
has_credit_line = Y when CreditLine > 0, else N |
Balance |
balance |
Outstanding AR / consumed credit (same meaning as BEES consumed_line) |
Partner resolution matches master sync: CardCode → code, then DocEntry → remote_id. Conflicting matches fail the row.
php artisan goal:business-partners:sync-credit-from-sap \
--company={companyId} \
[--code=CL00001234] \
[--force] \
[--card-type=C] \
[--limit=10000] \
[--offset=0] \
[--without-confirmation]
| Option | Description |
|---|---|
--company |
Required. GOAL company id. |
--code |
Single CardCode; incremental rules apply unless combined with understanding below. |
--force |
Full OCRD scan for --card-type (default C). Skips incremental selection. |
--card-type |
OCRD CardType filter (default C customers). |
--limit / --offset |
Cap or paginate force runs (limit=0 = no cap on force). |
--without-confirmation |
Do not write gproc.syncronizations (test DB). |
Default: incremental (no --force).
| Counter | Meaning |
|---|---|
total |
Card codes selected for SAP read |
updated |
GOAL row changed |
skipped_unchanged |
SAP values already match GOAL |
skipped_missing_goal |
No matching business_partners row (master sync first) |
skipped_no_credit_limit |
SAP CreditLine is zero or null; GOAL is not updated |
errors |
Row-level failures |
warnings |
e.g. SAP limit below address reservations (SAP value still applied) |
OCRD rows with ISNULL(CreditLine, 0) > 0.CreditLine <= 0 are not written to GOAL; they are only recorded in gproc.syncronizations when tracking is enabled (avoids re-queueing).CardCode from OINV, ORIN, ORDR after last profile synced_at, only when the partner has OCRD.CreditLine > 0.--force uses listOcrdCardCodes with onlyWithCreditLine = true (partners of --card-type that have SAP credit limit).
Only partners with SAP CreditLine > 0 (epsilon 1e-6) are applied to GOAL. Zero-limit SAP rows do not clear has_credit_line or credit_limit in GOAL.
For partners with a positive SAP limit, updates apply only when credit_limit, has_credit_line, or balance differ (epsilon 1e-6). Does not use the manual credit API validators; SAP is source of truth for eligible rows.
After each processed row (success, unchanged, or skipped for zero SAP limit), gproc.syncronizations is updated when tracking is enabled.
| Piece | Class |
|---|---|
| Inbound orchestrator | Domain\Base\BusinessPartner\Credit\SyncBusinessPartnerCreditFromSapAction |
| Inbound row apply | Domain\Base\BusinessPartner\Credit\ApplySapBusinessPartnerCreditSnapshotAction |
| Outbound push (REST) | Domain\Base\BusinessPartner\Credit\PushBusinessPartnerCreditToSapAction |
| SAP write | SB1Adapter::updateOcrdCreditLine (UseOcrdCreditSync) |
| Sync profile | App\Models\SB1\Master\SB1OcrdCredit (object_code: SB1_OCRD_CREDIT) |
For a full SAP commercial picture (payment condition + credit limit/balance):
php artisan goal:business-partners:sync-commercial-from-sap --company={companyId}
See business-partner-payment-terms-sync.md for OCTG/OCRD/CRD1 mapping and Credit Line Management fields (credit_purchase_allowed, payment term warnings).
goal:business-partners:sync-from-sap so code / remote_id exist.goal:business-partners:sync-payment-terms-from-sap when UI/BEES need aligned payment terms.app/Console/Kernel.php if needed (on-demand only by default).OCRD.CreditLine to 0.CreditLine <= 0 do not clear GOAL has_credit_line / credit_limit (inbound-only rule).