A method for agency bookkeeping processing of electronic invoices with blockchain notarization

CN122573544APending Publication Date: 2026-08-14GANGU 8090 ENTERPRISE MANAGEMENT CONSULTING CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-06
Publication Date
2026-08-14

AI Technical Summary

Technical Problem

[0006]针对现有技术的不足,本发明提供了一种电子票据区块链存证的代理记账处理方法,解决了历史存证票据发生跨期突变时难以精确追溯资金波及份额并自动修复多级派生错账,以及明文账务存证易暴露底层财务数据隐私的问题

Benefits of technology

1、本发明通过将获取的电子票据状态向量映射为根节点,并在代理记账处理中根据派生业务生成子凭证节点计算边权重,建立了基础账务与衍生核算的底层关联拓扑。该方式解决了区块链存证中原始票据与多期核算数据颗粒度断层的问题,使得系统在面对数据变更时,能够依据确定的图结构准确量化源头基础金额对下游业务的波及份额。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122573544A_ABST
    Figure CN122573544A_ABST
Patent Text Reader

Abstract

This invention relates to the field of blockchain evidence storage technology and discloses a method for proxy accounting processing of electronic invoice blockchain evidence storage. The method includes: monitoring main chain nodes to obtain the state vector of the electronic invoice; mapping the normal state code to an initial accounting voucher as the root node, generating sub-voucher nodes and calculating edge weights based on proxy accounting derived business; when the state code undergoes a cross-period mutation, traversing the directed acyclic graph of voucher dependencies starting from the root node to locate the affected nodes; calculating the compensation amount based on the edge weights, generating compensation vouchers, aggregating them into a cascaded compensation matrix, and performing proxy accounting entry; performing a hash operation on the matrix, and writing the mapping relationship between the invoice identifier and the hash of the processing result into a sidechain. This invention can accurately trace the share affected by electronic invoice mutations, automatically correct derived errors in proxy accounting processing, and achieve blockchain evidence storage that protects the privacy of underlying data through sidechain writing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of blockchain evidence storage technology, specifically to an agency accounting processing method for blockchain evidence storage of electronic invoices. Background Technology

[0002] Blockchain-based electronic invoice storage refers to the irreversible and tamper-proof storage of original financial documents such as invoices and fiscal receipts using a distributed network. Outsourced accounting refers to professional agencies using these underlying documents to handle accounting tasks for client companies, including setting up accounts, daily bookkeeping, cost amortization, and year-end closing. With the advancement of tax supervision informatization, directly integrating the underlying state of blockchain-stored electronic invoices into the outsourced accounting system for compliant accounting processing has become a fundamental implementation requirement in the industry.

[0003] In existing routine processing applications, the bookkeeping agency system typically synchronizes the validity status of electronic invoices from the main chain nodes periodically via network interface, converts them into accounting vouchers, and enters them into the local general ledger database. At the end of each natural accounting period, the system performs derivative accounting operations such as raw material allocation or profit transfer in batches based on the total amount of original vouchers recorded in the period, thereby generating period-end reports and completing the financial closing operation for the current period.

[0004] This approach creates a data gap between the underlying independent original invoices and the upper-level period-end summary accounting. When historical electronic invoices on the main chain become invalid or undergo cross-period changes such as red-inking, traditional systems struggle to accurately trace and quantify the specific financial impact of these abnormal documents on subsequent multi-level derivative transactions. This makes it difficult for the system to automatically synchronize the underlying data with the local accounting system, requiring financial personnel to manually check and adjust errors period by period, which easily disrupts the trial balance of double-entry bookkeeping under complex chained business. Furthermore, if the modification details of local accounts are directly uploaded to the blockchain for audit consistency, the actual amounts of underlying accounts will be exposed to the network, leading to the leakage of core corporate financial privacy.

[0005] Therefore, this invention proposes an agency accounting processing method for electronic invoice blockchain notarization to address the shortcomings of existing technologies. Summary of the Invention

[0006] To address the shortcomings of existing technologies, this invention provides a proxy accounting processing method for blockchain-based electronic invoice storage, which solves the problems of difficulty in accurately tracing the share of funds affected and automatically correcting multi-level derived errors when historical invoices undergo sudden changes across periods, as well as the problem that plaintext accounting storage easily exposes the privacy of underlying financial data.

[0007] To achieve the above objectives, the present invention provides the following technical solution: a method for agency accounting processing of electronic invoices with blockchain notarization, comprising the following steps: Listen to the main chain node to obtain the state vector of the electronic ticket, the state vector containing the status code and the ticket identifier; When the status code is normal, the status vector is mapped to the initial accounting voucher and the initial accounting voucher is used as the root node of the voucher-dependent directed acyclic graph. Sub-voucher nodes are generated according to the agency accounting derived business, and the edge weights of the root node pointing to the sub-voucher nodes are calculated. When the status code undergoes a cross-period mutation, the credential dependency directed acyclic graph is traversed starting from the root node to locate the affected sub-credential node. The compensation amount for the affected sub-voucher node is calculated based on the edge weight, compensation vouchers for the affected sub-voucher node are generated based on the compensation amount, and the compensation vouchers are aggregated into a cascaded compensation matrix. The cascaded compensation matrix is ​​then recorded in the surrogate accounting system. A hash operation is performed on the cascaded compensation matrix to generate a processing result hash, and the mapping relationship between the ticket identifier and the processing result hash is written into the sidechain.

[0008] Preferably, the step of monitoring the main chain node to obtain the state vector of the electronic ticket includes: Extract the latest block height that the main chain node has synchronized and the main chain block height that contains the electronic ticket change transaction, and calculate the difference between the latest block height and the main chain block height; Compare and determine the relationship between the difference and the block confirmation depth threshold; When the difference is greater than or equal to the block confirmation depth threshold, it is determined that the transaction data has reached an irreversible final consensus, and the corresponding state vector is pushed into the business message queue to complete the acquisition of the state vector.

