Added feature "CONSUMER_ENABLE_ASN0_SPLITTING"

This feature will change the behaviour of the document barcode consumer.
If CONSUMER_ENABLE_ASN0_SPLITTING=true, detection a ASN of value 0 will
NOT write that ASN into the new document metadata. This achieves document
splitting on ASN0
This commit is contained in:
Sebastian Jürges 2024-06-08 16:07:43 +02:00
parent d8c96b6e4a
commit f3bf86c016
2 changed files with 6 additions and 1 deletions

View File

@ -154,7 +154,8 @@ class BarcodePlugin(ConsumeTaskPlugin):
and (located_asn := self.asn) is not None
):
logger.info(f"Found ASN in barcode: {located_asn}")
self.metadata.asn = located_asn
if not settings.CONSUMER_ENABLE_ASN0_SPLITTING or located_asn > 0:
self.metadata.asn = located_asn
def cleanup(self) -> None:
self.temp_dir.cleanup()

View File

@ -893,6 +893,10 @@ CONSUMER_ENABLE_ASN_BARCODE: Final[bool] = __get_boolean(
"PAPERLESS_CONSUMER_ENABLE_ASN_BARCODE",
)
CONSUMER_ENABLE_ASN0_SPLITTING: Final[bool] = __get_boolean(
"PAPERLESS_CONSUMER_ENABLE_ASN0_SPLITTING",
)
CONSUMER_ASN_BARCODE_PREFIX: Final[str] = os.getenv(
"PAPERLESS_CONSUMER_ASN_BARCODE_PREFIX",
"ASN",