Files
quality_app-v2/test_barcode_format.py
Quality App Developer e2a6553fe9 updated format
2026-02-15 17:58:26 +02:00

71 lines
2.3 KiB
Python

#!/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)")