[0009] Preferably, the state vector further includes a block generation timestamp, a monetary attribute column vector, and a digest hash value.

[0010] Preferably, the step of mapping the state vector to the initial accounting voucher includes: Retrieve the preset accounting subject mapping matrix; Perform a logical multiplication operation between the accounting subject mapping matrix and the amount attribute column vector to output the initial accounting voucher.

[0011] Preferably, the step of calculating the edge weights from the root node to the sub-credential node includes: Obtain the total amount of current assets for similar accounting items and the amount consumed by the aforementioned bookkeeping derivative business; The quotient of the consumption quantity divided by the total quantity of assets in the current period is used as the edge weight.

[0012] Preferably, when the status code changes from normal to invalid or red-ink status, the cross-period condition determination logic is triggered. Extract the original accounting period of the initial accounting voucher corresponding to the electronic invoice, and obtain the current natural accounting period; When the original accounting period is earlier than the natural accounting period, the status code is determined to have undergone a cross-period change.

[0013] Preferably, the step of traversing the directed acyclic graph of credential dependencies starting from the root node to locate the affected sub-credential nodes includes: Apply data version optimistic locking to the local graph topology containing the root node; Push the root node that has undergone intertemporal mutation onto the traversal stack, and call the depth-first search graph traversal algorithm to search down to the next level node along the directed edges; All visited sub-credential nodes are identified as affected sub-credential nodes and added to the affected node set. The complete traversal path sequence from the root node to the affected sub-credential nodes and the edge weights of each directed edge on the traversal path are extracted.

[0014] Preferably, the step of calculating the compensation amount for the affected sub-certificate node based on the edge weight includes: Based on the status code type of the intertemporal mutation, determine the source mutation amount of the initial accounting voucher; Calculate the product of the weights of all directed edges on the traversal path from the root node to the affected sub-credential node; The compensation amount for the affected sub-certificate node is calculated by multiplying the amount of the source mutation by the product.

[0015] Preferably, the step of generating compensation vouchers for the affected sub-voucher nodes based on the compensation amount, aggregating the compensation vouchers into a cascaded compensation matrix, and performing proxy accounting on the cascaded compensation matrix includes: All compensation vouchers generated in the set of affected nodes are arranged in descending order according to the time sequence of business occurrence and the depth of graph topology, and then assembled into the cascaded compensation matrix. The cascaded compensation matrix is ​​parsed into a relational database batch insert statement. The corrected data is submitted to the general ledger and subsidiary ledger tables of the current accounting period in a unified database transaction to complete the proxy accounting entry. After successful entry, the data version optimistic lock is released.

[0016] Preferably, the step of performing a hash operation on the cascaded compensation matrix to generate a processing result hash, and writing the mapping relationship between the ticket identifier and the processing result hash into the sidechain includes: The concatenated compensation matrix is ​​converted into a standard byte stream and input into a preset one-way cryptographic hash function to calculate and generate the hash of the processing result; Using the ticket identifier as the query index key and the hash of the processing result as the evidence storage payload, an on-chain transaction package with the digital signature of the current operating node's private key is assembled. The on-chain transaction package is broadcast to the consensus node network of the sidechain via a cross-chain gateway for block confirmation and persistent storage.

[0017] This invention provides a method for agency accounting processing of electronic invoices with blockchain notarization. It has the following beneficial effects: 1. This invention establishes a fundamental topology linking basic accounting and derivative accounting by mapping the acquired electronic invoice state vector to a root node and calculating edge weights based on the sub-voucher nodes generated from derived business transactions during the agency accounting process. This approach solves the problem of granularity gaps between original invoices and multi-period accounting data in blockchain notarization, enabling the system to accurately quantify the impact of the source base amount on downstream business when facing data changes, based on a defined graph structure.

[0018] 2. This invention completes the closed loop of cross-period accounting repair by traversing a directed acyclic graph when a cross-period change in the status of electronic invoices is detected, calculating compensation amounts based on edge weights, aggregating them into a cascaded compensation matrix, and performing proxy accounting processing for recording. This mechanism solves the problem of erroneous carry-forward based on invalid vouchers in the early stage, ensuring that changes in the underlying data are synchronized with the local financial ledger, and providing an accurate data foundation that meets trial balance constraints for subsequent blockchain evidence storage.

[0019] 3. This invention generates a processing result hash by performing a hash operation on the cascaded compensation matrix, and writes the mapping relationship between the electronic invoice identifier and the processing result hash into the sidechain, establishing a dual-chain collaborative data alignment mechanism. This method does not require the plaintext exposure of the actual financial transactions when performing blockchain notarization, protecting the privacy of the underlying accounting records. At the same time, it provides reliable evidence for state rollback operations for the proxy accounting system when facing main chain block reorganization anomalies. Attached Figure Description

[0020] Figure 1 This is a flowchart of an agency accounting processing method for electronic invoice blockchain storage according to the present invention; Figure 2 This is an architecture diagram of an agency accounting processing system for electronic invoice blockchain storage according to the present invention; Figure 3 This is a flowchart of the inter-period mutation traversal addressing process of the present invention; Figure 4 This is a schematic diagram of the data topology for agency accounting processing in a specific application embodiment of the present invention.

[0021] Among them, 100 is the status monitoring module; 200 is the credential mapping module; 300 is the mutation location module; 400 is the compensation calculation module; and 500 is the hash anchoring module. Detailed Implementation

