From fd5d3142ed4d340acb4b81a2666d3c691c9d8984 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 1 Oct 2023 19:41:39 -0500 Subject: [PATCH] Truncate item descriptions when pushing to `dtransactions` if needed --- rattail_corepos/batch/pos.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/rattail_corepos/batch/pos.py b/rattail_corepos/batch/pos.py index 5b5380f..040399c 100644 --- a/rattail_corepos/batch/pos.py +++ b/rattail_corepos/batch/pos.py @@ -48,6 +48,7 @@ class POSBatchHandler(base.POSBatchHandler): self.corepos_handler = self.app.get_corepos_handler() self.coretrans = self.corepos_handler.get_model_office_trans() + self.maxlen_upc = self.app.maxlen(self.coretrans.TransactionDetail.upc) self.maxlen_description = self.app.maxlen(self.coretrans.TransactionDetail.description) # convert batch rows to `dtransactions` records @@ -122,8 +123,15 @@ class POSBatchHandler(base.POSBatchHandler): def make_d_badscan(self, row): d = self.make_d_basic(row=row) - d.upc = row.item_entry d.description = 'BADSCAN' + + d.upc = row.item_entry + if d.upc and len(d.upc) > self.maxlen_upc: + log.debug("have to truncate this upc to %s chars (it has %s): %s", + self.maxlen_upc, len(d.upc), d.upc) + d.upc = d.upc[:self.maxlen_upc] + d.description += " (TRUNCATED)" + return d def make_d_customer(self, row):