flatting Document and DocumentLine into Contract and ContractLine