[0022] The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0023] Please see the appendix Figure 1 This invention provides a method for agency accounting processing of electronic invoice blockchain notarization, including the following steps: S1. Listen to the main chain node to obtain the state vector of the electronic ticket. The state vector contains the status code and the ticket identifier. S2. When the status code is normal, map the status vector to the initial accounting voucher and use it as the root node of the voucher-dependent directed acyclic graph. Generate sub-voucher nodes according to the agency accounting derived business and calculate the edge weights from the root node to the sub-voucher nodes. S3. When a status code undergoes a cross-period mutation, traverse the directed acyclic graph of voucher dependencies starting from the root node to locate the affected sub-voucher nodes. S4. Calculate the compensation amount of the sub-voucher node based on the edge weight, generate the compensation voucher of the sub-voucher node based on the compensation amount and aggregate it into a cascaded compensation matrix, and perform proxy accounting on the cascaded compensation matrix. S5. Perform a hash operation on the cascaded compensation matrix to generate a processing result hash, and write the mapping relationship between the ticket identifier and the processing result hash into the side chain.

[0024] Please see the appendix Figure 2 This invention provides an agency accounting processing system for electronic invoice blockchain storage, comprising: The status monitoring module 100 is used to monitor the status vector of the main chain node when it obtains the electronic ticket. The status vector contains the status code and the ticket identifier. The voucher mapping module 200 is used to map the state vector to the initial accounting voucher when the status code is normal and use it as the root node of the voucher-dependent directed acyclic graph. It generates sub-voucher nodes according to the agency accounting derived business and calculates the edge weights from the root node to the sub-voucher nodes. The mutation location module 300 is used to locate the affected sub-certificate nodes by traversing the directed acyclic graph of certificate dependencies starting from the root node when a status code undergoes a cross-period mutation. The compensation calculation module 400 is used to calculate the compensation amount of the sub-voucher node based on the edge weight, generate the compensation voucher of the sub-voucher node based on the compensation amount and aggregate it into a cascaded compensation matrix, and perform proxy accounting on the cascaded compensation matrix. The hash anchoring module 500 is used to perform hash operations on the cascaded compensation matrix to generate the processing result hash, and writes the mapping relationship between the ticket identifier and the processing result hash into the side chain.

[0025] The electronic invoice blockchain notarization proxy accounting processing method and proxy accounting processing system of the present invention belong to the same inventive concept. Each logical module in the proxy accounting processing system is configured to execute the corresponding steps in the proxy accounting processing method. Specifically, the state monitoring module 100 in the proxy accounting processing system is used to execute step S1 to monitor the main chain node and obtain the state vector of the electronic invoice; the voucher mapping module 200 is used to execute step S2 to complete the state vector mapping and the construction of the voucher-dependent directed acyclic graph and the calculation of edge weights; the mutation location module 300 is used to execute step S3 to traverse the graph structure and locate the affected sub-voucher nodes when a cross-period mutation occurs in the state code; the compensation calculation module 400 is used to execute step S4 to calculate the compensation amount, generate compensation vouchers, and execute the proxy accounting entry of the cascaded compensation matrix; the hash anchoring module 500 is used to execute step S5 to generate the processing result hash and write the mapping relationship to the side chain. The proxy accounting processing system relies on the serialized interactive operation of each module to achieve a computational closed loop from data acquisition, graph structure calculation, voucher cancellation to cross-chain writing of the processing result.

[0026] See attached document Figure 1 and Figure 2 In this embodiment, the specific implementation of step S1 is performed through the following sub-steps: S101. In this embodiment, the main chain refers to the underlying blockchain network maintained by tax authorities or industry alliances, used for distributed ledger and tamper-proof storage of electronic invoices and fiscal receipts; the main chain node is the physical server or cloud instance that connects to the main chain and synchronizes the ledger data across the entire network. The state vector is a standardized mathematical expression that abstracts the originally unstructured or semi-structured electronic receipt file into a single, standardized mathematical expression containing only the core financial flow elements, representing the business validity and financial attributes of the receipt at a specific point in time.

[0027] A network connection is established with the main chain node storing electronic invoices in read-only mode via a remote procedure call (RPC) interface. The handshake authentication and communication protocol configuration of the RPC interface can be implemented by those skilled in the art based on existing blockchain network communication standards; these are well-known technologies in the field and will not be elaborated upon here. After the connection is established, the proxy ledger processing system continuously polls the smart contract event logs on the main chain node. When it detects a transaction involving the on-chain recording or status update of electronic invoices, it extracts the corresponding original transaction data block.

[0028] S102. As a preferred method, the extracted raw transaction data blocks are parsed to separate the underlying network protocol data and extract the structured elements related to the core business. The data processing method described above for parsing and extracting business elements from block transaction data is a well-known technology in this field and will not be elaborated further here. The agency accounting processing system further transforms the elements into discrete state vectors that support subsequent graph operations. To achieve accurate processing of agency accounting business in time series, a state vector is defined. for: ; in, The invoice identifier is specifically a combination of a unique invoice code and an invoice number issued by the tax authorities. Represents the timestamp of the block that contains the transaction. The column vector representing the monetary attribute consists of the pre-tax amount, tax amount, and total amount including tax on the invoice. The status code represents the current objective status of the electronic invoice using a fixed-format enumeration value. For example, 01 indicates a normal status, 02 indicates a voided status (a voided status means that the electronic invoice is declared invalid at the source, and its business economic substance is completely erased, equivalent to the underlying transaction never occurring), and 03 indicates a reverse status (a reverse status means that the electronic invoice cannot be directly erased because it has crossed the financial settlement cycle or undergone actual business changes, and can only be fully or partially reversed by issuing a document with a negative amount, and its complete historical occurrence and correction trajectory is still retained in the accounting system). This represents the digest hash value output by performing a secure hash algorithm on the original electronic invoice source file. It serves as underlying evidence and is used to verify the integrity of the original invoice file during sidechain auditing.

