A method , comprising: performing optical character recognition, OCR, on a scanned image of a first document; extracting an identifier from the first document; identifying a complementary document associated with the first document using the identifier; generating a list of hypotheses mapping the first document to the complementary document using: textual information from the first document; textual information from the complementary document; and predefined business rules; wherein generating the list of hypotheses comprises determining an overall cost of validating the first document according to each of the hypotheses; determining a validity of the first document based on the hypotheses, wherein determining the validity of the first document comprises selecting from among the hypotheses a hypothesis associated with a lowest cost, and determining the validity of the first document based on the selected hypothesis; and outputting an indication of the determined validity; wherein the first document is an invoice and the complementary document is a purchase order; and wherein the overall cost of validating the first document according to each of the hypotheses is the sum of: (i) a cost of generating a set of position match candidates from the invoice, wherein each position match candidate comprises a line-item or a combination of line-items extracted from the invoice that is a candidate to match to a position of the purchase order; and (ii) a cost associated with a specific one-to-one mapping of said set of position match candidates to respective positions of the purchase order. performing optical character recognition, OCR, on a scanned image of a first document; extracting an identifier from the first document; identifying a complementary document associated with the first document using the identifier; generating a list of hypotheses mapping the first document to the complementary document using: textual information from the first document; textual information from the complementary document; and predefined business rules; wherein generating the list of hypotheses comprises determining an overall cost of validating the first document according to each of the hypotheses; textual information from the first document; textual information from the complementary document; and predefined business rules; wherein generating the list of hypotheses comprises determining an overall cost of validating the first document according to each of the hypotheses; determining a validity of the first document based on the hypotheses, wherein determining the validity of the first document comprises selecting from among the hypotheses a hypothesis associated with a lowest cost, and determining the validity of the first document based on the selected hypothesis; and outputting an indication of the determined validity; wherein the first document is an invoice and the complementary document is a purchase order; and wherein the overall cost of validating the first document according to each of the hypotheses is the sum of: (i) a cost of generating a set of position match candidates from the invoice, wherein each position match candidate comprises a line-item or a combination of line-items extracted from the invoice that is a candidate to match to a position of the purchase order; and (ii) a cost associated with a specific one-to-one mapping of said set of position match candidates to respective positions of the purchase order. (i) a cost of generating a set of position match candidates from the invoice, wherein each position match candidate comprises a line-item or a combination of line-items extracted from the invoice that is a candidate to match to a position of the purchase order; and (ii) a cost associated with a specific one-to-one mapping of said set of position match candidates to respective positions of the purchase order. <EOS>