An invoice automatic cancellation method and device
By optimizing the invoice verification process using a two-pointer algorithm and pruning conditions, the problem of high time complexity in invoice verification in existing technologies is solved, and fast and accurate automatic invoice verification is achieved.
Patent Information
- Application Number
- CN202211293583.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-21
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2042-10-21
AI Technical Summary
The existing financial invoice reconciliation system is time-consuming and has low feasibility. In particular, it cannot quickly find feasible combinations when the number of invoices increases, resulting in time-consuming and labor-intensive processes.
By employing a two-pointer algorithm combined with pruning conditions, the total amount of the settlement statement to be reconciled and the invoice set is obtained. The combination of invoices that meet the target total amount is then filtered out, simplifying the problem to a summation of two numbers, reducing the number of searches. Furthermore, the invoice set is optimized through a preprocessing model and sorting to improve reconciliation efficiency.
It effectively reduces the time complexity of invoice verification, improves verification efficiency, reduces running time, avoids wasting time on incorrect input, and achieves fast and accurate automatic invoice verification.
Smart Images

Figure CN115599812B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of electronic information technology, and in particular to a method and apparatus for automatic invoice verification. Background Technology
[0002] Currently, when the finance department settles payments with each merchant, the merchant typically issues multiple invoices for the same settlement amount. The finance department then needs to verify these invoices against the settlement amount. The automated verification system for the finance department uses an iterative algorithm to filter invoices from multiple invoices to obtain a combination of invoices that match the amount on a single settlement statement. This provides the finance department with a convenient and efficient settlement service, significantly reducing intermediary and labor costs.
[0003] In the process of realizing this invention, the inventors discovered at least the following problems in the prior art:
[0004] When the finance department settles payments with each merchant, each merchant may have multiple settlement orders, and each settlement order may correspond to multiple invoices. Since invoice verification is not done in real time, invoices from different settlement orders can become mixed up, making invoice verification time-consuming, labor-intensive, and inefficient. Furthermore, the iterative algorithm used by the finance department's automated verification system is a brute-force algorithm that iterates through all possible combinations, resulting in high time complexity. When the number of invoices increases to a certain point, this algorithm cannot find feasible combinations in a short time, and may even fail to produce results. Therefore, this algorithm has very low feasibility in real-world scenarios. Summary of the Invention
[0005] In view of this, embodiments of the present invention provide an automatic invoice verification method and apparatus, which can solve the technical problems of high time complexity and low feasibility of existing financial invoice verification.
[0006] To achieve the above objectives, according to one aspect of the present invention, an automatic invoice reconciliation method is provided, characterized in that it includes, in response to a request for reconciliation processing, obtaining a settlement statement to be reconciled to determine the total amount of the output invoice set; obtaining the invoice set to be reconciled and a preset number of output invoices to filter a first invoice set from the invoice set to be reconciled, and then deleting the first invoice set from the invoice set to obtain a second invoice set; and determining a target total amount of the second invoice set based on the total amount of the output invoice set and the total amount of the first invoice set; invoicing a preset two-pointer algorithm to determine whether there is invoice information in the second invoice set that matches the target total amount of the second invoice set; if so, adding the invoice information to the first invoice set to obtain a final output invoice set to perform processing of the settlement statement to be reconciled; otherwise, re-filtering the first invoice set from the invoice set to be reconciled or updating the number of output invoices until a final output invoice set is obtained to perform processing of the settlement statement to be reconciled.
[0007] Optionally, after obtaining the set of invoices to be reconciled, it includes:
[0008] Determine whether the total amount of the set of invoices to be verified is equal to the total amount of the set of output invoices; if so, use the set of invoices to be verified as the set of output invoices to process the settlement statement to be verified; otherwise, determine whether the total amount of the set of invoices to be verified is greater than the total amount of the set of output invoices; if so, obtain the preset number of output invoices; otherwise, generate and output verification processing failure information.
[0009] Optionally, after obtaining the preset number of output invoices, the following steps are included:
[0010] Determine if the preset number of output invoices is greater than two; if so, filter to obtain the first invoice set based on the preset number of output invoices; otherwise, determine if the preset number of output invoices is equal to two; if so, determine that the first invoice set is an empty set, take the set of invoices to be reconciled as the second invoice set, and determine that the target total amount of the output invoice set is the target total amount of the second invoice set; otherwise, generate and output reconciliation processing failure information.
[0011] Optionally, before filtering to obtain the first invoice set based on a preset number of output invoices, the following steps are included:
[0012] The invoice preprocessing model is invoked to calculate a first threshold for the set of invoices to be verified, so as to determine the relationship between the first threshold and the total amount of the output invoice set. The set of invoices to be verified is sorted according to the relationship to obtain the sorted set of invoices to be verified.
[0013] Optionally, after obtaining the sorted set of invoices to be reconciled, it includes:
[0014] Based on the preset output invoice quantity order, invoices in the sorted set of invoices to be reconciled are obtained to generate a third invoice set. It is then determined whether the total amount of the third invoice set is equal to the total amount of the output invoice set. If so, the third invoice set is used as the output invoice set to process the settlement statement to be reconciled. Otherwise, it is determined whether the first threshold and the total amount of the third invoice set are both greater than or less than the total amount of the output invoice set. If so, the preset output invoice quantity is changed. Otherwise, two invoices are selected from the set of invoices to be reconciled, minus the preset output invoice quantity, to generate a first invoice set.
[0015] Optionally, a preset two-pointer algorithm is invoked to determine whether there exist two invoices in the second invoice set that match the target total amount of the second invoice set, including:
[0016] Sort the second set of invoices, and set two pointers to point to the invoice information at both ends of the sorted second set of invoices. Determine whether the total amount of the two invoices pointed to is equal to the target total amount of the second set of invoices. If yes, add the two invoices pointed to to the first set of invoices to obtain the final output invoice set. Otherwise, based on the relationship between the total amount of the two invoices pointed to and the total amount of the output invoice set, select one of the two pointers to move one unit to the left or right to the adjacent invoice, and determine again whether the total amount of the two invoices pointed to is equal to the target total amount of the second set of invoices.
[0017] Optionally, update the number of output invoices, including:
[0018] Update the number of output invoices and determine if the updated number of output invoices is valid;
[0019] If yes, then obtain the updated number of output invoices as the changed preset number of output invoices; otherwise, obtain the number of output invoices before the update plus one as the changed preset number of output invoices.
[0020] In addition, the present invention also provides an automatic invoice verification device, comprising: an acquisition module, configured to acquire a settlement form to be verified in response to a request for verification processing, thereby determining the total amount of the output invoice set, and to acquire the settlement form to be verified and a preset number of output invoices; a calculation module, configured to filter a first invoice set from the settlement form to be verified, and to delete the first invoice set from the settlement form to be verified to obtain a second invoice set, and to determine a target total amount of the second invoice set based on the total amount of the output invoice set and the corresponding total amount of the first invoice set; and a filtering module, configured to call a preset two-pointer algorithm to determine whether there is invoice information in the second invoice set that matches the target total amount of the second invoice set. If so, the two invoices are added to the first invoice set to obtain the final output invoice set for processing the settlement form to be verified; otherwise, the calculation module re-filters the first invoice set from the settlement form to be verified or updates the number of output invoices until the final output invoice set is obtained for processing the settlement form to be verified.
[0021] One embodiment of the above invention has the following advantages or beneficial effects: In response to a pending verification request, the invention obtains the settlement sheet and the set of invoices to be verified, determines the total amount of the output invoice set, obtains a preset number of output invoices, and filters them to obtain a first invoice set and a second invoice set. This simplifies a multi-summation problem into a two-number summation problem, effectively reducing time complexity. Then, a preset two-pointer algorithm is called for traversal summation, compressing the number of searches and significantly reducing running time while completing the automatic verification system function. Furthermore, by judging the relationship between the total amount of the invoice set to be verified and the total amount of the output invoice set, a first pruning condition is added to determine whether to terminate the verification process early, avoiding wasted time on incorrect verification inputs, thus improving the efficiency of invoice verification. In addition, by obtaining a preset number of output invoices, the invention also simplifies the process. The system generates a number of invoices and, based on the range of these numbers, determines whether to terminate the loop early, skip steps in the process, or continue the current process. A second pruning condition is added to predict and skip steps in the overall reconciliation process that are meaningless to the currently preset output invoice numbers, further reducing the runtime of the automatic invoice reconciliation system. Simultaneously, the system sorts the set of invoices to be reconciled, filters out the invoices with the largest or smallest amount from the previously preset output invoice quantity (the third invoice set), and compares their total amount with the total amount of the output invoice set. A third pruning condition is added to preliminarily estimate whether there are any output invoice combinations that meet the conditions, avoiding searching the entire dataset, preemptively rejecting unreasonable preset output invoice quantity values, and re-acquiring output invoice quantity values, thereby accelerating the iteration of the invoice reconciliation algorithm.
[0022] The further effects of the aforementioned unconventional alternative methods will be explained below in conjunction with specific implementation methods. Attached Figure Description
[0023] The accompanying drawings are provided to better understand the invention and are not intended to unduly limit the scope of the invention. Wherein:
[0024] Figure 1 This is the financial processing scenario to which this invention is applicable;
[0025] Figure 2 This is a schematic diagram of the main process of the automatic invoice verification method according to the first embodiment of the present invention;
[0026] Figure 3 This is a schematic diagram of the process related to the two-pointer algorithm according to an embodiment of the present invention;
[0027] Figure 4 This is a schematic diagram of the main process of the automatic invoice verification method according to the second embodiment of the present invention;
[0028] Figure 5 This is a schematic diagram of the main process of the automatic invoice verification method according to the third embodiment of the present invention;
[0029] Figure 6 This is a schematic diagram of the main modules of the automatic invoice verification device according to an embodiment of the present invention;
[0030] Figure 7 This is an exemplary system architecture diagram in which embodiments of the present invention can be applied;
[0031] Figure 8 This is a schematic diagram of the structure of a computer system suitable for implementing terminal devices or servers of the present invention. Detailed Implementation
[0032] The following description, in conjunction with the accompanying drawings, illustrates exemplary embodiments of the present invention, including various details to aid understanding. These details should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the invention. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0033] Figure 1 This is a flowchart illustrating the process of verifying corresponding invoices based on settlement receipts when business transactions occur between merchants and the finance department, as described in this invention. Figure 1As shown, when a merchant completes settlement with the finance department, invoices and settlement slips of the same amount are generated as supporting documents. In most cases, the total amount of multiple invoices corresponds to the amount of one settlement slip. Therefore, this invention can be directly applied to the role of the automatic reconciliation system shown in the diagram, quickly and efficiently filtering out invoice combinations that meet the settlement slip amount from the set of invoices to be reconciled, and feeding the output back to the finance department to complete the invoice reconciliation.
[0034] Figure 2 This is a schematic diagram of the main process of the automatic invoice verification method according to the first embodiment of the present invention, as shown below. Figure 2 As shown, the automatic invoice verification method includes:
[0035] Step S201: In response to the request for pending reconciliation processing, obtain the pending reconciliation settlement sheet to determine the total amount of the output invoice set.
[0036] In this embodiment, after the automatic invoice reconciliation system on the financial side is started, in response to the request for reconciliation, the system can obtain the settlement slips to be reconciled in order to determine the total amount of the output invoice set. For example, if the automatic invoice reconciliation system obtains a settlement slip with an amount of 7, it indicates that a set of several invoices to be reconciled needs to be selected from the subsequently obtained set of invoices to be reconciled, and it is guaranteed that the total amount of the invoices in the set is equal to the amount of this settlement slip, 7, which is the total amount of the output invoice set.
[0037] Step S202: Obtain the set of invoices to be verified and the preset number of output invoices, so as to filter out the first invoice set from the set of invoices to be verified, and then delete the first invoice set from the set of invoices to be verified to obtain the second invoice set, and determine the target total amount of the second invoice set based on the total amount of the output invoice set and the total amount of the first invoice set.
[0038] In this embodiment, after obtaining the set of invoices to be verified and the preset number of output invoices, the preset number of output invoices is divided into two parts. The first part is the number of invoices corresponding to the first invoice set, which is the preset number of output invoices minus two. The second part is the number of invoices selected from the second invoice set, which is two. Therefore, the sum of the two parts is exactly the preset number of output invoices. Furthermore, the selection method for obtaining the first invoice set from the set of invoices to be verified is random selection or sequential selection. After obtaining the first invoice set, the first invoice set is then deleted from the set of invoices to be verified to obtain the second invoice set. The total amount of the first invoice set is calculated, and the total amount of the output invoice set minus the total amount of the first invoice set is the target total amount of the second invoice set. For example, the total amount of the output invoice set is 9, the invoice set to be verified is {1, 5, 2, 4, 2, 3}, and the preset number of output invoices is 4. Therefore, the number of invoices in the first invoice set is 4-2=2. After sorting the invoice set to be verified, it becomes {1, 2, 2, 3, 4, 5}. Filtering from front to back, the first invoice set is {1, 2}. The total amount of the first invoice set is 1+2=3, and the target total amount of the second invoice set is 9-3=6.
[0039] In some embodiments, after obtaining the set of invoices to be reconciled, it can be determined whether the total amount of the set of invoices to be reconciled is equal to the total amount of the output invoice set; if so, the set of invoices to be reconciled is used as the output invoice set to process the settlement statement to be reconciled; otherwise, it is determined whether the total amount of the set of invoices to be reconciled is greater than the total amount of the output invoice set; if so, a preset number of output invoices is obtained; otherwise, a reconciliation processing failure message is generated and output. It can be seen that the present invention adds a first pruning condition at this stage, filtering out cases where the total amount of the set of invoices to be reconciled is equal to or less than the total amount of the output invoice set. This quickly predicts whether the input invoice information is suitable for the subsequent automatic invoice reconciliation algorithm. If it is not suitable, the reconciliation processing is terminated early and a failure message is generated, avoiding traversing and searching through incorrect input invoice information, wasting time, and reducing efficiency.
[0040] In other embodiments, after obtaining the preset number of output invoices, it can be determined whether the preset number of output invoices is greater than two. If so, a first invoice set is obtained by filtering based on the preset number of output invoices. Otherwise, it is further determined whether the preset number of output invoices is equal to two. If so, the first invoice set is determined to be an empty set, the invoice set to be reconciled is determined to be a second invoice set, the target total amount of the output invoice set is determined to be the target total amount of the second invoice set, and a preset two-pointer algorithm is called. Otherwise, a reconciliation processing failure message is generated and output. It can be seen that the present invention adds a second pruning condition at this stage to handle different preset numbers of output invoices. If the number is greater than two, the first invoice set is filtered; if it is equal to two, the process jumps to the step of calling the two-pointer algorithm; if it is less than two, the process ends early. The specific calculation steps of the invoice reconciliation algorithm are adjusted according to different ranges of preset output invoice numbers, further improving the operating efficiency of the automatic reconciliation system.
[0041] In other embodiments, before obtaining the first invoice set by filtering according to a preset number of output invoices, an invoice preprocessing model can be used to calculate a first threshold for the invoice set to be reconciled, to determine the relationship between the first threshold and the total amount of the output invoice set. The invoice set to be reconciled is then sorted according to this relationship to obtain a sorted invoice set to be reconciled. Invoices from the sorted invoice set to be reconciled are then obtained according to a preset output invoice number order to generate a third invoice set. It is then determined whether the total amount of the third invoice set is equal to the total amount of the output invoice set. If so, the third invoice set is used as the output invoice set to process the settlement statement to be reconciled. Otherwise, it is determined whether the first threshold and the total amount of the third invoice set are both greater than or both less than the total amount of the output invoice set. If so, the preset number of output invoices is changed; otherwise, two invoices (preset number of output invoices minus two) are selected from the invoice set to be reconciled to generate the first invoice set. The first threshold calculated by the preprocessing model can be the average or median of the invoice amounts in the set of invoices to be verified, or other characteristic values, representing the approximate range of all invoice amounts in the set. The third invoice set contains a preset number of output invoices with the largest or smallest amounts in the set of invoices to be verified. This invention adds a third pruning condition at this stage to estimate the reasonableness of the preset number of output invoices, avoiding the need to search the entire dataset and achieving more accurate invoice verification.
[0042] For example, the total amount of the output invoice set is 13, the preset number of output invoices is 3, and the set of invoices to be verified is {2, 3, 1, 5, 4}. Since 3 > 2, we continue to filter the first invoice set. The first threshold calculated using the invoice preprocessing model (in this example, the first threshold is set to the average value) yields an average value of 3 for the set of invoices to be verified. Since 3 < 13, the conclusion is that the average amount of the set of invoices to be verified is relatively small compared to the total amount of the output invoice set. Therefore, we take the total amount of the three largest invoices in the set of invoices to be verified as 3 + 4 + 5 = 12, which is the total amount of the third invoice set. Since 12 < 13, and the total amount of the three largest invoices in the set of invoices to be verified is still less than the total amount of the output invoice set, we know that there are no three invoice combinations in the set of invoices to be verified that satisfy the total amount of the output invoice set. This means that the preset number of output invoices at this stage is unreasonable and needs to be updated before re-entering the iteration.
[0043] Step S203: Invoke the preset two-pointer algorithm to determine whether there is invoice information in the second invoice set that matches the target total amount of the second invoice set. If so, add the invoice information to the first invoice set to obtain the final output invoice set, so as to process the settlement statement to be verified; otherwise, re-filter the first invoice set from the invoice set to be verified or update the number of output invoices until the final output invoice set is obtained to process the settlement statement to be verified.
[0044] In this embodiment, invoking the preset two-pointer algorithm includes: sorting the second invoice set; setting two pointers to point to the invoices at both ends of the sorted second invoice set; determining whether the total amount of the two pointed-to invoices is equal to the target total amount of the second invoice set; if so, adding the information of the two pointed-to invoices to the first invoice set to obtain the final output invoice set; otherwise, based on the relationship between the total amount of the two pointed-to invoices and the total amount of the output invoice set, selecting one of the two pointers to move one unit to the left or right to the adjacent invoice, and again determining whether the total amount of the two pointed-to invoices is equal to the target total amount of the second invoice set.
[0045] In other embodiments, updating the number of output invoices includes: updating the number of output invoices and determining whether the updated number of output invoices is valid; if so, obtaining the updated number of output invoices as the changed preset number of output invoices; otherwise, obtaining the number of output invoices before the update plus one as the changed preset number of output invoices.
[0046] For example, the amount of the settlement statement to be reconciled is 13, the set of invoices to be reconciled is {1,1,3,8,14}, and the preset number of output invoices is 3. It can be seen that after determining any invoice as part of the first invoice set, the two-pointer algorithm cannot find two invoices matching the target total amount of the second invoice set. Therefore, it is necessary to re-filter the first invoice set from the set of invoices to be reconciled, and then use the two-pointer algorithm again to filter the second invoice set. This continues until no different first invoice sets can be obtained from the set of invoices to be reconciled based on the preset number of output invoices. Then, the updated number of output invoices is obtained, and it is determined whether the updated number of output invoices is valid. Validity can be defined as a positive integer greater than the preset number of output invoices. The updated number of output invoices can be customized by the finance personnel. If the updated number of output invoices is 3.5, 0, or 3, it is considered invalid, and the original number of output invoices (3) is obtained. Calculating 3 + 1 = 4, 4 is used as the changed preset number of output invoices.
[0047] For example, the default two-pointer algorithm is as follows: Figure 3 As shown, 'm' represents the preset number of output invoices, 'target' represents the target total amount of the second invoice set, and 'invoice' refers to the second invoice set. The automatic invoice verification system transforms the multiple summation problem into a final two-number summation problem, employing a two-pointer approach. As shown, the invoices in the second invoice set are sorted by amount from left to right, from smallest to largest. Two pointers are set to point to the invoices at opposite ends of the sorted second invoice set; the left pointer points to the first number 2, and the right pointer points to the last number 5. The sum of the left and right pointers is calculated each time. If the sum is greater than the target total amount of the second invoice set (i.e., the 'target' value in the diagram), then the two smaller numbers should be selected. Since the second invoice set is sorted in ascending order, the left pointer remains stationary, and the right pointer moves one unit to the left. If the sum is less than the target total amount of the second invoice set, then the two larger numbers should be selected. Therefore, the right pointer remains stationary, and the left pointer moves one unit to the right. When the sum of the two pointers equals the target total amount of the second invoice set, it means that two invoices that meet the requirements have been found. Then, the two invoices that are pointed to are added to the first invoice set to obtain the final output invoice set.
[0048] Figure 4 This is a schematic diagram of the main flow of the automatic invoice cancellation method according to the second embodiment of the present invention, the automatic invoice cancellation method including:
[0049] Step S401: In response to the pending verification processing request, obtain the pending verification settlement form to determine the total amount of the output invoice set.
[0050] Step S402: Obtain the set of invoices to be verified.
[0051] Step S403: Determine whether the total amount of the set of invoices to be reimbursed is equal to the total amount of the set of output invoices. If yes, proceed to step S410; otherwise, proceed to step S404.
[0052] Step S404: Determine whether the total amount of the set of invoices to be reimbursed is greater than the total amount of the set of output invoices. If not, proceed to step S413; if yes, proceed to step S405.
[0053] Step S405: Obtain the preset number of output invoices.
[0054] Preferably, when entering S405 in a subsequent step, the preset output invoice quantity is retrieved again, including: updating the output invoice quantity to determine whether the updated output invoice quantity is valid; if so, the updated output invoice quantity is used as the changed preset output invoice quantity; otherwise, the output invoice quantity before the update is incremented by one as the changed preset output invoice quantity.
[0055] Step S406: Determine whether the preset number of output invoices is greater than two. If yes, proceed to step S407; otherwise, proceed to step S411.
[0056] Step S407: Select two invoices from the set of invoices to be verified to generate the first invoice set.
[0057] Step S408: Delete the first invoice set from the invoice set to be verified to obtain the second invoice set, and determine the target total amount of the second invoice set based on the total amount of the output invoice set and the total amount corresponding to the first invoice set.
[0058] Ideally, the target total amount of the second invoice set is the total amount of the output invoice set minus the total amount of the first invoice set.
[0059] Step S409: Invoke the preset two-pointer algorithm to determine whether there are two invoices in the second invoice set that match the target total amount. If yes, proceed to step S412; otherwise, proceed to step S407 or S405.
[0060] Preferably, if there are no two invoices in the second invoice set that match the target total amount of the second invoice set, proceed to step S407, that is, re-filter the invoices from the set of invoices to be verified and output the number of invoices minus two to generate the first invoice set, and then proceed to subsequent steps S408 and S409, calling the preset two-pointer algorithm for filtering again. If, after traversing the entire first invoice set, two invoices that match the target amount of the second invoice set are still not found in step S409, then proceed to step S405, that is, re-obtain the preset number of output invoices.
[0061] Step S410: The set of invoices to be reconciled is used as the output invoice set to process the settlement statement to be reconciled.
[0062] Step S411: Determine if the preset number of output invoices is equal to two. If yes, proceed to step S408; otherwise, proceed to step S413.
[0063] Preferably, if the preset number of output invoices is equal to two, then the first invoice set is determined to be an empty set, the invoice set to be cancelled is determined to be the second invoice set, the target total amount of the output invoice set is determined to be the target total amount of the second invoice set, and step S408 is performed.
[0064] Step S412: Add the information of the two invoices to the first invoice set to obtain the final output invoice set, so as to perform the processing of the settlement statement to be verified.
[0065] Step S413: Generate and output verification processing failure information.
[0066] Figure 5 A schematic diagram of the main flow of the automatic invoice cancellation method according to the third embodiment of the present invention, wherein the automatic invoice cancellation method includes:
[0067] Step S501: In response to the pending verification processing request, obtain the pending verification settlement form to determine the total amount of the output invoice set.
[0068] Step S502: Obtain the set of invoices to be verified.
[0069] Step S503: Determine whether the total amount of the set of invoices to be reimbursed is equal to the total amount of the set of output invoices. If yes, proceed to step S514; otherwise, proceed to step S504.
[0070] Step S504: Determine whether the total amount of the set of invoices to be reconciled is greater than the total amount of the set of output invoices. If not, proceed to step S518; if yes, proceed to step S505.
[0071] Step S505: Obtain the preset number of output invoices.
[0072] Preferably, when entering S505 in a subsequent step, the preset output invoice quantity is retrieved again, including: updating the output invoice quantity to determine whether the updated output invoice quantity is valid; if so, the updated output invoice quantity is used as the changed preset output invoice quantity; otherwise, the output invoice quantity before the update is incremented by one as the changed preset output invoice quantity.
[0073] Step S506: Determine whether the preset number of output invoices is greater than two. If yes, proceed to step S507; otherwise, proceed to step S515.
[0074] Step S507: Call the invoice preprocessing model to calculate the first threshold for the invoices to be verified, and sort the invoice set to be verified according to the relationship between the first threshold and the total amount of the output invoice set.
[0075] Step S508: Obtain the invoices from the sorted set of invoices to be verified according to the preset output invoice quantity order to generate a third invoice set.
[0076] Step S509: Determine whether the total amount of the third invoice set is equal to the total amount of the output invoice set. If yes, proceed to step S516; otherwise, proceed to step S510.
[0077] Step S510: Determine whether the total amount of the first threshold and the third invoice set is both greater than or both less than the total amount of the output invoice set. If yes, proceed to step S505; otherwise, proceed to step S511.
[0078] Step S511: Select two invoices from the set of invoices to be verified to generate the first invoice set.
[0079] Step S512: Delete the first invoice set from the invoice set to be verified to obtain the second invoice set, and determine the target total amount of the second invoice set based on the total amount of the output invoice set and the total amount corresponding to the first invoice set.
[0080] Ideally, the target total amount of the second invoice set is the total amount of the output invoice set minus the total amount of the first invoice set.
[0081] Step S513: Invoke the preset two-pointer algorithm to determine whether there are two invoices in the second invoice set that match the target total amount. If yes, proceed to step S517; otherwise, proceed to step S511 or step S505.
[0082] Preferably, if there are no two invoices in the second invoice set that match the target total amount of the second invoice set, proceed to step S511, that is, re-filter the invoices to be verified from the invoice set and subtract two invoices to generate the first invoice set, and then proceed to subsequent steps S512 and S513, calling the preset two-pointer algorithm for filtering again. If, after traversing the entire first invoice set, two invoices that match the target amount of the second invoice set are still not found in step S513, then proceed to step S505, that is, re-obtain the preset number of output invoices.
[0083] Step S514: The set of invoices to be reconciled is used as the output invoice set to process the settlement statement to be reconciled.
[0084] Step S515: Determine if the preset number of output invoices is equal to two. If yes, proceed to step S513; otherwise, proceed to step S518.
[0085] Preferably, if the preset number of output invoices is equal to two, then the first invoice set is determined to be an empty set, the invoice set to be cancelled is determined to be the second invoice set, the target total amount of the output invoice set is determined to be the target total amount of the second invoice set, and step S513 is performed.
[0086] Step S516: The third invoice set is used as the output invoice set to process the settlement statement to be reconciled.
[0087] Step S517: Add the information of the two invoices to the first invoice set to obtain the final output invoice set, so as to perform the processing of the settlement statement to be verified.
[0088] Step S518: Generate and output verification processing failure information.
[0089] Figure 6 This is a schematic diagram of the main modules of the automatic invoice verification device according to an embodiment of the present invention, as shown below. Figure 6As shown, the automatic invoice verification device 600 includes an acquisition module 601, a calculation module 602, and a filtering module 603. The acquisition module 601, in response to a request for verification processing, acquires the settlement sheet to be verified to determine the total amount of the output invoice set; and acquires the set of invoices to be verified and a preset number of output invoices. The calculation module 602 filters the set of invoices to be verified to obtain a first invoice set; deletes the first invoice set from the set of invoices to be verified to obtain a second invoice set; and determines the target total amount of the second invoice set based on the total amount of the output invoice set and the corresponding total amount of the first invoice set. The filtering module 603 calls a preset two-pointer algorithm to determine whether there is invoice information in the second invoice set that matches the target total amount of the second invoice set. If so, the invoice information is added to the first invoice set to obtain the final output invoice set for processing the settlement sheet to be verified; otherwise, the calculation module 602 re-filters the set of invoices to be verified to obtain the first invoice set or updates the number of output invoices until the final output invoice set is obtained for processing the settlement sheet to be verified.
[0090] In some embodiments, the calculation module 602 is further configured to: determine whether the total amount of the set of invoices to be reconciled is equal to the total amount of the set of output invoices; if so, use the set of invoices to be reconciled as the set of output invoices to perform the processing of the settlement statement to be reconciled; otherwise, determine whether the total amount of the set of invoices to be reconciled is greater than the total amount of the set of output invoices; if so, obtain the preset number of output invoices; otherwise, generate and output reconciliation processing failure information.
[0091] In some embodiments, the calculation module 602 is further configured to: determine whether the preset number of output invoices is greater than two; if so, filter to obtain a first invoice set based on the preset number of output invoices; otherwise, determine whether the preset number of output invoices is equal to two; if so, determine that the first invoice set is an empty set, determine that the set of invoices to be reconciled is a second invoice set, determine that the target total amount of the output invoice set is the target total amount of the second invoice set, and call a preset two-pointer algorithm; otherwise, generate and output reconciliation processing failure information.
[0092] In some embodiments, the calculation module 602 is further configured to: call the invoice preprocessing model, calculate a first threshold for the set of invoices to be verified, determine the relationship between the first threshold and the total amount of the output invoice set, sort the set of invoices to be verified according to the relationship, and obtain the sorted set of invoices to be verified.
[0093] In some embodiments, the calculation module 602 is further configured to: obtain invoices from the sorted set of invoices to be reconciled according to a preset output invoice quantity order to generate a third invoice set; determine whether the total amount of the third invoice set is equal to the total amount of the output invoice set; if so, use the third invoice set as the output invoice set to perform processing of the settlement statement to be reconciled; otherwise, determine whether the first threshold and the total amount of the third invoice set are both greater than or both less than the total amount of the output invoice set; if so, change the preset output invoice quantity; otherwise, select the preset output invoice quantity minus two invoices from the set of invoices to be reconciled to generate a first invoice set.
[0094] In some embodiments, the filtering module 603 is further configured to: sort the second invoice set, set two pointers to point to the invoice information at both ends of the sorted second invoice set, determine whether the total amount of the two invoices being pointed to is equal to the target total amount of the second invoice set; if so, add the two invoices being pointed to to the first invoice set to obtain the final output invoice set; otherwise, based on the relationship between the total amount of the two invoices being pointed to and the total amount of the output invoice set, select one of the two pointers to move one unit to the left or right to the adjacent invoice, and determine again whether the total amount of the two invoices being pointed to is equal to the target total amount of the second invoice set.
[0095] In some embodiments, the calculation module 602 is further configured to: update the number of output invoices and determine whether the updated number of output invoices is valid; if so, obtain the updated number of output invoices as the changed preset number of output invoices; otherwise, obtain the number of output invoices before the update plus one as the changed preset number of output invoices.
[0096] It should be noted that the automatic invoice verification method and the automatic invoice verification device described in this invention are related in terms of specific implementation, so repeated content will not be described again.
[0097] Figure 7 An exemplary system architecture 700 is shown that can be applied to the automatic invoice verification method or device of the present invention.
[0098] like Figure 7 As shown, system architecture 700 may include terminal devices 701, 702, and 703, a network 704, and a server 705. Network 704 serves as the medium for providing communication links between terminal devices 701, 702, and 703 and server 705. Network 704 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.
[0099] Users can use terminal devices 701, 702, and 703 to interact with server 705 via network 704 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 701, 702, and 703.
[0100] Terminal devices 701, 702, and 703 can be various electronic devices with invoice verification and processing screens that support web browsing, including but not limited to smartphones, tablets, laptops, and desktop computers.
[0101] Server 705 can be a server that provides various services, such as a backend management server that supports users using terminal devices 701, 702, and 703 (for example only). The backend management server can analyze and process data such as received product information query requests, and feed back the processing results (such as target push information, product information - for example only) to the terminal devices.
[0102] It should be noted that the automatic invoice verification method provided in this embodiment of the invention is generally executed by server 705, and correspondingly, the computing device is generally located in server 705.
[0103] It should be understood that Figure 7 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0104] The following is for reference. Figure 8 It shows a schematic diagram of the structure of a computer system 800 suitable for implementing a terminal device of the present invention. Figure 8 The terminal device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.
[0105] like Figure 8 As shown, the computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 802 or programs loaded from storage section 808 into random access memory (RAM) 803. The RAM 803 also stores various programs and data required for the operation of the computer system 800. The CPU 801, ROM 802, and RAM 803 are interconnected via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0106] The following components are connected to the I / O interface 805: an input section 805 including a keyboard, mouse, etc.; an output section 806 including a cathode ray tube (CRT), liquid crystal display processor (LCD), and speakers, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN card and a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 810 as needed so that computer programs read from it can be installed into the storage section 808 as needed.
[0107] In particular, according to the embodiments disclosed in this invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 809, and / or installed from removable medium 811. When the computer program is executed by central processing unit (CPU) 801, it performs the functions defined above in the system of this invention.
[0108] It should be noted that the computer-readable medium shown in this invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0109] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0110] The modules described in the embodiments of the present invention can be implemented in software or hardware. The described modules can also be housed in a processor; for example, a processor can be described as including an acquisition module, a calculation module, and a filtering module. The names of these modules do not necessarily limit the module itself.
[0111] In another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiments; or it may exist independently and not assembled into the device. The computer-readable medium carries one or more programs that, when executed by the device, cause the device to include, in response to a request for pending verification processing, acquiring a settlement statement to be verified to determine the total amount of an output invoice set; acquiring the set of invoices to be verified and a preset number of output invoices to filter a first invoice set from the set of invoices to be verified, then deleting the first invoice set from the set of invoices to be verified to obtain a second invoice set; and determining a target total amount for the second invoice set based on the total amount of the output invoice set and the total amount of the first invoice set; invoicing a preset two-pointer algorithm to determine whether there is invoice information in the second invoice set that matches the target total amount of the second invoice set; if so, adding the invoice information to the first invoice set to obtain a final output invoice set to perform processing of the settlement statement to be verified; otherwise, re-filtering the first invoice set from the set of invoices to be verified or updating the number of output invoices until a final output invoice set is obtained to perform processing of the settlement statement to be verified.
[0112] According to the technical solutions of the present invention, the problems of high time complexity and low feasibility of existing financial invoice reconciliation can be solved.
[0113] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for automatic invoice verification, characterized in that, include: In response to a request for pending write-off processing, obtain the pending write-off settlement statement to determine the total amount of the output invoice set; Obtain the set of invoices to be verified and the preset number of output invoices, filter the first invoice set from the set of invoices to be verified, then delete the first invoice set from the set of invoices to be verified to obtain the second invoice set, and determine the target total amount of the second invoice set based on the total amount of the output invoice set and the total amount of the first invoice set; The preset two-pointer algorithm is invoked to determine whether there is invoice information in the second invoice set that matches the target total amount of the second invoice set. If so, the invoice information is added to the first invoice set to obtain the final output invoice set, so as to process the settlement statement to be verified. Otherwise, the first invoice set is obtained by re-filtering from the invoice set to be verified or the number of output invoices is updated until the final output invoice set is obtained to process the settlement statement to be verified.
2. The method according to claim 1, characterized in that, After obtaining the set of invoices to be verified, it includes: Determine whether the total amount of the set of invoices to be verified is equal to the total amount of the set of output invoices; If so, the set of invoices to be reconciled will be used as the output invoice set to process the settlement statement to be reconciled; Otherwise, determine whether the total amount of the set of invoices to be reconciled is greater than the total amount of the set of output invoices. If it is, obtain the preset number of output invoices. Otherwise, generate and output reconciliation processing failure information.
3. The method according to claim 1, characterized in that, After obtaining the preset number of output invoices, the following is included: Determine if the preset number of output invoices is greater than two; If so, the first invoice set is obtained by filtering according to the preset number of output invoices; Otherwise, determine whether the preset number of output invoices is equal to two. If so, determine that the first invoice set is an empty set, take the set of invoices to be reconciled as the second invoice set, and determine that the target total amount of the output invoice set is the target total amount of the second invoice set; otherwise, generate and output reconciliation processing failure information.
4. The method according to claim 1, characterized in that, Before obtaining the first set of invoices from the set of invoices to be verified, the following is included: The invoice preprocessing model is invoked to calculate a first threshold for the set of invoices to be verified, so as to determine the relationship between the first threshold and the total amount of the output invoice set. The set of invoices to be verified is sorted according to the relationship to obtain the sorted set of invoices to be verified.
5. The method according to claim 4, characterized in that, After obtaining the sorted set of invoices to be verified, it includes: Based on the preset output invoice quantity order, the invoices in the sorted set of invoices to be verified are obtained to generate a third invoice set, and it is determined whether the total amount of the third invoice set is equal to the total amount of the output invoice set. If so, the third invoice set will be used as the output invoice set to process the settlement statement to be reconciled; Otherwise, determine whether the total amount of the first threshold and the third invoice set is greater than or less than the total amount of the output invoice set. If so, change the preset number of output invoices. Otherwise, select the preset number of output invoices minus two invoices from the invoice set to be cleared to generate the first invoice set.
6. The method according to claim 1, characterized in that, The pre-defined two-pointer algorithm is invoked to determine whether there exists any invoice information in the second invoice set that matches the target total amount of the second invoice set, including: Sort the second set of invoices, set two pointers to point to the invoice information at both ends of the sorted second set of invoices, and determine whether the total amount of the two invoices pointed to is equal to the target total amount of the second set of invoices; If so, add the information of the two invoices being pointed to to the first invoice set to obtain the final output invoice set; Otherwise, based on the relationship between the total amount of the two invoices being pointed to and the total amount of the output invoice set, one of the two pointers is moved one unit to the left or right to the adjacent invoice, and then it is determined again whether the total amount of the two invoices being pointed to is equal to the target total amount of the second invoice set.
7. The method according to claim 1, characterized in that, Update the number of output invoices, including: Update the number of output invoices and determine if the updated number of output invoices is valid; If so, obtain the updated number of output invoices as the changed preset number of output invoices; otherwise, obtain the number of output invoices before the update plus one as the changed preset number of output invoices.
8. An automatic invoice verification device, characterized in that, include: The acquisition module is used to retrieve the settlement statement to be reconciled in response to the request for reconciliation processing, so as to determine the total amount of the output invoice set; Used to obtain the set of invoices to be verified and the preset number of output invoices; The calculation module is used to filter the first set of invoices from the set of invoices to be verified; Used to delete the first set of invoices from the set of invoices to be verified, thus obtaining the second set of invoices; Used to determine the target total amount of the second invoice set based on the total amount of the output invoice set and the total amount of the first invoice set; The filtering module is used to call a preset two-pointer algorithm to determine whether there is invoice information in the second invoice set that matches the target total amount of the second invoice set. If so, the invoice information is added to the first invoice set to obtain the final output invoice set, so as to process the settlement statement to be reconciled. Otherwise, the calculation module will re-filter the set of invoices to be reconciled to obtain the first set of invoices, until the final output set of invoices is obtained to process the settlement statement to be reconciled.
9. An electronic device, characterized in that, include: One or more processors; When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-7.
10. A computer-readable medium having a computer program stored thereon, characterized in that, When the computer program is executed, it implements the method as described in any one of claims 1-7.
Citation Information
Patent Citations
Invoice data processing method and device, electronic equipment and readable storage medium
CN112395465A
Blockchain-based invoice creation method apparatus, and electronic device
US20200202396A1