[0029] S103. After obtaining the initial state vector, it is necessary to address the data consistency issues unique to distributed networks. Main chain nodes may experience temporary forks and block reorganizations due to network latency or computing power contention. If financial entries are triggered directly based on the latest block at the end of the chain, a dirty read error may occur because that block is subsequently discarded by the network, resulting in unchanged underlying documents but reversed local financial ledger entries. To eliminate these technical risks, a pre-set block confirmation depth threshold is implemented. The specific range of the block confirmation depth threshold is determined by the consensus algorithm used by the main chain nodes. When the main chain nodes adopt a practical Byzantine fault tolerance mechanism... The value can be 1 or 2, when the main chain node uses the proof-of-work mechanism. Set to an integer greater than or equal to 6. The proxy ledger processing system extracts the latest block height that has been synchronized by the main chain node. And extract the main chain block height containing the electronic invoice change transaction. Here, block height refers to the sequence number of a specific block in the blockchain ledger, arranged sequentially according to time. It is used to represent the absolute position of the block in the entire chain. The difference in block height is calculated according to the following formula. : ; After calculating the difference, compare and judge the difference. Block confirmation depth threshold The size relationship.

[0030] S104, when the difference Greater than or equal to the block confirmation depth threshold At this point, it is determined that the transaction data has reached an irreversible final consensus in the main chain network. The corresponding state vector is then... The message is pushed into the business message queue, thus completing the acquisition of the state vector. If the difference is determined... Less than the block confirmation depth threshold If the state vector of the transaction data is suspended in memory, the suspension waiting time of the state vector is recorded synchronously. Before the suspension waiting time reaches a preset time threshold (e.g., 600 seconds), the proxy accounting system continues to monitor the block height growth of the main chain nodes; if the suspension waiting time reaches the preset time threshold and the difference is less than 600 seconds, the system will continue to monitor the block height growth of the main chain nodes. If the size judgment condition is still not met, or if the proxy accounting system detects a block rollback event for the transaction issued by the main chain node, the suspended state vector is discarded from memory to avoid memory leaks and dirty reads in the proxy accounting system. Memory leaks refer to the failure phenomenon where suspended data cannot be released for a long time, causing the available running memory of the proxy accounting system to be exhausted. Dirty reads refer to the proxy accounting system executing incorrect accounting voucher processing based on the invalid voucher status that was eventually revoked by the main chain network.

[0031] See attached document Figure 1 and Figure 2 In this embodiment, the specific implementation of step S2 is performed through the following sub-steps: S201. Parse the state vector read from the business message queue and determine its contained status code. When the status code is normal, it indicates that the electronic invoice is legal and valid on the main chain and has not yet been voided or reversed, meeting the conditions for generating local accounting data. At this time, extract the amount attribute column vector from the state vector. This amount attribute column vector is denoted as... It contains discrete numerical elements such as the amount excluding tax, the tax amount, and the total amount including tax from the original data of the invoice.

[0032] S202. To convert unstructured data into standard financial vouchers, the bookkeeping processing system retrieves a pre-set accounting subject mapping matrix. In this embodiment, the pre-set accounting subject mapping matrix is ​​a two-dimensional data table based on the unified accounting system. The setting of debit and credit mapping relationships according to the unified accounting system is a well-known technique in the field and will not be elaborated further here. The row dimension of this two-dimensional data table corresponds to the debit and credit account structure of the target accounting voucher, and the column dimension corresponds to the amount attributes in the state vector. The matrix elements take values ​​of 1, -1, or 0 to represent the flow of funds and the debit / credit relationship. A logical multiplication operation is performed between the accounting subject mapping matrix and the amount attribute column vector to output the initial accounting voucher. The initial accounting voucher refers to a standardized basic accounting unit in the bookkeeping processing system that records the occurrence of a single economic transaction of an enterprise. The initial accounting voucher is denoted as... Its calculation process follows the matrix multiplication model as follows: ; in, This represents a pre-defined accounting subject mapping matrix. Through the above calculations, unstructured electronic invoice data is deterministically transformed into structured financial data that conforms to the principles of double-entry bookkeeping.

[0033] S203. After completing the matrix operations, the state vector is mapped to the initial accounting voucher and used as the root node of the voucher-dependent directed acyclic graph. Specifically, the agency accounting processing system will generate the initial accounting voucher... The data is persistently stored in a graph database. A graph database is a low-level data management unit specifically designed for storing entities and the relationships between them. The voucher-dependent directed acyclic graph (DAG) is constructed within the graph database, using vertices and unidirectional edges to describe the flow of financial data across different accounting periods without forming closed loops. The root node is an independent vertex in the DAG that has no predecessor node and serves only as the initial source of funds or costs. This root node is denoted as... .

[0034] S204. Because accounting agencies typically only obtain summary invoices and period-end statements from client companies, they struggle to access detailed physical inventory data from the company's internal systems. This gap in data granularity leads to a loss of precise correspondence between underlying original invoices and upper-level cost accounting. To address this issue, as a preferred approach, multiple root nodes for similar accounting items are aggregated into virtual batch summary nodes within the current accounting period. Multiple root nodes with the same material attributes or account codes are then... In the logical topology, they are forced to converge into a single total node, denoted as the virtual batch summary node. .

