fix(loyalty): use Code 128 barcode for retail scanner compatibility
Switch wallet pass barcodes from QR to Code 128 format using the card_number (digits only), so standard retail barcode scanners can read loyalty cards. Apple Wallet keeps QR as fallback in barcodes array. Also fix stale Vendor.loyalty_program relationship (now company-based), add parent init calls in vendor JS components, and update module docs to reflect Phase 2 completion. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -125,16 +125,23 @@ class AppleWalletService:
|
||||
"authenticationToken": card.apple_auth_token,
|
||||
"webServiceURL": self._get_web_service_url(),
|
||||
"barcode": {
|
||||
"message": card.qr_code_data,
|
||||
"format": "PKBarcodeFormatQR",
|
||||
"message": card.card_number.replace("-", ""),
|
||||
"format": "PKBarcodeFormatCode128",
|
||||
"messageEncoding": "iso-8859-1",
|
||||
"altText": card.card_number,
|
||||
},
|
||||
"barcodes": [
|
||||
{
|
||||
"message": card.card_number.replace("-", ""),
|
||||
"format": "PKBarcodeFormatCode128",
|
||||
"messageEncoding": "iso-8859-1",
|
||||
"altText": card.card_number,
|
||||
},
|
||||
{
|
||||
"message": card.qr_code_data,
|
||||
"format": "PKBarcodeFormatQR",
|
||||
"messageEncoding": "iso-8859-1",
|
||||
}
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
@@ -275,8 +275,9 @@ class GoogleWalletService:
|
||||
"accountId": card.card_number,
|
||||
"accountName": card.card_number,
|
||||
"barcode": {
|
||||
"type": "QR_CODE",
|
||||
"value": card.qr_code_data,
|
||||
"type": "CODE_128",
|
||||
"value": card.card_number.replace("-", ""),
|
||||
"alternateText": card.card_number,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,12 @@ function vendorLoyaltyCardDetail() {
|
||||
if (window._loyaltyCardDetailInitialized) return;
|
||||
window._loyaltyCardDetailInitialized = true;
|
||||
|
||||
// IMPORTANT: Call parent init first to set vendorCode from URL
|
||||
const parentInit = data().init;
|
||||
if (parentInit) {
|
||||
await parentInit.call(this);
|
||||
}
|
||||
|
||||
// Extract card ID from URL
|
||||
const pathParts = window.location.pathname.split('/');
|
||||
const cardsIndex = pathParts.indexOf('cards');
|
||||
|
||||
@@ -41,6 +41,12 @@ function vendorLoyaltyCards() {
|
||||
if (window._loyaltyCardsInitialized) return;
|
||||
window._loyaltyCardsInitialized = true;
|
||||
|
||||
// IMPORTANT: Call parent init first to set vendorCode from URL
|
||||
const parentInit = data().init;
|
||||
if (parentInit) {
|
||||
await parentInit.call(this);
|
||||
}
|
||||
|
||||
if (window.PlatformSettings) {
|
||||
this.pagination.per_page = await window.PlatformSettings.getRowsPerPage();
|
||||
}
|
||||
|
||||
@@ -29,6 +29,12 @@ function vendorLoyaltyEnroll() {
|
||||
if (window._loyaltyEnrollInitialized) return;
|
||||
window._loyaltyEnrollInitialized = true;
|
||||
|
||||
// IMPORTANT: Call parent init first to set vendorCode from URL
|
||||
const parentInit = data().init;
|
||||
if (parentInit) {
|
||||
await parentInit.call(this);
|
||||
}
|
||||
|
||||
await this.loadProgram();
|
||||
loyaltyEnrollLog.info('=== LOYALTY ENROLL PAGE INITIALIZATION COMPLETE ===');
|
||||
},
|
||||
|
||||
@@ -30,6 +30,12 @@ function vendorLoyaltySettings() {
|
||||
if (window._loyaltySettingsInitialized) return;
|
||||
window._loyaltySettingsInitialized = true;
|
||||
|
||||
// IMPORTANT: Call parent init first to set vendorCode from URL
|
||||
const parentInit = data().init;
|
||||
if (parentInit) {
|
||||
await parentInit.call(this);
|
||||
}
|
||||
|
||||
await this.loadSettings();
|
||||
loyaltySettingsLog.info('=== LOYALTY SETTINGS PAGE INITIALIZATION COMPLETE ===');
|
||||
},
|
||||
|
||||
@@ -29,6 +29,12 @@ function vendorLoyaltyStats() {
|
||||
if (window._loyaltyStatsInitialized) return;
|
||||
window._loyaltyStatsInitialized = true;
|
||||
|
||||
// IMPORTANT: Call parent init first to set vendorCode from URL
|
||||
const parentInit = data().init;
|
||||
if (parentInit) {
|
||||
await parentInit.call(this);
|
||||
}
|
||||
|
||||
await this.loadStats();
|
||||
loyaltyStatsLog.info('=== LOYALTY STATS PAGE INITIALIZATION COMPLETE ===');
|
||||
},
|
||||
|
||||
@@ -52,6 +52,12 @@ function vendorLoyaltyTerminal() {
|
||||
}
|
||||
window._loyaltyTerminalInitialized = true;
|
||||
|
||||
// IMPORTANT: Call parent init first to set vendorCode from URL
|
||||
const parentInit = data().init;
|
||||
if (parentInit) {
|
||||
await parentInit.call(this);
|
||||
}
|
||||
|
||||
await this.loadData();
|
||||
|
||||
loyaltyTerminalLog.info('=== LOYALTY TERMINAL INITIALIZATION COMPLETE ===');
|
||||
|
||||
@@ -253,14 +253,6 @@ class Vendor(Base, TimestampMixin):
|
||||
cascade="all, delete-orphan",
|
||||
)
|
||||
|
||||
# Loyalty program (one-to-one)
|
||||
loyalty_program = relationship(
|
||||
"LoyaltyProgram",
|
||||
back_populates="vendor",
|
||||
uselist=False,
|
||||
cascade="all, delete-orphan",
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
"""String representation of the Vendor object."""
|
||||
return f"<Vendor(id={self.id}, vendor_code='{self.vendor_code}', name='{self.name}', subdomain='{self.subdomain}')>"
|
||||
|
||||
Reference in New Issue
Block a user