Plank help · updated 2026-11-23
Importing incoming ЭСФ into 1C
How an incoming electronic invoice becomes a linked СчетФактураПолученный + ПоступлениеТоваровУслуг pair in 1C: the three-way link that must exist, which section a line belongs in (the nomenclature card decides, per line — never a per-base setting), the receipt-line analytics 1C will not infer and will not complain about, which of the ЭСФ's two numbers is «the number», which ЭСФ a batch may start from, how to pick a historical template, resolving nomenclature and units without inventing catalog records, and the stop conditions.
Agents: fetch the raw markdown of this page at /en/help/1c-incoming-esf-import.md
Importing incoming ЭСФ into 1C
An incoming ЭСФ is not a document. It is a notification that a supplier issued one, and the accounting only exists once 1C holds a received invoice and a goods/services receipt, linked to each other and to the ЭСФ.
A request to create a contract or a card is the agent's work (dry run → «да»), not
a reason to write to the Plank team. The import creates both: --create-contracts
and --create-nomenclature. Do not write a writer of your own for either.
First: the ЭСФ has to already be inside 1C
Everything on this page starts from a row in Document_ЭСФ. Getting it there is a
separate job that neither this page nor any script here performs, and three things are
easy to confuse:
| What it does | Puts ЭСФ into Document_ЭСФ? | |
|---|---|---|
| 1C's own «Обмен с ИС ЭСФ» | The exchange inside 1C, set up by the accountant with their ЭЦП | Yes — this is the prerequisite |
| Connecting ЭСФ | A direct client to esf.gov.kz: lists issued and received invoices, issues new ones | No — it hands invoice data back as files |
This page / 1c-esf-import-kz | Turns an ЭСФ already in 1C into a linked invoice + receipt | Reads them; never creates them |
The trap is the middle row. connecting-esf can see received invoices, so a
workspace that has connected ЭСФ reasonably expects the import to work — and it will
find nothing, because that connection reaches the portal and this one reads 1C.
If the base holds no ЭСФ, the question is whether the 1C-side exchange is configured
and has run. No script substitutes for it. check-access.py reports
Document_ЭСФ as published-but-empty, and the importer distinguishes "this base has
no ЭСФ at all" from "that registration number is not here" — different problems,
different next steps.
Do not try to run that exchange yourself. «Обмен с ИС ЭСФ» signs with the
accountant's ЭЦП through 1C's external component, which runs on their computer —
it cannot run in the cloud browser or over OData, and on 2026-10-17 an attempt to
drive it from there cost twenty minutes and achieved nothing. Ask the person to run
the exchange in their own 1C (or to upload the ЭСФ XML), then continue from the
Document_ЭСФ rows it creates.
Going the other way — issuing your own invoices to the portal — is Connecting ЭСФ. This page is only about ЭСФ that have arrived.
There is a kit for this: 1c-esf-import-kz. Install it (see
the 1C starter kit) rather than writing a fresh script:
python3 scripts/1c/esf/import-esf.py --first 5 # dry run — read the dates it picked
python3 scripts/1c/esf/import-esf.py --registration 35318 --apply
--first N sorts ascending, so it hands you the oldest unprocessed ЭСФ. In a base
that has been running for years those are almost never the ones being asked about — see
"Batches, and which ЭСФ a batch starts from" below. Read the dates in the dry run before
--apply, and when they are not the period you want, name the batch yourself —
--period YYYY-MM, or --only-refs with exactly its ЭСФ — instead of trusting the
ordering. Not a loop of --registration: see "One batch, one run" below.
On a base too large to read whole, use --only-refs. The import reads three
document sets to protect you from importing an ЭСФ twice, and on a big base that
is the whole run: one measured base holds 1 098 567 ЭСФ, 856 431 received
invoices and 680 904 receipts, and reading them takes longer than anyone will
wait. --only-refs refs.txt (one Ref_Key per line, or a JSON array) fetches
exactly the ЭСФ you name and narrows the invoice and receipt reads to their
counterparties — legitimate, because a chain written from an ЭСФ carries that
ЭСФ's own supplier. Deliberately NOT narrowed by organisation: a chain mistakenly
created under another legal entity of the same base is exactly the half-written
chain the duplicate guard exists to find.
An ЭСФ the exchange loaded with no counterparty («Контрагент_Key» empty — common
on a fresh base) is narrowed too: the БИН/ИИН inside its registration number is
looked up, and exactly one counterparty carrying it is the area
(read-area-supplier-from-registration). None, or several, still stops the run
with only-refs-supplier-unknown.
The price is stated in the run's own report. With the area narrowed, "what this base fills on every posted document" has no population to read, so nothing is filled from it; every derivation is scoped to the supplier instead, and a field that neither a rule nor the supplier's own history settles is reported as a question rather than guessed. Expect more readiness warnings than a full read would raise. A held run is recoverable; a wrong settlement account in the books is not.
If a run seems to hang, get the list of requests before changing anything.
Set PLANK_1C_TRACE=1 and run it again: every request is printed with how long
it took and how many bytes came back, and a summary at the end says which object
the time actually went to. This exists because a run that took eighteen minutes
for four documents was diagnosed twice as "too much data" and was not — the base
was serving a thousand whole invoices in under two seconds while the import sat
on one slow query.
The posting proof used to be the longest read. Before trusting a past
invoice as a template, the import checks which posted documents really moved an
accounting register. That used to mean reading every register those documents
can record into, from end to end, however few ЭСФ you were importing. It now
asks the registers about the documents it actually needs the answer for. If your
base cannot be trusted to answer such a question — some publications answer a
register filter with nothing, or with rows you did not ask for — the run detects
that and reads the register the slow, certain way instead, and says so in the
report. "posting_proof": false in mapping.json's esf block skips the check
entirely, and that is a decision rather than a speed-up: without it the run
trusts the «Проведён» flag, which a document 1C refused in silence also
carries.
The rules below are what it enforces, and what you have to honour if you adapt it.
Everything here assumes you have already read
Working with 1C over OData. The rules there —
match by identifier, post only through post-documents.py, re-read after every
write, never hard-code a Ref_Key — apply unchanged and are not repeated.
A corrected ЭСФ is never a second receipt
First check that this space's kit has the protection: it exists only from kit 1.55.0. Most spaces received an older kit, and a kit is updated only by a kit refresh, so this page may describe a check your copy does not run. A copy in a space carries no kit.json and import-esf.py has no --version. The one reliable test is the code itself: the protection is there if scripts/1c/esf/import-esf.py imports _correction (grep -n "from _correction import" scripts/1c/esf/import-esf.py) and scripts/1c/esf/_correction.py exists. scripts/.plank-kits.json records the version the space was CREATED with — it is absent in older spaces and is not rewritten by a refresh, so use it only as a hint, never as the answer.
If the import does not have it, or you cannot tell: do not import a corrected ЭСФ (Вид = Исправленный, СвязанныйЭСФ_Key filled), with --apply or any other way, and do not create its receipt by create-document.py, by hand or by a script. An older import writes it as a second receipt for a delivery already in the books. Import the rest of the batch by --registration and ask the accountant whether the corrected ЭСФ replaces the chain (supersede-esf.py) or is a correction. This is the rule of kit 1.54.2. Everything below describes kit 1.55.0 and newer.
A corrected ЭСФ is a row of Document_ЭСФ whose Вид is Исправленный (an
ordinary one reads Обычный). It names the ЭСФ it corrects in
СвязанныйЭСФ_Key, and also in СвязанныйЭСФРегистрационныйНомер,
СвязанныйЭСФНомер and СвязанныйЭСФДата. It is a new registration number
for a delivery that may already be in the books, usually for another amount, so
no guard keyed on «this ЭСФ» or on the amount sees it. The import recognises it by
those fields, never by money — named in mapping.json as esf.kind_field,
esf.corrected_kind and esf.related_esf_field if this base calls them
otherwise — and creates nothing for it:
| code | when |
|---|---|
esf-correction-of-written | the original's chain is written (1C's link on the original, or this kit's anchor). The report names the original, its invoice and receipt. The correct receipt is a corrected invoice on the same receipt (Поступление); the kit has no operation that writes one, so it stops and says so — make the correction in 1C. The printed supersede-esf.py --registration <corrected> --replace-invoice <invoice> replaces the chain: dry-run it, and only if the accountant decides to replace |
esf-correction-base-missing | the original is not named, not in the base, or marked for deletion |
esf-correction-original-unwritten | the original is in the base with no chain — importing either one leaves the other importable |
esf-correction-kind-unknown | the ЭСФ names another ЭСФ but its kind is not published or empty |
Only the accountant's answer lifts a refusal:
"esf": {"corrections": {"<registration number of the corrected ЭСФ>": "new"}}
imports it as an ordinary ЭСФ; "supersede" keeps the refusal and its command.
Do not create the receipt for a refused ЭСФ any other way. An ordinary ЭСФ sends
no new request for this check.
Every run says once, as esf-kind-recognition (info, no numbers or sums), how it
tells the kind on this base: the kind field and its «corrected» value, whether the
field is published, how many of the run's ЭСФ name another and how many of those it
recognised as corrected. «НЕ опубликовано», or fewer recognised than linked, means
esf.kind_field / esf.corrected_kind need this base's names.
Second receipts written before this check (kit below 1.55.0) are found by a batch
dry run (--period YYYY-MM): esf-correction-second-chain names the corrected
ЭСФ and both invoices; find-runs.py lists a chain's documents by the anchor in
their comment. The kit changes none of them — the accountant decides.
The chain, and why two documents is not enough
Incoming ЭСФ ──▶ СчетФактураПолученный ◀──▶ ПоступлениеТоваровУслуг
Three links, all of them required:
- the ЭСФ's
СчетФактураfield points at the received invoice; - the received invoice points at the receipt, both as its main reference and
as a row in
ДокументыОснования; - the receipt points back at the received invoice.
An ЭСФ is not processed because two new documents exist. Miss the first link and 1C's own interface still shows the ЭСФ as unhandled, however complete the two documents look — so the accountant opens it and finds the chain broken. Write the ЭСФ→invoice link even when the user asked only for a draft.
Choose the target database from the ЭСФ, not from credentials
The organisation named in the ЭСФ decides which 1C base you write to. Resolve it
through the workspace's register of bases. Never take the address that happens to
be in a shared credentials.json — a practice with 17 client companies has 17
bases, and the cost of guessing is a document in someone else's accounting.
One base can also hold several of your own legal entities — a head company and its branches, each with its own БИН. «Организация» on the ЭСФ is filled by 1C's own «Обмен с ИС ЭСФ», not by the supplier, so it can name the head company on an invoice made out to a branch, and nothing about that looks wrong. Every run therefore compares the receiving party the document itself names — «Грузополучатель», then «ГрузополучательИдентификатор», then any БИН of this base's organisations in the header — with the organisation it is about to write into:
- it names another organisation of this base — the run stops
(
esf-wrong-recipient,esf-recipient-ambiguous), and--accept-warningsdoes not clear it. Import that ЭСФ against the mapping of the organisation it names, or settle the document's «Организация»/«Грузополучатель» in 1C. Note «Грузополучатель» is the consignee: if your group really does buy through one organisation and receive through another, that is a decision to record in 1C, not one the run may guess. - the document was issued by you — its supplier is one of this base's own
organisations — nothing is refused (
recipient-self-issued). Whether such a document may be imported as a purchase at all is «Направление»'s question, and the run already refuses an outgoing ЭСФ. - the comparison cannot be made — the run says exactly that under its own code
rather than passing quietly.
recipient-unstated(the ЭСФ names no identifier) is reported and stops nothing: nobody can fill in a field the document does not have.recipient-unidentifiable— your own organisation's card carries no БИН — holds a run on a base with several organisations, because that is a minute's work in 1C and until it is done the check cannot run at all.
The comparison is by БИН only: one VAT certificate covers a whole group, so it cannot tell a head company from its branch; РНН has not been issued since 2019 and an empty one is not a defect; and a name — «Филиал» in a description — decides nothing.
Pick a template from history, then take only structure from it
Before creating anything, read this base's own already posted incoming ЭСФ and their linked documents. Prefer, in order:
- the same supplier, matched by exact
Ref_Key; - the same operation kind — goods or services;
- the largest overlap of confirmed nomenclature;
- on a tie, the most recent correct document.
Never template off a document with a material amount discrepancy, wrong VAT, or
incomplete links — or off a document that reads «Проведён» and moved no register.
1C «posts» a document it refused in silence: the flag is set and nothing reaches the
books. import-esf.py reads which posted documents actually recorded a movement
and ignores the rest as templates and as evidence; the report lists them
(posted-without-movements) — check those in the 1C client.
From the template, take only settings. Supplier contract, warehouse, settlement and advance accounts, author and responsible, currency, line-level accounts and analytics, operation kind, the shape of the tabular sections.
When the goods of ONE ЭСФ went to another warehouse than the template's, record it:
esf.warehouse_by_registration: {"<registration>": "<Ref_Key or warehouse name>"}.
It must match exactly one live warehouse, or the chain is refused
(warehouse-unresolved); a different --warehouse is refused too. «УчитыватьКПН»
on the receipt is esf.account_for_cit (true/false), or the template's when that is
null.
The contract is not from the template either. It belongs to one supplier. When the ЭСФ names its contract, the import tries, in this order, and the dry run says which step answered:
- a choice the accountant recorded for this ЭСФ (
esf.contract_by_registration); - the same number and date;
- the same contract written differently — same number with another date, or the same words («Договор оферты» and «Оферта»); only if exactly one card fits;
- what the accountant's own recent posted documents for this supplier all used;
- the supplier's only contract — used, but the write waits until somebody has
looked (
--accept-warning contract-substituted).
If none of these answers, the ЭСФ is not written and the report lists every candidate contract with its reference, so the choice can be recorded and the import run again. When the ЭСФ names no contract: the one this supplier's posted documents use, otherwise the newest card.
When the contract is not in 1C, create it — on the accountant's word.
--create-contracts (with --create-nomenclature, in the same run) plans the
missing supplier contract in the dry run under «Supplier contracts». The requisites:
owner = the supplier's card by БИН, the ЭСФ's organisation, kind «С поставщиком»,
number and date from the ЭСФ or from the accountant (--contract-number,
--contract-date, with one --registration), tenge. The accountant's command given
before the run is enough, unless at least one of these holds — then show the dry run and
wait for a fresh «да»: (a) the run creates what was not asked for (cards, contracts);
(b) it has warnings, refused rows or «по аналогии». Posting, marking or a replacement
after it needs no «да» — you do them yourself after their own dry run (ADR 0024). After the «да»,
--apply --confirm <digest> creates exactly it, re-reads it by
Ref_Key, records it in esf.contract_by_registration, and the chain stands on it
in the same run. --apply without --confirm is refused. Before planning, every
contract of the owner is read, including those marked for deletion. The same number
and date live is used. The same one marked for deletion, a folder or another
organisation's refuses the ЭСФ with the reason. Near twins (another date, the same
words, two live) are a question with the list. No number in the ЭСФ means the
accountant gives it (no contracts) or picks from the list (some). A create that
failed or went unanswered stops the run before any document and is never retried:
run find-runs.py and read the supplier's contracts first.
Never take content. Dates, amounts, numbers, quantities, prices, VAT and the primary document all come from the ЭСФ in front of you. Copying an amount off a template is how a plausible document ends up describing a delivery that never happened.
What "stable" looks like in practice: in a surveyed base, every posted chain used the
same warehouse, the same settlement account, the same advance account and the same
responsible person — while every supplier had its own contract, and one field
(УчитыватьКПН) flipped for every ЭСФ dated on or after a particular day. So:
settings are stable per base, contracts are stable per supplier, and anything that
changed mid-year needs its cutover date established rather than guessed.
What the import fills by rule instead of asking
A field every posted document fills, but not always the same way, is sometimes a real
choice and sometimes a consequence of something already known. The import fills only
the second kind, and the dry run names the rule (derived-by-rule):
- rate and multiplicity — from the posted documents in the same currency, when they all agree;
- a copy of another field — a field that on every posted document equals the counterparty, the contract or a date of that document («Поставщик_Key», the rows' «ДатаОборота») is filled from that field; it also replaces a value copied from history, because on a base with one supplier's history that value is the old supplier;
- «УчитыватьНДС» for an ЭСФ without VAT — on, with the base's own «Без НДС» rate,
and no question: the document total is the same either way, and «on» never drops the
document out of VAT accounting. The one exception is a supplier whose own posted
invoices without VAT are all «off» (at least three) — then the kit follows the
supplier. The «Без НДС» rate is never guessed: it comes from the ЭСФ line,
esf.no_vat_rate_ref, the mapping'svat_ratestable, the one catalog element of that name, or the base's own posted lines without VAT; if none of them answers, that ЭСФ is refused withvat-rate-unresolved. Decided at creation, because 1C refuses it later; - a supplier with no posted documents of its own — the settlement account, the advance account and «СобытиеОС» from the newest twenty posted documents of the same operation kind, only when all twenty agree;
- the invoice's own parties — «Поставщик_Key» is the ЭСФ's supplier and
«Покупатель_Key» the organisation the chain is written into, wherever this base's
posted invoices publish the field and none of them uses it for something else
(
esf.invoice_parties: falseswitches it off). Never take them from a template: that is another purchase's supplier; - «НДСВидПоступления_Key» on a receipt row — by THAT row's VAT (kit 1.72.0). A ref
configured in
esf.vat_receipt_kind_with_vat_ref/_without_vat_reffor the row's class wins. Without one: this supplier's posted receipts, rows of the same class only, when at least three agree; otherwise the whole base's, the same way. Rows the kit wrote do not count, and the template row and the supplier's other rows never decide it — a supplier who always sold with VAT no longer puts «с НДС» on a line without VAT. When nothing answers the row's class, that ЭСФ is held withvat-receipt-kind-unresolved: the report names the class, the rows, the key to set and the values the base uses. Write the right one into that key and run the dry run again. 1C refuses to post a receipt whose rows leave the field empty, so it is never written blank.
The template row also carries, beside «СчетЗатратБУ_Key», its tax twin «СчетЗатратНУ_Key», the second subconto (БУ and НУ, with their types) and «НДСВидОборота» — all from the same row, so the two accounts cannot come from two different purchases.
What no rule settles is still reported, with every value the base has used and how often, so one answer closes it.
Another supplier's chain as the template
A supplier with no posted chain of its own takes its settings from another supplier's
chain. That stops the write (template-other-supplier) only when a field that decides
how the documents post came from that chain and from nothing else. The import builds
the documents a second time without the template and compares: settlement and advance
accounts, «СобытиеОС», «УчитыватьНДС», «СуммаВключаетНДС», the contract, and the rows'
accounts, analytics and VAT. If every one of them was set by a rule, by the base's own
history or by a recorded decision, the report only notes the borrowed template and names
where each field came from — no --accept-warning needed. Otherwise the warning names
the fields that came from the other supplier alone; check them against this supplier's
documents before writing.
Until 2026-09-18, «СуммаВключаетНДС» (does this base write amounts gross or net) could
never clear this check on its own, even when the whole organisation agreed about it: its
common, entirely normal answer of False (net) read the same as «this base never fills
this field», so it was silently left out of every history-derived setting rather than
recognised as this base's own decision. Fixed — it is measured the same way every other
per-base setting is.
Dates and numbers come from specific places
| Field | Source |
|---|---|
| Received invoice date | the ЭСФ date |
| Incoming invoice number | the ЭСФ's Номер — see below |
| Receipt date | the ЭСФ turnover date (дата оборота), not the ЭСФ date |
| Receipt's primary-document number and date | the waybill or act, not the ЭСФ |
An ЭСФ has two numbers and only one of them is "the ЭСФ number". Номер is what
the supplier issued the invoice under and what the accountant reconciles against.
РегистрационныйНомер is the portal's identity for the document — a long machine key,
used for finding it and for duplicate protection. The received invoice's «Номер
входящего документа» takes Номер.
Both are non-empty strings that look like an invoice number, so putting the wrong one
there produces a document that matches nothing on paper and is unfalsifiable from
inside 1C. Read it back and compare against Номер specifically.
Do not substitute either of them for the waybill number, and do not replace a
technical empty date (0001-01-01) with a guess. Most receipts in a real base carry
that sentinel legitimately, because no waybill date was ever known.
What is not a question
Some fields are answered by the ЭСФ itself, and asking the accountant about them is asking them to read the document aloud. None of these is a question:
- Dates and numbers the ЭСФ states — its
Номер, its date, the turnover date, the registration number, the waybill — come from the places in the table above. The invoice rows' «ДатаОборота» is the ЭСФ's turnover date too; the import writes it wherever this base's posted invoice rows carry the field, and it is never reported asrequired-unresolved,prevalent-unfilledorsibling-unfilled. - A line's VAT rate is the ЭСФ line's. A rate only becomes a question when the
line states none and nothing in the base settles it (
vat-rate-unresolved). - An invoice that moves no register after posting is not a failed invoice when no
posted invoice of this organisation moves one either (
type-moves-nothing): on that base «Счет-фактура полученный» records nothing. It does not hold posting the receipt, andrepair-esf-posting.pyreports «nothing to repair» for it. - A wrong unposted draft this kit wrote is corrected in place with
scripts/1c/odata/correct-document.py. Never mark it for deletion in the 1C web client and create it again, and never delete and re-import the chain. - A posted document is the expected end state after
post-documents.py, not an anomaly to investigate.
Ask the accountant only what needs their judgement: which contract when the contract ladder above names several, an account the history splits on, which card a line is, and whether a borrowed template's posting fields are right.
Decide and show: how you ask
For every question the dry run leaves open, find the answer yourself before asking.
Look in the decisions already recorded in mapping.json (esf.contract_by_registration,
esf.warehouse_by_registration, esf.line_mappings, esf.existing_receipts, esf.corrections), then in the
accountant's own posted chains for this supplier — chains this kit wrote never vote —
then in the base's contracts, cards and receipts. Propose each answer with its basis, so
it can be checked in one look: «договор № 15/24 — на нём 6 из 6 поступлений бухгалтера от этого
поставщика, последнее от 02.11», «карточка «Кофе зерновой 1 кг» — та же сумма уже была
в поступлении № 218 от 14.10». When nothing gives a basis, say so and list the candidates.
Put every proposal and every remaining question in ONE message, each naming its ЭСФ (number, date, supplier, amount) and line, and ask for «да» or a correction per item — not one ЭСФ per turn. What the accountant confirms is recorded under those same keys, with the date and the accountant's own words, so the next batch does not ask it again; a line is written only once its decision is recorded and the run re-reads it.
These stay a question, with no proposal presented as the answer: which of the base's
organisations the ЭСФ is for when its recipient does not settle it
(esf-wrong-recipient, esf-recipient-ambiguous); a receipt that might already be
this delivery with several candidates; a corrected ЭСФ; and writing to 1C at all, which
needs the accountant's «да» on the dry run. A proposal nobody has confirmed is never a reason for
--accept-warnings.
Goods or services: the nomenclature card decides, per line
1C keeps purchases in two tabular sections — «Товары» and «Услуги» — because they post
differently: a goods row moves stock, a services row books straight to expense. Which
section a line belongs in is read off the resolved nomenclature card's Услуга
flag, line by line.
It is never a per-base setting, and never inherited from the template. A practice set it once, for a client whose base sold only services, and within hours every other client's goods were being filed as services — while the accountant, correctly, kept saying so in the chat and nothing changed, because the instruction was in the chat and the mistake was in a config file. A setting cannot know what a line is; the card can. The same rule decides everything downstream: the accounts, and whether a stated quantity of 0 is a lump-sum service or a credit note that needs a person.
An ЭСФ carrying both kinds becomes two receipts under one invoice. «ВидОперации» is
one value on the document header, so one receipt cannot hold both. The import writes a
goods receipt and a services receipt, and one received invoice that names both in
«ДокументыОснования» (the ЭСФ's «СчетФактура» link is a single reference, so there is
one invoice). The report says so with an esf-split warning; check both receipts
against the ЭСФ before posting. The check after the write verifies each receipt
against its own lines and the invoice against the whole ЭСФ.
The split happens only when every line has a known kind — resolved to a
nomenclature card, or one this run has been permitted to create (see "A card this run
will create is not reported as unresolved" above) — because the kind is read from the
card: one line with no card and no permission is an unknown kind, and the ЭСФ is then
refused instead. A base that wants every mixed ЭСФ refused and split by hand sets
"split_mixed": false under esf in mapping.json. Before kit 1.18.2 a correctly
split chain was reported «verification FAILED», because its first receipt was checked
against every line of the ЭСФ.
A base's own operation kind is kept. If esf.copy_from_template lists
«ВидОперации», the receipt takes the kind the template chain carries — some bases file
every purchase as «ПокупкаКомиссия» — and the check after the write expects exactly
that value. The one kind never inherited is the one the mapping declares for the
other sort of line («Услуги» on goods, «Товары» on services); the kind is then read
off the lines as above. Before kit 1.18.1 such a chain was written correctly and still
reported «verification FAILED».
If a goods line has already been filed as a service, note that 1C will not let you
PATCH the kind of an existing document: the fix is to replace the whole chain with
supersede-esf.py (see «Replacing a chain that cannot be corrected»).
Receipt-line analytics: what 1C will not infer and will not complain about
These are the fields an accountant checks first and the ones a script most often leaves empty. Every one of them saves cleanly when wrong or absent — the document totals correctly and looks finished in a listing — so none of them can be verified by anything except reading the row back.
| Field | What it is | Where it comes from |
|---|---|---|
НДСВидОборота | turnover kind, e.g. «Общий» | this base's rule, per base |
НДСВидПоступления | «Товары, приобретенные с НДС» / «…без НДС» | per line, from whether that line carries VAT |
СчетЗатратБУ / СчетЗатратНУ | cost account, e.g. 7210 | this base's rule, per base |
СубконтоЗатратБУ1 / НУ1 | cost article («Статья затрат») | per line — the same supplier's own posted receipts for that product |
СубконтоЗатратБУ2 | department | this base's rule, per base |
СчетУчетаНДС | VAT account | this base's rule, per base |
Three things worth stating separately, because each has already been shipped wrong:
НДСВидПоступленияis decided per line, by VAT. A line carrying VAT is «приобретенные с НДС»; a line without is the other one. Getting it backwards files a wrong VAT return and leaves the document total correct, so nothing downstream catches it. The supplier's history only names WHICH value of that class this base uses; it never moves a line to the other class. The read-back checks the kind against the line's VAT whether or not the two keys are set.- The cost article is per-service, not per-base. The same base books an inspection and a rent to different articles. Take it from what this supplier's own posted receipts did with that product, and leave it for the accountant when the base has never decided — an invented article is worse than an empty one.
Субконто*are polymorphic references and need their_Typecompanion (StandardODATA.Catalog_СтатьиЗатрат,…Catalog_ПодразделенияОрганизаций). Write the value alone and 1C stores it asUndefined: the field reads as filled everywhere except on the accountant's screen, where it is blank.
Take these from a row of a verified posted chain, not from its header. They are row-level fields; 1C does not put them on the document, and code that looks for them there finds nothing and writes the all-zeroes GUID without complaining.
The customs declaration (НомерГТД) is never taken from the template row. It
belongs to one delivery, and the template is another one: copied, it gives a local
purchase somebody's import declaration and an import the previous shipment's number,
the document posts, and the wrong number travels on into outgoing invoices and
traceability reports. It comes only from the ЭСФ's own row. When that row names none,
the receipt row goes out with the field empty and the dry run says so per row —
customs-declaration-missing, «номер декларации не указан в документе, образец его
не даёт». That is information, not a hold: fill the declaration in 1C if the goods
are imported. A goods_copy_row_from_template list that still names НомерГТД_Key
is honoured for every other name on it.
Receipts the kit wrote before this change may already carry a foreign number. Every
run lists the ones it wrote itself (by its mark in «Комментарий») whose declaration
their ЭСФ does not name — written-foreign-customs-declaration, with each
receipt's number and date, or one line saying all are clean. The kit changes none of
them: open each in 1C and correct or clear the declaration.
Arithmetic, per line, before anything is written
Check to the kopeck: each line's net, VAT and gross; each document total; that net + VAT = gross; and that the sum of lines equals the document total.
The VAT rate is decided per line of the ЭСФ in front of you. Not per supplier, and never copied from an older document. Suppliers change rates mid-relationship, and a VAT figure that differs between the invoice and the receipt is exactly the signal that per-line resolution was skipped somewhere. An unexplained discrepancy is a stop condition, not a rounding note.
Then check the total 1C will actually store — before writing. 1C recomputes
«СуммаДокумента» from the rows and two header flags: with «УчитыватьНДС» off it drops
the VAT, and with «СуммаВключаетНДС» off it adds the VAT on top of the rows. A
VAT-bearing ЭСФ written through a template that does not account for VAT is stored as
its net, and once 1C holds it the flag cannot be corrected. Since kit 1.19.0 the
import computes that total for every document it is about to send — in the dry run
too — and refuses the ЭСФ with esf-total-mismatch if it is not the gross, naming
the template, both flags, the net, the VAT and the expected gross. Do not work around
it: fix the template choice or the mapping, run the dry run again, and only then
--apply.
One kopeck is written and shown; two kopecks stop the ЭСФ (kit 1.84.0). A supplier's
accounting program rounds, so a line whose net + VAT is 0.01 ₸ off its own gross, or a
declared total 0.01 ₸ off the sum of the lines, is not a refusal. The ЭСФ is written
as the ЭСФ states it — the document total is never rounded in 1C's favour — and the
report carries an esf-penny-gap line, «проверить: расхождение 0,01 ₸ (ЭСФ №…,
line, what against what)». Show that line to the accountant. More than 0.01 ₸ per line,
per declared total, or over the whole document is refused exactly as before.
esf.arithmetic_tolerance can only lower this ("0" = exact); a value above 0.01 is
refused.
When 1C stores equal invoice rows merged (kit 1.84.0, off by default). If the
accountant has decided that a merged invoice row is fine, the universal rule and the
agent's record turn on esf.accept_merged_invoice_rows. The read-back then compares
the invoice by group (card, unit, VAT rate, content): the same grouped quantity, amount,
VAT and turnover as were sent is accepted and the report says «проверить: 1С объединила
строки N и M …»; any other difference is a failed verification. Without the key the
check is unchanged.
Nomenclature: resolve, don't invent
Per line, in strict order:
- a non-null nomenclature reference in the ЭСФ itself, if the card exists and is active;
- an exact external identifier (GTIN, national-catalogue code) resolving to exactly one active card;
- an unambiguous exact historical match of the source name for that same supplier;
- an unambiguous exact match against an active catalog card;
- creating a new card — only with the user's explicit permission.
A similar name is not an identifier. Dose, concentration, volume, pack quantity, dosage form, brand and manufacturer all have to match. Two cards sharing an identifier or an exact name means stop and ask, unless the ЭСФ carries a confirmed reference.
When the ladder answers nothing: look before you decide
scripts/1c/esf/suggest-nomenclature.py reads the base around an unresolved line
and prints the candidates with the evidence for each and what argues against it.
It never picks — there is no threshold and no --best, and verdict is null
even in --json. When only a name resemblance carries every candidate it says
so outright, because a coincidence dressed up as a suggestion takes the decision
away from the person whose name belongs on it.
python3 scripts/1c/esf/suggest-nomenclature.py --registration ESF-…-…-…
What it can tell you that the ladder cannot:
- the same money, already filed this way — a past receipt row booked at exactly this total against that card. The strongest everyday signal, because a name can drift and a unit gets converted (50 kg on the ЭСФ becomes 50 000 г in the receipt) but the total does neither;
- what this supplier has actually delivered, as a count and a share of their posted rows;
- when the tempting answer is the wrong one — if the supplier bills some other line under a name that fits the card better, that card is probably that other product's. A 50 kg bulk line resembles a «200 г пакет» card until you notice the supplier bills the pack separately, under its own name;
- when one reference serves several lines — that reference cannot tell those lines apart, and treating it as proof files two products as one.
Read it, decide, then record the decision (below). The report also names which column it read the item reference from: if it says the configured field is absent from your ЭСФ rows, the first rung of the ladder has been finding nothing on every line, which looks exactly like «the supplier named no card».
You no longer have to spot that yourself. If the configured column is absent and your ЭСФ rows are holding out another one, the import stops and names it:
«Номенклатура_Key» is not published on the ЭСФ's «Товары» rows in this
configuration … This base points at Catalog_Номенклатура through: «Товар».
Set esf.line_fields.nomenclature in mapping.json … Every column this row is
missing, in one block: {"esf": {"line_fields": {"esf_item_id": "GTIN", "gtin": "GTIN", "nomenclature": "Товар"}}}
The block lists every column the row lacks, the GTIN/identifier columns included
(1C:Fresh publishes a plain GTIN instead of ИдентификаторТовараЭСФ), so one
edit fixes them all. A run whose identifier column is absent but whose item reference
is fine says so once, as line-field-unpublished, with the same block. The incoming
number needs no setting: a base that publishes «Number» instead of «Номер» is
read from «Number» already.
Set it — and then read what it resolves to before you trust it. On one live base the column was filled on 98% of lines and every card it named was real, but 52 of 120 documents had two differently-named lines carrying the same reference. Wiring the field and walking away files those two products as one, on the strongest kind of evidence there is. A base whose ЭСФ genuinely reference no cards is not stopped — it falls through to name and GTIN matching, as before.
When you do create a card, with permission: re-check for duplicates by external identifier and exact name first, use the exact source name, keep GTIN / ТН ВЭД / full name, set the base unit from the ЭСФ code, set the VAT rate from the current line, clone only accounting fields from a comparable card in the same base, strip server-owned fields, note the source ЭСФ registration number in the comment, and re-read the card to confirm name, unit, VAT and that it is active.
The same GTIN under slightly different names is one product. Use the existing card.
The space's rules as parameters: esf.nomenclature_rules (kit 1.78.0)
The order is fixed: rules → the base's history → creation, and a question is left
only where there is no ground. A rule the space already made — «карточки не нашлось —
создай», «услуга — единица 5114» — is recorded once in mapping.json
(esf.nomenclature_rules: create_missing, kind_from_esf, service_unit_code,
parent_from_history; all off by default) and the dry run executes it and says on what
ground: «Решено без вопроса по правилу …». create_missing has exactly the gates of
--create-nomenclature (written only on --apply; a dry run only lists the cards), it
never applies to a line with two live cards, and a supplier whose own history booked one
name to two cards is a question («какая из двух?»), not a reason to create a third. The
single «записать?» per batch stays the only question. Without VAT in the amounts a row
keeps the price the ЭСФ states when it agrees with the amount to the kopeck tolerance.
A line that is a fixed asset (ОС) is not written as goods (kit 1.81.0)
An ЭСФ for equipment must not become a goods receipt on the stock account. The import
treats a line as a fixed asset only on evidence: the accountant's own posted receipts of
that card are on a 24xx account (or in a fixed-asset operation kind or section the base
named), or the base recorded the decision once (esf.fixed_assets.cards, true for an
asset, false for goods). Then the receipt is written with her «ВидОперации» and her
accounts, and carries no cost account or analytics. The account sign is read from the
account the row is booked to — a cost account of a service is not a sign. Nothing is written,
and the report says fixed-asset-unresolved with the reason, when: the evidence is not
unanimous; there are fewer than three of her receipts to take the form from; the form has
fields the import does not write (extra row or header fields, a second tabular section such
as «АмортизацияОС», a VAT account, kind or turnover that differ from her ordinary
receipts); the ЭСФ mixes an asset with goods; the chart of accounts could not be read whole;
or a run that reads only part of the base (--only-refs, an import from a waybill) could
not read the card's whole history. A receipt an earlier run left half-written as goods is
not finished — the report says chain-already-started with the difference. Without any
sign the line is written exactly as before. Commissioning, depreciation and receipts already
written as goods are not touched. Not yet confirmed on a client base: the real
fixed-asset document form and the reading of the tabular sections of receipts.
A card this run will create is not reported as unresolved
Run with --create-nomenclature, a line that needs step 5 gets a card planned
for it, not created on the spot — creation happens later in the same run, once
every other decision for the ЭСФ has been made, so a dry run always plans and
never writes. Until 2026-09-18 the pre-write check that compares a draft against
this base's own posted history did not know that, and asked you to pick one of
the base's existing cards to answer a question --create-nomenclature had
already answered. That is fixed: a line whose card this run has been permitted
to create is reported as settled — «карточка будет создана в этом прогоне» —
and only that line. Without the flag, or for a line nothing was planned for,
the same field still holds the chain exactly as before.
«Код» of a new card: 1C numbers it, unless 1C refuses its own number
A new card is sent without a «Код», and 1C numbers it the way it numbers
every other card. The dry run says so: «код назначит 1С; если 1С откажет —
следующий свободный код базы». If 1C refuses that code as already taken
(«Значение «999» поля «Код» не уникально» — seen on a base whose numbering
repeated a held code), the import reads the catalog's codes once, takes the
first free code above the refused one, in that code's format
(00-00000999 → 00-00001000, 999 → 1000 or the next free after
it), sends the card once more and checks the code
1C stored. The report names the code it chose and the one 1C refused.
A second refusal stops the run with nomenclature-code-taken: nothing
was written and there is no third try. Ask the accountant to look at the
numbering of «Номенклатура» in 1C (prefix, code length, the card holding that
code — one marked for deletion counts too), then re-run. Do not choose codes
by hand in your own script or change the kit to always send one: on other
bases the numbering works. The --confirm code of the dry run does not
change because of this.
A per-line record can say this explicitly too: {"source_name": "...", "unit_ref": "...", "create": {"description": "..."}} — «no card here matches
this line, make one» — instead of leaving it to the automatic steps above to
fail before step 5 is reached. description is optional and, when given,
overrides what the new card is called (the ЭСФ line's own name is used
otherwise). Creating still needs --create-nomenclature and still goes
through the same duplicate check and read-back as any other card this run
creates — the record only says a person already decided, so the run does not
have to fail its way there.
A card created in a run is found by the next line of the same card in that run
(kit 1.64.0) — before, a second line could read «not found». The new card gets
the VAT rate when every line of the ЭСФ that needs it carries one non-zero rate;
lines with two different rates write no rate and warn
nomenclature-vat-rate-conflict — set the rate on the card in 1C. When
«Комментарий» is published, the card says «Создано из ЭСФ <рег. номер>».
The record can also answer «goods or service?» for the new card:
"create": {"is_service": true} (the older spelling "create": true, "is_service": true means the same). The kit otherwise takes that from the
supplier's own posted history and refuses when the history is empty or split; a
recorded answer is used there, and beats the history when they disagree — the
report names both. It is one line's decision, never a setting for the whole base.
Where new service cards are filed — folder, nomenclature group, «ВидНДСПриИмпорте»
— is esf.service_nomenclature_defaults (parent_ref,
nomenclature_group_ref, vat_import_kind); the card's VAT rate is the line's
own. A folder that is not a live folder, a group that is not a live element, or a
default the base does not publish refuses the card rather than creating it
somewhere else.
Other per-base or per-ЭСФ decisions a mapping can record (all optional; without
them nothing changes): without_contract_registrations — these ЭСФ go in with
no contract, by decision; default_contract_without_esf_contract — the exact name
of the contract card (e.g. «Без договора») every ЭСФ that names NO contract goes on,
for the whole base: one card of that name and of the supplier kind («С поставщиком»;
a «Без договора» with the customer is never taken), or that ЭСФ is refused
with the reason and the kind named (none or several) and nothing is created or guessed; a decision for
one ЭСФ and a contract the ЭСФ itself names both win over it. Without the key the
contract comes from the supplier's history as before, and the dry run says for every
ЭСФ without a contract where it came from (contract-source: «настройка базы»,
«история поставщика», «новейшая карточка, истории нет»); vat_inclusive_overrides — «СуммаВключаетНДС» for
one ЭСФ; template_supplier_registrations — take the template from another
ЭСФ's supplier's posted chain (a person approved it, so it is not held);
row_coefficient, services_row_unit: false,
services_row_content: "line_name", tax_expense_department: false — the
row shape a base writes; strict_receipt_analytics: true — the receipt-line
analytics are checked against the configuration BEFORE writing. Lines are
numbered by 1C's own «LineNumber» (the number you see in 1C), an ЭСФ with an
empty «Number» is refused rather than given its registration number, and
esf.lines_section is an old name that is no longer read — the report says
what to rename it to.
A planned card also settles whether an ЭСФ mixing goods and services (below) may be
split. Until 2026-09-18 the split check asked the same question the paragraph above
already fixed — "does this line have a card right now" — for a different purpose, and
a line whose card this run had planned but not yet written still read as unknown. A
dry run held such a chain as unsplittable while the very next --apply, where the
card is created before the check runs, split and wrote it without a warning. Both runs
now agree: a planned card is a known kind on either one, and a line nothing has
planned still holds the split the same way on both.
Until 2026-09-19 the SAME mixed shape — a planned card, on an ЭСФ split into a goods
receipt and a services receipt — could still disagree between a dry run and
--apply, for two more reasons layered on top of each other. A goods/services split
renumbers a line's position within its own section (so a second receipt does not start
counting at "line 3"), and the check that excuses a planned card was still matching on
the OLD position, so the excuse silently stopped applying the moment a chain split.
Separately, a supplier with very few posted documents of its own could make the base
appear to always use ONE fixed product for every line — which is never true of a
line's own nomenclature — and that false "always the same" reading masked the first
bug for a day. Both are fixed, and a new automated check now runs a dry run and
--apply back to back, on the same data, across several such shapes, so the two can
no longer quietly drift apart again.
Units
- the active unit named in the ЭСФ;
- an exact, unambiguous match of
ЕдиницаИзмеренияКодagainst this base's unit catalog; - the unambiguous unit of confirmed nomenclature or of that product's history.
The unit's text is routinely empty or wrong; the code wins, but only on an exact unique match. One code resolving to several active units, or no code at all, is stop-and-ask. Expect this to bite often — partial unit recognition is the norm, not the exception.
Filling units on an ЭСФ that is already in the base
The rules above are for a chain you are creating. An ЭСФ that arrived from the portal months ago and sits there with empty «Ед. изм.» and «Ед. изм. остатков» is a different job: it cannot be posted that way, and filling those rows by hand across a month of invoices is work nobody does carefully by the fortieth row.
fill-esf-units.py does it. The rule below belongs to the accounting practice that
uses it — confirmed by their administrator on 2026-08-04 — so all of it is
mapping.json configuration under esf.units_fill, not code:
- The nomenclature card's base unit wins, always. It is what this base already decided about this product, and it outranks anything read off a label.
- Failing that, finished pharmaceutical packaging is
шт— tablets, capsules, dragee, ampoules, vials, tubes, and anything carrying мг / мл / №. What is sold is the package, not its contents. A row reading "Меновазин 40 мл" is one bottle, not forty millilitres. - Loose or weighed goods are left alone, even when the name also matches rule 2.
- A conversion coefficient other than 1 leaves the row alone. The two units are then different measures and the relationship between them is not yours to infer. At coefficient 1 they must agree, and a payload where they don't is refused.
- Nothing else is guessed. A row the card is silent about and the name does not identify goes on the manual list, with the reason.
Rule 5 is the one that matters, and it is why the report is always three lists — filled (with the source of each unit), already complete, and needs-a-human. A run that fills every row and flags nothing has been lucky or has guessed, and you cannot tell which from the outcome. A unit written onto a row is indistinguishable from a unit that was checked, and it changes what every quantity on that row means.
Two mechanical traps, both of which delete data silently:
- Send the whole tabular section. A partial section replaces the section — the rows you left out are deleted. "Only send what changed" destroys the rest of the invoice.
- Only the item reference and the two units may move. Quantity, price, amount and VAT are the supplier's figures. The script proves this with a field-level diff before writing rather than merely intending it, because a payload assembled from a re-read row carries every field.
This is a write to a document the kit did not create, so it takes the same guard as
link_esf_to_invoice: the ЭСФ must belong to the pinned organisation, and the
totals and the invoice link are re-read afterwards to prove the edit moved nothing
else. Nothing is posted.
Duplicate protection
Identify an ЭСФ by the whole set — Ref_Key, registration number, supplier,
organisation, number and date, turnover date, amount, and the composition of its
lines. Before creating, confirm: the ЭСФ is incoming, active, and belongs to the
target organisation; its СчетФактура field is empty; the registration number
occurs once; no invoice already exists with that supplier, incoming number, date
and amount; no receipt already exists for that waybill, supplier, date and
amount; and no chain already carries this ЭСФ's marker.
The same supplier number is not automatically a duplicate. When an old and a new document nearly match but the registration numbers differ, that is a re-issued ЭСФ — a separate decision, not a skip. A corrected ЭСФ the import recognises itself — see «A corrected ЭСФ is never a second receipt».
«Active» means the portal's state too, not only DeletionMark. An ЭСФ annulled or
withdrawn on the portal reaches 1C with DeletionMark=false and an empty
СчетФактура — it looks exactly like one nobody has processed. The import reads
«Статус» and «Состояние»: a value containing «аннулир» or «отозван» (any case, ё=е,
spaces ignored) refuses the ЭСФ, and the batch report lists it as esf-skipped
with the field and its value; supersede-esf.py refuses it the same way
(esf-not-importable). Do not import it by hand either. If this base uses other
words, the stems are esf.cancelled_states in mapping.json ([] turns the
check off). «ОтказВАннулировании», «ОжидаетАннулирования» and «НаАннулировании» are
not cancelled and import; the last two get the report line
esf-pending-cancellation — check the ЭСФ's status before closing the period.
A base that does not publish either field is not checked, and imports as before. An ЭСФ annulled AFTER its chain was written is still skipped as «already
points at invoice», and the report lists it in its own section,
esf-cancelled-after-import, with the invoice still standing in 1C (its number and
date when the run has read it, otherwise its reference) — check the VAT offset. Nothing is written or unwound and the run is not held; unwinding the
chain is the accountant's decision.
When the receipt is already there (existing-receipt)
The ЭСФ often arrives weeks after the goods, and by then the receipt may already be in the base — entered by the accountant from the paper waybill, or loaded by a retail system. The import looks for it before creating anything, and says which rule found it:
- a recorded decision,
esf.existing_receiptsin mapping.json:{"<registration number>": "<Ref_Key of the receipt>"}, or"new"when this delivery has no receipt yet; - the waybill number: the ЭСФ names the waybill in its section G, and the accountant types the same number into the receipt's «Номер входящего документа» (leading zeros do not matter);
- the same amount on the turnover date, when exactly one receipt of this supplier has it (a retail system's receipts carry no number);
- the same amount within 3 days — a warning: the invoice is written on it only once you accept it.
When one is found, only the invoice is written, standing on that receipt,
with that receipt's cards and contract. The receipt itself is never changed.
The ЭСФ is skipped, with the candidates named, when there are several; when
the waybill number matches but the amount differs; when a receipt of the same
amount names another waybill; and when a receipt of exactly this amount already
stands under another invoice — that ЭСФ may repeat one already processed.
Answer each with esf.existing_receipts.
A receipt that only might be this delivery is asked about too, and nothing is created until it is answered:
- within 3 days, for another amount, with no invoice on it
(
existing-receipt-nearby); - exactly this amount within 30 days, with no invoice on it and not written by the
import (
existing-receipt-wide). A monthly rent whose earlier receipts have their invoices is not asked about; - the ЭСФ has no date to search around (
existing-receipt-undated).
"new" lifts each one for that registration number. The report groups the
questions by supplier and prints the block to paste: one answer covers the ЭСФ it
lists and says nothing about a later ЭСФ of the same supplier.
Several counterparty cards with one БИН/ИИН count as one supplier for this search
only. A match on the other card is a warning (existing-receipt-other-card);
once you accept it, the invoice stands on that receipt under the ЭСФ's own card
and contract. A card with an empty БИН joins nothing.
--apply --confirm looks again at each supplier's receipts, so one entered
after the dry run stops the write (plan-changed).
If an --apply --confirm wrote only part of its plan, run the next DRY RUN with
--reuse-plan <that digest>: it reuses the plan's evidence for the ЭСФ still left
(plan-reused-subset), finishes a half-written chain by its anchors, and prints a new
digest to confirm. It keeps the old plan's date (12 hours from the first read) and is
refused with --apply or --replace-invoice.
A receipt the import does create now carries the waybill number and date from the ЭСФ, the way the accountant's do.
Posting from a paper waybill (import-waybill.py)
To enter the receipt the day the goods arrive, before the ЭСФ exists: read the photo of the «Накладная на отпуск запасов на сторону» into a JSON file, then
python3 scripts/1c/esf/import-waybill.py --waybill synced_data/1c/waybills/152.json
python3 scripts/1c/esf/import-waybill.py --waybill synced_data/1c/waybills/152.json \
--apply --confirm <code from the dry run>
{"supplier_bin": "260140022690", "supplier_name": "ТОО «OfficeMax»",
"number": "152", "date": "2026-08-05", "total": 32801.00, "vat_total": 4524.27,
"warehouse": "Коктобе сити",
"lines": [{"name": "Ножницы Foska YG9039-B, 18 см", "article": "YG9039",
"unit": "шт", "quantity": 3, "price": 823.00, "sum": 2469.00, "vat": 340.55}]}
Copy the numbers exactly as printed; never fix one so that it adds up. The file
is checked harder than an ЭСФ: quantity × price for each line, the lines against
«Итого», and the VAT against its total and its rate. If anything disagrees,
nothing is written — look at the photo again and correct the file. The supplier
is found by its БИН. The warehouse comes from --warehouse or from the note
written on the paper; with neither, the run is held until you name one. Cards
come from this supplier's own earlier ЭСФ and recorded decisions, then the usual
ladder. An existing card keeps its own unit. Only the receipt is written,
unposted. When the ЭСФ arrives, the ordinary import finds the receipt by the
waybill number and writes only the invoice. A delivery already in the base
(waybill-already-in-base) is not written again.
Writing the chain
- create the fully populated unposted receipt;
- re-read it and take its
Ref_Key; - create the unposted received invoice with the main reference and the
ДокументыОснованияrow pointing at the receipt; - re-read the invoice;
- write the receipt's back-reference to the invoice;
- write the ЭСФ's reference to the invoice;
- re-read all three.
All three stay Posted=false. Every draft carries a technical comment with the
source ЭСФ registration number, and the script is idempotent: a second run finds
the cards and documents it already created instead of making more.
That comment is required. It holds the anchor that lets a later run recognise a
chain interrupted after step 1, so an empty one is refused before anything is
read (no-import-anchor). The text comes from esf.comment in
mapping.json, which applies to ЭСФ documents only. If this base has comments
switched off for bank documents (documents.write_comment: false) and names no
esf.comment, set one, for example «Создано из входящей ЭСФ. Требует проверки
бухгалтером.». Do not switch comments back on for the whole base to get past it.
If a run stops between those steps, read ## Written before doing anything
else. A chain that created its documents and then could not finish is listed
there as INCOMPLETE, with each document's 1C number and Ref_Key, the
anchor they carry, and a «Never done:» line naming the steps that did not happen
(the receipt's back-reference, the ЭСФ link, the read-back). Those documents are
in the base. The next --apply of that ЭСФ finishes the chain from those
very documents: it re-reads them by Ref_Key, writes only the missing steps and
creates nothing a second time (chain-resumed in the report). It does that only
when the pieces are unambiguous — none posted, at most one receipt per kind and
one invoice, the invoice standing on those receipts. Otherwise the ЭСФ is refused
as chain-already-started with the reason, and you decide with
find-runs.py — finish the links, or mark the drafts with mark-for-deletion.py. So: do not delete the drafts to «start over», and do not post
them by hand before the chain is finished.
--apply holds the base for the whole run — cards, contracts and every chain. Another chat's write to the same base waits for the import, and the import for it: «база занята другой записью агента, жду» on stderr is that queue, not a hang. If the other write held the base past the ceiling (10 minutes), the import stops before writing anything — no card, no draft — with base-busy, exit 1, and a report that says «Ничего не записано»: tell the accountant the base is busy and run the same --apply --confirm … again later. repair-esf-posting.py and repair-goods-accounts.py queue the same way. The dry run never waits.
Two refusals of a hosted 1C:Fresh base
odata-memory-limit— «Ошибка датаакселератора. Недостаточно памяти.» The server ran out of memory; it is a state of the server, not of the request, and it can hit a read of ONE document. A read steps its page down 1000 → 200 → 100 by itself; a read by key is asked again at most twice, with a pause; a write is never sent again. If it still fails, put"page_size": 200and"parallel_requests": 1inscripts/1c/credentials.jsonand run again when nobody is working in the base. A chain cut by it is listed as INCOMPLETE and the next run finishes it (above).1c-before-write-refused— «Ошибка при выполнении обработчика 'ПередЗаписью'». Nothing was written. If 1C names a field, it is filled by precedent: add it toesf.copy_from_template(receipt) oresf.invoice_copy_from_template(invoice), dry-run ONE ЭСФ with--registration <number>, show the accountant the value, and only after her «yes» run--registration <number> --apply --confirm <digest>. If it names nothing, it is a setting of the base: the text gives the change-prohibition date when the base publishes it over OData (or says plainly that only the administrator sees it) and what to hand the 1C administrator. On 2026-11-17 exactly this refusal was the change-prohibition date; lifting it let the next run write.
The ЭСФ names its supplier and its goods; the card gets its codes
On every base, by default, and before the receipt — the order you keep in 1C:
after your «да» the run creates the cards, completes the ЭСФ, then writes the
receipt from it, the invoice and the links, and finally re-reads the chain and
checks the ЭСФ agrees with it (esf-source-fields-drift stops the batch if not).
To keep the old order on one base (the ЭСФ is completed after the chain is written
and verified): "esf": {"complete_source_fields": {"order": "after"}}. A receipt
already in the base, a waybill, a replacement and a resumed chain always keep the
old order. If a run stops after the ЭСФ and before the receipt, the report says
«INCOMPLETE — the ЭСФ itself was completed»; the next dry run shows
esf-half-chain, and the next --apply writes the receipt and the invoice
without writing the ЭСФ again. If 1C refuses the ЭСФ write because the ЭСФ does
not stand on an invoice yet, the report says what was stored and that this base
needs "order": "after"; an ЭСФ left partially changed is named
(esf-partially-completed) and not written over until it is put back or
completed. What is written: section B «Поставщик» on the
row of «Поставщики» (the header «Контрагент» alone is not kept by 1C), and on each
line «Товар» — the nomenclature card the receipt row carries — with «Ед. изм.» and
«Ед. изм. остатков» in the unit that row was booked in. Lines are matched by the
supplier's figures (quantity, VAT, amount, rate), never by position, and the
supplier only when the БИН/ИИН the ЭСФ states is on the counterparty's card. Every
goods card the chain books to also gets the line's «ТН ВЭД» and «Код НКТ»
(NTIN; from the GTIN column only when it is the national code) — but only where the
card's field is empty; a new card is created with them.
Nothing filled is ever replaced. A card that already has a different code, one card
that the batch's lines give two different codes, a section B that already names
another supplier, a unit that would need a conversion — each is reported by name
(nomenclature-code-conflict, esf-source-fields-refused) and left for the
accountant. Names, quantities, prices, VAT, amounts, posting and links are never
touched. The dry run shows all of it, and the codes are part of the --confirm
code. For a chain written earlier:
fill-esf-units.py --number <ЭСФ number> --complete-from-chain [--apply] — only for a
chain this kit wrote. Do not write a receipt, an invoice or an ЭСФ «по аналогии»
with create-document.py: it holds such a run (esf-chain-by-precedent)
because it does none of this. Off for one base: "esf": {"complete_source_fields": false} / {"nomenclature_codes": false}.
In the same write the ЭСФ header gets «ДоговорПоставки» — the receipt's contract —
and «Грузоотправитель» — the supplier's counterparty card, only when the consignor
БИН/ИИН in the ЭСФ is that card's, and always together with its type field: a
base without that field gets neither. Only empty fields: one already filled with
something else is reported (esf-header-conflict, a warning) and left as it is,
while the rest is still written; a consignor who is not the supplier is left to the
accountant. Both are read back. A base whose ЭСФ does not publish «Грузоотправитель»
in OData is told once per run (consignor-field-unpublished, information — it
holds nothing) and the other fields are written.
Verify by reading, separately
A successful POST is not evidence. In an independent read, confirm: one ЭСФ, one invoice, one receipt; all three on the same organisation and supplier; the same contract on invoice and receipt; the ЭСФ pointing at the right invoice; invoice and receipt linked both ways; line count matching the ЭСФ; nomenclature and unit filled on every line; quantity, price, amount, rate and VAT matching the source; each document total matching the ЭСФ; dates and numbers taken from the right sources; and nothing posted or marked for deletion.
Posting
Posting is the next step once the drafts reconcile, and whether you do it without
asking is the accountant's word, recorded once in esf.run_policy (record-run-policy.py):
after_check — post after the check and show the result; ask — offer after every
write. Not recorded yet: by the base's precedent, in ONE question before the write —
if more than half of the past ЭСФ chains THIS KIT wrote are posted, ask «записать N и провести, как прошлые?» (one
«yes» for both, no second question after the write); if they are not posted or there are
none, ask only «записать?». Never post silently. After a clean write the report says «N непроведённых —
провести одной командой» and prints the command; always offer it. The import itself never posts.
Post with scripts/1c/odata/post-documents.py, giving it every document the
import created — receipts and invoices — in ONE call (--ref Document_<Name>:<Ref_Key>
per document; the dry run prints a code, then --apply --confirm <code>). Posted=true alone proves nothing: it counts a
document posted only when a register movement was recorded, and clears the flag when
none was. A document that fails is named and left unposted, and the rest are still
posted and proven. Run diagnose-posting.py only on a document it reported not
posted. Afterwards confirm that every link survived, amounts and line counts are
unchanged, and no duplicates or deletion marks appeared.
Receipts and invoices go in the same call, in any order. The script posts the invoices last. Posting a receipt makes 1C set the invoice standing on it to «Проведён» with no movements; the script reads every invoice's flag before it starts, so a flag its own run set is cleared and that invoice posted in the same call — only an invoice that was already in that state before the run is reported as broken.
Reposting a linked ЭСФ is not part of the routine (not confirmed on a base).
post-documents.py can repost one (--ref Document_ЭСФ:<Ref_Key>, only a posted
ЭСФ in «Статус» «Созданный» whose invoice is posted), but call it only when the
accountant asks for it — never as a step of the import.
«ПодтвержденДокументамиОтгрузки» on the invoice follows the accountant. The
import ticks it only as her own posted invoices say (the supplier's first, then the
organisation's, at least five, all the same — false counts as an answer too);
documents the kit wrote never count. With no such answer it is ticked, as before. The
report names how many documents gave the answer. Whether the box matters to «Извещение
об отнесении НДС в зачёт» is not confirmed on a base.
The receipt is what has to move. On a base where no posted «Счет-фактура
полученный» records a movement (the import reports type-moves-nothing), an
invoice that moved nothing is in its normal state — report it, and do not let it stop
the receipts.
A VAT-free invoice on a receipt that moved stays posted. When every line of a
posted «Счет-фактура полученный» is «Без НДС»/0 with СуммаНДС = 0 (its own lines —
not its «УчитыватьНДС» header, not the supplier) and its receipt, of the same
organisation and not marked for deletion, moved a register, 1C had nothing for the
invoice to record. post-documents.py leaves it posted and says so on its own line,
«без НДС, движений нет — оставлен проведённым» — relay it as information, not as a
failure; the import keeps it as a template (no-vat-unmoved-kept) and
repair-esf-posting.py reports «nothing to repair». An invoice with VAT on any line
is still cleared and named as before. "esf": {"no_vat_unmoved_invoice": "set_aside"}
in mapping.json restores the old behaviour, the template choice included; write it
only in this space's own chat. When the new reading picks another template chain than
the old one would have, the report has one line «образец сменился: <old chain's
invoice / receipt numbers> → <new>, счета строк <old> → <new>;
esf.no_vat_unmoved_invoice=set_aside возвращает прежний выбор» — tell the accountant
which chain the ЭСФ now copies and which accounts its lines get.
A wrong unposted draft is corrected, not recreated. Use
scripts/1c/odata/correct-document.py --entity-set … --ref … --set Поле=значение
(dry run first, then --apply) — a posted or marked chain too, since any document
can be corrected in place (§10 of the OData rules).
supersede-esf.py (below) is only for a field 1C accepts only at creation.
Receipts written with an empty stock or settlement account (kit 1.71.0). Before
kit 1.69.0 the kit could write a «Товары» row with «СчетУчетаБУ» empty, or a receipt of
any kind, «Услуги» included, with an empty settlement account. Run
python3 scripts/1c/esf/repair-goods-accounts.py --mapping … --credentials … (reads
only): it finds the kit's own such receipts and lists them — unposted and posted
separately, with number, date and rows, and what each would get. The values come from the
import's own rules: esf.goods_account_ref, otherwise the accountant's posted receipts
(this card → this supplier → the base's last 10 rows, unanimous only); the settlement
account from the import's rules (receipts of the same kind only), then
esf.settlement_accounts. A receipt with no single answer is held and named, and left
unchanged. An empty cost account on a «Услуги» row is named but not filled: fill it with
correct-document.py; a posted receipt with one is held. Show the list to the accountant; one
«да» covers the whole batch: --apply --confirm <code>. Posted receipts are unposted,
filled, posted again and their movements checked. If 1C refuses one, it is named and the
rest are fixed. Undo: scripts/1c/odata/correct-document.py --rollback <run>.
Rows with an empty tax (НУ) or VAT account (kit 1.76.0). The same command also lists
the kit's receipts whose rows have «СчетУчетаНУ» («Товары»), «СчетЗатратНУ» («Услуги»)
or «СчетУчетаНДС» empty while the accounting account is set. It fills them on
unposted receipts only. The tax account is taken only from a sample in this base: the
accountant's posted receipts with the same nomenclature and the same accounting account,
otherwise the same nomenclature group with the same accounting account, otherwise (kit
1.77.0) every row of the base with the same accounting account, if there are at least 20 and
they all agree. If those rows do not agree, or there are none, the row is refused with the
reason and stays empty; it is never guessed. An empty VAT turnover kind («НДСВидОборота»,
kit 1.77.0) is filled the way the import fills it: esf.vat_turnover_kind, otherwise
the accountant's posted rows of the same VAT class (with or without VAT), if at least three
receipts agree. The VAT account is taken only from esf.vat_account_ref. Without that
key the row is refused «нет настройки», so ask the accountant for the VAT account once and
record it. The receipt's other rows are still filled. A posted receipt with such rows
is listed under «Нужно перепровести» and not changed.
A document that «posted» with no movements is repaired, not reposted — posting
it again with the same empty fields changes nothing. Run
python3 scripts/1c/esf/repair-esf-posting.py <entity set> <Ref_Key> --mapping … --credentials …
(reads only), show in the chat what it would fill, then run it again
with --apply --confirm <digest>. It clears the false flag, fills the fields every
recent working document of the same operation carries (from the same rules the
import uses), posts, and proves the movement — one document per run. If it refuses,
relay its reason: a field with several candidates is the accountant's choice, and a
field 1C accepts only at creation means replacing the chain (below).
A month of ЭСФ in one pass
Do a month (or any period) in a separate chat, with the kit's commands only — write no script of your own while the kit has the command. One dry run, one write:
import-esf.py … --from 2026-11-01 --to 2026-11-30 --suppliers known --questions questions.json
record-answers.py --answers questions.json # checks every answer
record-answers.py --answers questions.json --apply # records them
import-esf.py … --from … --to … --suppliers known --apply --confirm <digest>
- A warning about one ЭСФ (
contract-substituted,template-other-supplier,contract-unresolved,supplier-lookup-unreadable) holds that ЭСФ only; the others are written and the held one is named with the flag that releases it. Exit 3 = part written, 4 = nothing written because everything was held. - All open questions land in ONE file.
record-answers.pyrecords the answers without a manual edit ofmapping.jsonand reads everyRef_Keyfrom 1C: a wrong one is refused when recorded, not on the next run. It replaces an earlier decision only when the run proved it dead (re-worded line, deleted card or unit) and shows «was → now»; on a base with several organisations it needs--organization. --suppliers knownleaves out an ЭСФ of a supplier the base does not hold and names it; a supplier that could not be READ is held with the error, not left out as «absent». The kit never creates a counterparty; a nomenclature card only through--create-nomenclaturefrom a dry run that listed it.- A zero or negative quantity refuses that ЭСФ only, with its own code
(
esf-zero-quantity,esf-negative-quantity); the report counts them. - «Вид учёта НУ» and «Учитывать КПН» are named with their place in the document's «Цена и валюта» window. The template fills them only from at least 5 posted documents that moved a register; a shorter history gets a question.
- A repeat dry run takes the posting proof from a cache for 12 hours
(
--no-proof-cachereads everything). Only «moved» is cached, and only for the same document version (a re-post changes it); a document that moved nothing is asked again every run. A register that timed out is skipped and named, and a document found nowhere else is «not checked», not «refused» — nothing is set aside. fill-card-codes.pyfills «ТН ВЭД» / «Код НКТ» of the period's cards from the ЭСФ: only empty fields, a conflict is listed and not written, a write needs--apply --confirm. An annulled or withdrawn ЭСФ gives no codes and is named.
Replacing a chain that cannot be corrected
Some invoice fields are accepted only while the document is being created —
«КурсВзаиморасчетов», «КратностьВзаиморасчетов», «УчитыватьНДС» — and a chain with
one of them wrong, or with the wrong total, is replaced rather than edited. Never
write a one-off script for this. A hand-written replacement that created a new
invoice on each failed attempt left one ЭСФ with five live invoices, and 1C then
refused every further write to that chain. Use supersede-esf.py:
python3 scripts/1c/esf/supersede-esf.py --registration <ЭСФ> --replace-invoice <invoice №>— a dry run. It names the chain the ЭСФ stands on and, while that chain is still live, names what has to happen first: unpost it if it is posted and mark the invoice and its receipt(s) for deletion.supersede-esf.pydoes neither itself — you do them yourself withmark-for-deletion.py(a posted document is unposted first; dry run, then--apply --confirm; see §10 of the OData rules), never with a script of your own and never by sending the accountant into 1C.- After that is done, run the same dry run again. Now it predicts the new chain and prints
--apply --confirm <digest>. The digest covers the ЭСФ, the chain being replaced and every payload, so it is good only for what that dry run showed. - Run it with
--apply --confirm <digest>. It creates the new unposted chain with the same code the import uses, moves the ЭСФ's link from the marked invoice to the new one, and reads all three back. - Post the new chain with
post-documents.py; the marked documents can then be deleted withmark-for-deletion.py --delete(its dry run lists what still references them).
The old chain is marked before the new one exists, so there is never a moment with two live chains for one ЭСФ. An interrupted run is finished by running it again: nothing that exists is created twice, and two live pieces of one role are a refusal, never a choice. It replaces one chain per run and only the chain the ЭСФ actually points at. Exit status: 0 done or nothing to do, 1 refused, waiting for the old chain to be unposted and marked, or unconfirmed.
Batches, and which ЭСФ a batch starts from
Default to the current period, newest first. An accountant asking for "the first three" means the three that are in their way today, not the three oldest rows in a register that reaches back years. Sorting the unprocessed set ascending and taking the head is how a request about this year gets answered with documents written into a period that was closed and audited two years ago — which then have to be found and deleted one at a time.
Resolve the selection before you write anything:
- take the current year unless the user named a period;
- inside it, sort newest turnover date first, then ЭСФ date and number;
- state the date range in the same message that proposes the batch — "3 ЭСФ, 12.07.2026–04.08.2026". A wrong period is obvious to an accountant at a glance and completely invisible inside a registration number;
- treat anything outside the current period as opt-in. Ask before including it, and never let a bare "the first N" reach into a closed year.
Old unprocessed ЭСФ are a question of their own, not a backlog to work through head-first. One still sitting unlinked in a base that has been closing its books normally is far more likely to be abandoned, superseded or corrected elsewhere than work waiting to be done — and posting it silently reopens a period the accountant has already filed.
Then, for the batch itself: exclude anything already linked; set aside old anomalous ЭСФ and probable re-exports; take N unique documents; analyse the whole batch and dry-run it once; create nomenclature with a shared GTIN guard so one product is not created twice across two ЭСФ in the same batch; create and verify each chain separately; post only after a separate confirmation.
One batch, one run
- A batch runs as ONE
--period YYYY-MMor--only-refs FILErun, not as a loop of--registration. The dry run of the whole batch lists every line of every ЭСФ, every card it would create (with--create-nomenclature) and every question, and the--apply --confirm <digest>writes exactly that batch: the cards first, before the first chain, then each chain. A loop of single-ЭСФ runs asks the same kind of question once per ЭСФ and creates a card in one run that the next ЭСФ needed too. - The first question of a batch is the missing nomenclature, as one list. Lines with
no card (
--create-nomenclaturenot given yet) and lines with two or more live cards (card-ambiguous: a choice among the candidates it names — never pick one for the accountant) go into one message, every ЭСФ and line named, before anything is written. When every line already has its card, there is no nomenclature question at all. After the «да», dry-run the same batch with--create-nomenclatureand--apply --confirmits digest; a planned card is not asked about again. - A single-ЭСФ run (
--registration) is for two cases only: a corrected ЭСФ (supersede-esf.pyand the corrected-ЭСФ section above), and an ЭСФ the batch did not take because its turnover date put it in a different period than the one you ran.
Each run of import-esf.py counts this, without reading the chat: the event
1c_esf_batch carries only numbers and closed codes — how the ЭСФ were selected, how
many, how many lines and planned cards, the line questions by code — plus how many dry
runs of this same batch ended with a nomenclature question (nomenclature_question_rounds).
The batch is named by a one-way key kept in the workspace; no registration number, name or
amount leaves it.
Stop conditions
Stop before writing when: the target base or organisation is not established; the recipient's БИН on the ЭСФ names an organisation of this base other than the one being written into; a duplicate registration or an existing chain is found; any ЭСФ in the selected batch falls outside the current period and the user did not ask for that period; supplier, contract, warehouse, accounts or operation kind are undetermined; the arithmetic does not balance; nomenclature or unit is ambiguous; a catalog record would have to be created without permission; a VAT rate is not matched to the catalog; a goods document is about to be built from a services template or vice versa; or you cannot prove all three links.
A clean dry run followed by a held --apply is not a bug
A first ЭСФ from a supplier with no posted chain of its own, and no contract this
base already holds, will show contract-unresolved and/or template-other-supplier
warnings. A plain --apply (no --accept-warnings) holds the write for exactly
this reason — read the warnings, check the borrowed accounts and VAT profile
against what this supplier's documents should use, then re-run with
--accept-warnings (or the specific --accept-warning <code> for each). That is
not required-unresolved in disguise, and it is not the class of defect this kit's
--create-nomenclature flag exists to prevent: a line this run is permitted and
about to create a catalog card for is already excused from required-unresolved,
identically on a dry run and on --apply, however many distinct nomenclature
values this base's posted history otherwise carries
(1c-esf-import-and-posting.md §0 #32).
Where knowledge about this goes
This page is the regulation. Do not copy it into workspaces. Writing it into each
workspace's knowledge/ folder by hand produces N copies that drift and cannot be
corrected together. Link to it instead; /help/1c-incoming-esf-import.md serves the
raw markdown.
What does belong in a workspace's knowledge/local/: the confirmed contracts
and per-supplier settings of that base, its stable document structure, its local
exceptions, the user's decisions about creating catalog records or posting, and
the numbers of documents already created. Never company names, GUIDs, БИН/ИИН,
base addresses or banking details from one base in another workspace's shared
notes.