[0035] S205. During the daily accounting cycle, the bookkeeping processing system generates sub-voucher nodes based on bookkeeping derivative transactions. Bookkeeping derivative transactions refer to derivative accounting actions such as cost allocation, depreciation accrual, or tax transfer automatically triggered at the end of the month or period based on the original accounting data; a sub-voucher node is a new voucher record vertex generated and stored in the graph database based on the allocated or transferred amount when executing bookkeeping derivative transactions. The specific generation process is as follows: the bookkeeping processing system reads the total amount in the virtual batch summary node, calculates the amount to be transferred in the current period based on the preset consumption ratio (e.g., the percentage of raw materials used in production to the total raw material inventory in the current period), and assembles the amount to be transferred along with the corresponding target accounting subject elements into a new voucher data block, instantiating it as a sub-voucher node. This sub-voucher node is denoted as... When generating sub-voucher nodes during the execution of agency bookkeeping derivative business, a directed edge is established from a virtual batch summary node to the sub-voucher node to represent the direction of cost or fund outflow.

[0036] S206. To quantify the impact of the initial base amount on downstream business, the bookkeeping processing system calculates the edge weights of the root node pointing to the sub-voucher node. It obtains the total amount of assets in the current period and the consumption quantity of bookkeeping-derived transactions. Let the total amount of assets for this type of accounting item in the current period be... (in The quantity transferred or consumed in this bookkeeping agency derivative transaction was... The quotient of the consumption quantity divided by the total quantity of assets in the current period is used as the edge weight. This edge weight is denoted as... The calculation formula is as follows: ; The edge weights are calculated and dynamically assigned based on this formula. At the macro-statistical level, the mathematical concept of weighted average was used to establish the relationship of capital ratio decay between the source data node and subsequent derived data nodes.

[0037] See attached document Figures 1-3 In this embodiment, step S3 is specifically implemented through the following sub-steps: S301. During the continuous monitoring and processing of electronic invoice status, the agency accounting system parses the status code changes of newly received status vectors. When the status code changes from normal to void or reversed, the cross-period condition judgment logic is triggered. The original accounting period of the initial accounting voucher corresponding to the electronic invoice is extracted and recorded as follows: In this embodiment, an accounting period refers to a continuous and equal relative time period artificially divided in financial accounting for closing accounts and preparing reports, usually in calendar months. Simultaneously, the current natural accounting period of the bookkeeping agency system is obtained and denoted as... Because bookkeeping services require period-end closing and financial shut-off at the end of each accounting period, the bookkeeping processing system determines the relationship between the two by comparing period sequence numbers. If the conditions are met... This indicates that the original accounting period for the invoice has been closed, and according to financial compliance standards, the original voucher cannot be directly modified or deleted. At this point, the bookkeeping system determines that the status code has undergone a cross-period change.

[0038] S302. After determining that a cross-period mutation has occurred in the status code, to prevent the node data in the graph database from being tampered with by other parallel derived businesses during subsequent source tracing traversal, thus causing a non-repeatable read error, the proxy accounting processing system applies a data version optimistic lock to the local graph topology containing the root node. For the configuration and version number verification mechanism of the data version optimistic lock, those skilled in the art can use existing database concurrency control technologies, which are well-known in the field and will not be elaborated here. As a preferred approach, after successfully acquiring the optimistic lock, the proxy accounting processing system serializes the connected subgraph structure where the current root node is located and the associated financial account balance status, generates a local state snapshot, and persists it in the system database, thereby providing underlying data support for handling abnormal rollbacks when extreme block reorganizations occur in the main chain.

[0039] S303. After completing concurrency control and saving the state snapshot, the agency accounting system traverses the directed acyclic graph (DAG) of voucher dependencies, starting from the root node. The agency accounting system calls the depth-first search graph traversal algorithm to perform source addressing operations. The specific code-level implementation of the depth-first search graph traversal algorithm can be written by those skilled in the art based on standard data structure knowledge; it is a well-known technology in this field and will not be elaborated here. Specifically, the agency accounting system pushes the root node that has undergone a mutation onto the traversal stack and searches downwards along the directed edges established in the aforementioned steps. Since the directed edges in the DAG represent the exact physical flow of funds or cost allocation, when the search path reaches the aforementioned virtual batch summary node, the depth-first search graph traversal algorithm directly penetrates this summary node and continues to explore deeper-level derived accounting nodes along the directed edges.

[0040] S304. During the traversal and addressing process, the affected sub-document nodes are located. Affected sub-document nodes refer to derivative accounting nodes where, in business logic, the cost amortization or carry-over amount on which the source electronic invoice is invalidated or reversed, resulting in a loss of legal original voucher support and thus causing financial value deviations. Based on the aforementioned directed edges representing the physical attributes of fund flows, all nodes visited along the path reached by the depth-first search graph traversal algorithm are determined to be affected sub-document nodes. When the traversal algorithm travels along the directed edges and reaches a leaf node with an out-degree of zero, it indicates that the fund flow chain has reached its end. The algorithm automatically terminates and backtracks on this branch, thus avoiding the algorithm from falling into a logical dead zone. The agency accounting processing system identifies each visited sub-document node and adds it to the affected node set. This affected node set is denoted as... Simultaneously, the bookkeeping system extracts and records the complete traversal path sequence from the root node to each affected sub-voucher node, as well as the edge weights of the directed edges along that path. This includes the set of affected nodes. The associated edge weight sequence accurately defines the scope of all historical cost amortization and carry-over vouchers affected across multiple accounting periods after the source electronic invoice is voided or reversed.

[0041] See attached document Figure 1 and Figure 2 In this embodiment, step S4 is specifically implemented through the following sub-steps: S401. During continuous monitoring and processing, the agency accounting system extracts the baseline value of changes caused by the source electronic invoices. Based on the status code type of the inter-period change, the agency accounting system determines the source change amount of the original initial accounting voucher. The source change amount refers to the most original basic value directly caused by the change in the status of the main chain electronic invoice, which needs to be reversed or adjusted in the financial accounting system. Let the recorded amount in the original initial accounting voucher corresponding to the core business account (e.g., the total amount excluding tax) be... When the status code changes to void or full reversal, it indicates that the economic substance of the original transaction has been eliminated, and the amount of the source change is recorded as follows. Its value is When the status code changes to a partial red overprint, The value is the negative of the actual red-ink invoice difference (which is obtained by parsing the red-ink invoice amount in the latest transaction data of the main chain).

[0042] S402. After determining the source of the change, the agency accounting system calculates the compensation amount for the sub-document node based on the edge weights. In this embodiment, the compensation amount refers to the difference that needs to be reduced or increased in the current period to correct the erroneous carry-over based on invalid original documents in the previous period. The agency accounting system retrieves the set of affected nodes and their associated edge weight sequence extracted in step S3. For any affected sub-document node, the system calculates the product of all directed edge weights on the traversal path from the root node to that sub-document node. The source mutation amount is then calculated. Multiplying by the product of the products, the compensation amount corresponding to the sub-voucher node is calculated, and this compensation amount is denoted as... The calculation formula is as follows: ; in, It represents the depth of the directed graph addressing path from the root node to the specific sub-credential node, i.e., the number of derived business levels traversed. Indicates the th ... The edge weights of a directed edge are: Values ​​range from 1 to The integers. Through the above multiplication operations, the impact of basic funding errors on the multi-level business amortization process is accurately restored at the mathematical level, ensuring the quantitative accuracy of the impact of changes in the underlying data on the top-level accounting results.

[0043] S403. After completing the numerical calculation, the bookkeeping system generates compensation vouchers for the sub-voucher nodes based on the compensation amount. A compensation voucher is a formal financial accounting voucher generated within the current active accounting period, specifically used to record the aforementioned compensation amount in accordance with accounting error correction standards. Since the accounting period in which the original cross-period voucher was located has been closed, the bookkeeping system directly instantiates a new data block within the current natural accounting period. As a preferred method, the bookkeeping system reads the debit and credit accounts of the original affected sub-voucher node, maintaining the original business logic direction, and calculates the compensation amount in negative form. Enter the corresponding amount field to generate a red-ink reversal compensation voucher, denoted as... .

[0044] S404. To ensure the atomicity of accounting processing and satisfy the trial balance constraint of double-entry bookkeeping—that every debit must have a corresponding credit, and debits must equal credits—the outsourced accounting system aggregates the generated compensation vouchers into a cascading compensation matrix. A cascading compensation matrix is ​​a two-dimensional data structure specifically designed for batch encapsulating interdependent double-entry bookkeeping elements. Because the cancellation of a single invoice often triggers a chain reaction involving month-end closing, cost allocation, and profit transfer, multiple compensation vouchers are generated. The outsourced accounting system will aggregate all compensation vouchers generated in the affected node set. Arrange the transactions in descending order of their chronological order and graph topology depth, and assemble them into a cascaded compensation matrix. The cascaded compensation matrix is ​​denoted as... The row vectors of the cascaded compensation matrix represent each independent derived compensation transaction, and the column vectors represent the corresponding voucher number, summary, debit account code, credit account code, and compensation amount.

[0045] S405. After assembly and sorting, the bookkeeping processing system executes the bookkeeping posting of the cascading compensation matrix. Bookkeeping posting refers to the persistent transaction operation of formally writing the voucher data, which has undergone trial balance verification, into the underlying database of the bookkeeping processing system's accounting system. The bookkeeping processing system will execute the cascading compensation matrix... Parsed as standard relational database batch insert statements, all cascading corrected data are atomically committed to the general ledger and subsidiary ledger tables of the current accounting period within a unified database transaction. For the rollback and commit mechanism of database transactions, those skilled in the art can use general relational database transaction control statements for configuration, which is well-known technology in the field and will not be elaborated further here. After successful posting, the agency accounting processing system releases the optimistic lock on the data version previously applied to the graph database and marks the data status of the corresponding affected nodes as corrected, thereby completing the business loop of automatically blocking the impact of cross-period bill mutations and repairing accounts.

[0046] See attached document Figure 1 and Figure 2 In this embodiment, step S5 is specifically implemented through the following sub-steps: S501. When the bookkeeping system completes the cascading accounting modification operation in the local database, it performs a hash operation on the cascading compensation matrix to generate a processing result hash. The processing result hash refers to the fixed-length hash value of the accounting correction operation made by the bookkeeping system for a specific inter-period anomaly, which is used to prove the authenticity of the accounting processing without exposing the detailed accounts. Considering that the cascading compensation matrix encapsulates complete inter-period correction business data and sensitive financial account transactions, direct transmission of the raw data in a distributed network would lead to the leakage of financial privacy. Therefore, the bookkeeping system retrieves the cascading compensation matrix generated in the aforementioned steps, converts its various dimension parameters into a standard byte stream according to a fixed character encoding standard, and inputs it into a preset one-way cryptographic hash function for calculation. For the specific call to the cryptographic hash function and the byte stream serialization mechanism, those skilled in the art can refer to standard cryptographic algorithm libraries for implementation, which are well-known technologies in the field and will not be elaborated here. Let the serialization function of the conversion process be... The cryptographic hash function is The cascaded compensation matrix is The hash of the generated processing result is denoted as... The calculation formula is as follows: ; Through the above calculations, the bookkeeping system reduces the dimensionality of the high-dimensional financial correction matrix data into a fixed-length string with global uniqueness and irreversibility.

[0047] S502. Based on the generated processing result hash, to achieve tamper-proof auditing of the agency accounting process for electronic invoice blockchain storage, the agency accounting system writes the mapping relationship between the invoice identifier and the processing result hash into a sidechain. In this embodiment, the sidechain refers to an auxiliary distributed ledger network that is logically parallel to the aforementioned tax main chain, specifically used as an irreversible audit storage for storing the operation logs of the agency accounting system; the mapping relationship refers to the association identifier established by key-value pairs between the original faulty invoices on the main chain and the locally derived compensation processing actions. The agency accounting system extracts the invoice identifier obtained in step S1. The ticket identifier is used as the query index key to process the result hash. As the corresponding evidence storage payload, it is assembled into an on-chain transaction package with the digital signature of the current operating node's private key.

[0048] S503. The proxy ledger processing system broadcasts the assembled on-chain transaction package to the consensus node network of the sidechain via a cross-chain gateway for block confirmation and persistent storage. When the transaction package is included in a block by a sidechain node, it indicates that a cross-chain anchor has been established between the original abnormal ticket on the main chain and the derived compensation result of the local proxy ledger processing system. As a preferred approach, if a block reorganization occurs on the main chain network during subsequent operation, causing the electronic ticket transaction originally used as the basis for cross-period determination to be rolled back on-chain, the listening component of the proxy ledger processing system, upon detecting the anomaly, will initiate a smart contract query operation to the sidechain using the affected main chain ticket identifier as a clue.

[0049] S504. Based on the query results returned by the sidechain, the agency accounting system extracts and verifies the hash of the executed processing results. Based on the hash of the processing result, the agency accounting system can quickly locate the specific cascading compensation matrix generated for this error state in the local database. The system also generates corresponding operation and transaction logs, which triggers the local accounting system's abnormal rollback mechanism, restoring the financial data of the bookkeeping processing system to a usable snapshot version before the compensation action occurred. By constructing a dual-chain architecture with the main chain monitoring the source and the side chain anchoring the result, this embodiment enables the bookkeeping processing system to handle underlying network consensus fluctuations and achieve cross-period accounting blockade and repair without changing the operating rules of the external tax main chain.

[0050] Specific application examples: Taking manufacturing companies as an example, the specific steps of the outsourced accounting system for executing the electronic invoice blockchain-based accounting processing method are as follows: During the natural accounting period (denoted as Within January, the agency accounting processing system executes step S1, monitoring the main chain node to obtain the status vector of the electronic invoice. The agency accounting processing system parses the status vector, obtains the invoice identifier, and determines that the status code contained in the status vector is normal.

[0051] In step S2, the bookkeeping processing system extracts the amount attribute column vector from the state vector, retrieves the preset accounting subject mapping matrix, performs logical multiplication, maps the state vector to an initial accounting voucher, and stores it as the root node of the directed acyclic graph of voucher dependencies in the graph database. The recorded entry amount for this initial accounting voucher is 10,000 yuan, corresponding to a raw material procurement transaction. (See [reference]). Figure 4 The bookkeeping processing system generates a rectangular entity with a solid border at the top of the graph to represent the root node. At the end of January, the bookkeeping processing system generates sub-voucher nodes based on the bookkeeping-derived business. Specifically, the bookkeeping processing system obtains the total number of assets for the current period as 10,000 units and the production consumption as 4,000 units, and calculates the edge weight from the root node to the sub-voucher node as 0.4 based on their quotient. The bookkeeping processing system generates a sub-voucher node with an amount of 4,000 yuan and establishes a directed edge from the root node to this sub-voucher node in the voucher-dependent directed acyclic graph, as shown below. Figure 4 As shown, the system derives sub-credential nodes marked with solid-line circles and establishes directed connections through solid-line arrows, assigning weights to these connections to represent edge weights of 0.4.

[0052] When the system runs into a subsequent natural accounting period (e.g., March, the current natural accounting period) When updated to March, the bookkeeping processing system executes step S3. The bookkeeping processing system detects the main chain node update, and the status code of the aforementioned electronic invoice changes to void. The bookkeeping processing system then extracts the original accounting period (denoted as...). (for January), the comparison confirms that the conditions are met. The system determines that a status code has undergone a cross-period mutation based on the given conditions. The agency accounting system applies a data version optimistic lock to the local graph topology containing the root node. Then, it traverses the directed acyclic graph of voucher dependencies starting from the root node. The agency accounting system calls a depth-first search graph traversal algorithm to locate the affected sub-voucher nodes along the directed edges, adds the sub-voucher nodes generated at the end of January to the set of affected nodes, and records the depth of the traversal path (denoted as ). ) is 1 and the corresponding edge weight sequence.

[0053] In step S4, since the status code has changed to invalid, the bookkeeping processing system determines the source change amount of the original initial accounting voucher (denoted as...). The value is -10,000 yuan (i.e.) The bookkeeping system calculates the compensation amount for sub-voucher nodes based on edge weights. For the sub-voucher node in the affected node set, the product of the weights of all directed edges along the traversal path is calculated (because...). If the initial value is 1, the product is 0.4. Multiply the source mutation amount by this product to calculate the compensation amount for the sub-certificate node (denoted as ). The amount is -4000 yuan. The agency accounting system generates compensation vouchers for sub-voucher nodes based on the compensation amount and aggregates them into a cascaded compensation matrix. This involves arranging compensation vouchers with negative compensation amounts in chronological order and assembling them into a cascaded compensation matrix. Finally, the agency accounting system executes agency accounting entries on the cascaded compensation matrix, releases the data version optimistic lock after submitting a unified database transaction, and marks the data status of the corresponding node as corrected. Figure 4 As shown at the bottom, the system further derives rectangular entities with dashed borders to represent compensation vouchers for the addressed sub-voucher nodes. The business actions of cascading compensation matrix aggregation and fund repatriation logic are reflected by dashed directional arrows.

[0054] After the transaction is recorded, the proxy accounting system executes step S5. The proxy accounting system performs a hash operation on the cascaded compensation matrix to generate a processing result hash; that is, it converts the cascaded compensation matrix into a standard byte stream and inputs it into a one-way cryptographic hash function to obtain a fixed-length string. Subsequently, the proxy accounting system extracts the invoice identifier obtained in step S1 as a query index key and writes the mapping relationship between the invoice identifier and the processing result hash into the sidechain. This is then broadcast to the consensus node network of the sidechain via a cross-chain gateway for persistent storage, completing the proxy accounting processing for electronic invoice blockchain notarization.

[0055] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A method for agency accounting processing of electronic invoices with blockchain notarization, characterized in that, Includes the following steps: Listen to the main chain node to obtain the state vector of the electronic ticket, the state vector containing the status code and the ticket identifier; When the status code is normal, the status vector is mapped to the initial accounting voucher and the initial accounting voucher is used as the root node of the voucher-dependent directed acyclic graph. Sub-voucher nodes are generated according to the agency accounting derived business, and the edge weights of the root node pointing to the sub-voucher nodes are calculated. When the status code undergoes a cross-period mutation, the credential dependency directed acyclic graph is traversed starting from the root node to locate the affected sub-credential node. The compensation amount for the affected sub-voucher node is calculated based on the edge weight, compensation vouchers for the affected sub-voucher node are generated based on the compensation amount, and the compensation vouchers are aggregated into a cascaded compensation matrix. The cascaded compensation matrix is ​​then recorded in the surrogate accounting system. A hash operation is performed on the cascaded compensation matrix to generate a processing result hash, and the mapping relationship between the ticket identifier and the processing result hash is written into the sidechain.

2. The method for agency accounting processing of electronic invoice blockchain notarization according to claim 1, characterized in that, The steps for monitoring the main chain node to obtain the state vector of the electronic ticket include: Extract the latest block height that the main chain node has synchronized and the main chain block height that contains the electronic ticket change transaction, and calculate the difference between the latest block height and the main chain block height; Compare and determine the relationship between the difference and the block confirmation depth threshold; When the difference is greater than or equal to the block confirmation depth threshold, it is determined that the transaction data has reached an irreversible final consensus, and the corresponding state vector is pushed into the business message queue to complete the acquisition of the state vector.

3. The method for agency accounting processing of electronic invoice blockchain notarization according to claim 1, characterized in that, The state vector also includes a block generation timestamp, a monetary attribute column vector, and a digest hash value.

4. The method for agency accounting processing of electronic invoice blockchain notarization according to claim 3, characterized in that, The step of mapping the state vector to the initial accounting voucher includes: Retrieve the preset accounting subject mapping matrix; Perform a logical multiplication operation between the accounting subject mapping matrix and the amount attribute column vector to output the initial accounting voucher.

5. The method for agency accounting processing of electronic invoice blockchain notarization according to claim 1, characterized in that, The step of calculating the edge weights from the root node to the sub-credential node includes: Obtain the total amount of current assets for similar accounting items and the amount consumed by the aforementioned bookkeeping derivative business; The quotient of the consumption quantity divided by the total quantity of assets in the current period is used as the edge weight.

6. The method for agency accounting processing of electronic invoice blockchain notarization according to claim 1, characterized in that, When the status code changes from normal to invalid or red-over status, the inter-period condition determination logic is triggered. Extract the original accounting period of the initial accounting voucher corresponding to the electronic invoice, and obtain the current natural accounting period; When the original accounting period is earlier than the natural accounting period, the status code is determined to have undergone a cross-period change.

7. The method for agency accounting processing of electronic invoice blockchain notarization according to claim 6, characterized in that, The step of traversing the directed acyclic graph of credential dependencies starting from the root node to locate the affected child credential nodes includes: Apply data version optimistic locking to the local graph topology containing the root node; Push the root node that has undergone intertemporal mutation onto the traversal stack, and call the depth-first search graph traversal algorithm to search down to the next level node along the directed edges; All visited sub-credential nodes are identified as affected sub-credential nodes and added to the affected node set. The complete traversal path sequence from the root node to the affected sub-credential nodes and the edge weights of each directed edge on the traversal path are extracted.

8. The method for agency accounting processing of electronic invoice blockchain notarization according to claim 7, characterized in that, The step of calculating the compensation amount for the affected sub-certificate node based on the edge weight includes: Based on the status code type of the intertemporal mutation, determine the source mutation amount of the initial accounting voucher; Calculate the product of the weights of all directed edges on the traversal path from the root node to the affected sub-credential node; The compensation amount for the affected sub-certificate node is calculated by multiplying the amount of the source mutation by the product.

9. The method for agency accounting processing of electronic invoice blockchain notarization according to claim 8, characterized in that, The steps of generating compensation vouchers for the affected sub-voucher nodes based on the compensation amount, aggregating the compensation vouchers into a cascaded compensation matrix, and performing proxy accounting on the cascaded compensation matrix include: All compensation vouchers generated in the set of affected nodes are arranged in descending order according to the time sequence of business occurrence and the depth of graph topology, and then assembled into the cascaded compensation matrix. The cascaded compensation matrix is ​​parsed into a relational database batch insert statement. The corrected data is submitted to the general ledger and subsidiary ledger tables of the current accounting period in a unified database transaction to complete the proxy accounting entry. After successful entry, the data version optimistic lock is released.

10. The method for agency accounting processing of electronic invoice blockchain storage according to claim 1, characterized in that, The step of performing a hash operation on the cascaded compensation matrix to generate a processing result hash, and writing the mapping relationship between the ticket identifier and the processing result hash into the sidechain includes: The concatenated compensation matrix is ​​converted into a standard byte stream and input into a preset one-way cryptographic hash function to calculate and generate the hash of the processing result; Using the ticket identifier as the query index key and the hash of the processing result as the evidence storage payload, an on-chain transaction package with the digital signature of the current operating node's private key is assembled. The on-chain transaction package is broadcast to the consensus node network of the sidechain via a cross-chain gateway for block confirmation and persistent storage.