diff --git a/test_barcode_format.py b/test_barcode_format.py new file mode 100644 index 0000000..921a0a6 --- /dev/null +++ b/test_barcode_format.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python3 +""" +Test script to verify barcode format in generated PDFs +""" +import sys +sys.path.insert(0, '/srv/quality_app-v2') + +from app.modules.labels.pdf_generator import LabelPDFGenerator + +# Test order data +test_order = { + 'comanda_productie': 'TEST-ORD-004', + 'cod_articol': 'ART004', + 'descr_com_prod': 'Metal Bracket D - Galvanized Steel', + 'cantitate': 300, + 'com_achiz_client': 'CLIENT-PO-2024-004', + 'nr_linie_com_client': '04', + 'customer_name': 'MetalCraft Solutions', + 'customer_article_number': 'MC-BRACK-D004', + 'data_livrara': '2024-03-22', + 'dimensiune': 'Small' +} + +print("="*70) +print("BARCODE FORMAT TEST") +print("="*70) + +# Test what sequential number will be generated +prod_order = test_order['comanda_productie'] +piece_number = 1 + +# This is how the PDF generator creates the sequential number +sequential_number = f"{prod_order}-{piece_number:04d}" + +print(f"\nšŸ“¦ Production Order: {prod_order}") +print(f"šŸ”¢ Piece Number: {piece_number}") +print(f"šŸ“Š Sequential Number (Horizontal Barcode): {sequential_number}") + +# Check vertical barcode format +com_achiz_client = test_order['com_achiz_client'] +nr_linie = test_order['nr_linie_com_client'] +vertical_code = f"{com_achiz_client}/{nr_linie}" + +print(f"šŸ“ Vertical Barcode: {vertical_code}") + +print("\n" + "="*70) +print("EXPECTED vs ACTUAL") +print("="*70) +print(f"āœ… CORRECT Horizontal: {sequential_number}") +print(f"āŒ WRONG Format: TEST/ORD/004/0001") +print(f"") +print("If you're seeing TEST/ORD/004/0001, possible causes:") +print("1. Data in database has slashes instead of hyphens") +print("2. Barcode scanner is configured to translate hyphens to slashes") +print("3. Looking at wrong barcode (there are 2 barcodes on each label)") +print("="*70) + +# Generate actual PDF to verify +print("\nšŸ”§ Generating test PDF...") +pdf_gen = LabelPDFGenerator(paper_saving_mode=True) +pdf_buffer = pdf_gen.generate_single_label_pdf(test_order, 1, 300, printer_optimized=True) + +# Save test PDF +output_file = '/srv/quality_app-v2/test_label_output.pdf' +with open(output_file, 'wb') as f: + f.write(pdf_buffer.read()) + +print(f"āœ… Test PDF saved to: {output_file}") +print(f"šŸ“„ Open this PDF to verify the barcode format visually") +print("\nThe barcode should encode: TEST-ORD-004-0001 (with hyphens)") diff --git a/test_label.pdf b/test_label.pdf new file mode 100644 index 0000000..cd9a92e --- /dev/null +++ b/test_label.pdf @@ -0,0 +1,74 @@ +%PDF-1.4 +%“Œ‹ž ReportLab Generated PDF document http://www.reportlab.com +1 0 obj +<< +/F1 2 0 R /F2 3 0 R +>> +endobj +2 0 obj +<< +/BaseFont /Helvetica /Encoding /WinAnsiEncoding /Name /F1 /Subtype /Type1 /Type /Font +>> +endobj +3 0 obj +<< +/BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding /Name /F2 /Subtype /Type1 /Type /Font +>> +endobj +4 0 obj +<< +/Contents 8 0 R /MediaBox [ 0 0 226.7717 297.6378 ] /Parent 7 0 R /Resources << +/Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] +>> /Rotate 0 /Trans << + +>> + /Type /Page +>> +endobj +5 0 obj +<< +/PageMode /UseNone /Pages 7 0 R /Type /Catalog +>> +endobj +6 0 obj +<< +/Author (anonymous) /CreationDate (D:20260215130816+00'00') /Creator (Recticel Label System) /Keywords () /ModDate (D:20260215130816+00'00') /Producer (Optimized for Epson TM-T20 / Citizen CTS-310) + /Subject (Production Label) /Title (Thermal Label - Optimized for Label Printers) /Trapped /False +>> +endobj +7 0 obj +<< +/Count 1 /Kids [ 4 0 R ] /Type /Pages +>> +endobj +8 0 obj +<< +/Filter [ /ASCII85Decode /FlateDecode ] /Length 1821 +>> +stream +Gat=-gMRrh&:N/3n?EFq$&<^g3d)DUc.1AU#kf05/)-&XUe&87LYQ1kCsLUd+N*?ec5[>91M:B%)BZ+HYO@^%ZV[iTA&UnhDA>6RC@PWD?-IDu\9p4klCZbC@O>lS:F[3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_>Ms;[,%B`X#H7eSi"];$-QKX.9aAj5K\3nHpSD-G_#i=s4TVMendstream +endobj +xref +0 9 +0000000000 65535 f +0000000073 00000 n +0000000114 00000 n +0000000221 00000 n +0000000333 00000 n +0000000536 00000 n +0000000604 00000 n +0000000924 00000 n +0000000983 00000 n +trailer +<< +/ID +[] +% ReportLab generated PDF document -- digest (http://www.reportlab.com) + +/Info 6 0 R +/Root 5 0 R +/Size 9 +>> +startxref +2895 +%%EOF