Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
MBetterc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mbetter
MBetterc
Commits
1c223d1c
Commit
1c223d1c
authored
Dec 20, 2025
by
Stefy Lanza (nextime / spora )
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ean12 barcode generation
parent
262296b4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
27 deletions
+74
-27
routes.py
mbetterclient/web_dashboard/routes.py
+32
-4
bet_details.html
...client/web_dashboard/templates/dashboard/bet_details.html
+42
-23
No files found.
mbetterclient/web_dashboard/routes.py
View file @
1c223d1c
...
...
@@ -5466,8 +5466,22 @@ def generate_bet_barcode(bet_id):
if
not
enabled
or
standard
==
'none'
:
return
jsonify
({
"error"
:
"Barcodes are not enabled"
}),
404
# Format bet ID for barcode
# First try to get saved barcode data from bet
barcode_data
=
None
session
=
api_bp
.
db_manager
.
get_session
()
try
:
from
..database.models
import
BetModel
bet
=
session
.
query
(
BetModel
)
.
filter_by
(
uuid
=
bet_uuid
)
.
first
()
if
bet
and
bet
.
barcode_data
:
barcode_data
=
bet
.
barcode_data
logger
.
debug
(
f
"Using saved barcode data for bet {bet_uuid}: {barcode_data}"
)
finally
:
session
.
close
()
# If no saved barcode data, format bet ID for barcode (fallback)
if
not
barcode_data
:
barcode_data
=
format_bet_id_for_barcode
(
bet_uuid
,
standard
)
logger
.
debug
(
f
"Using generated barcode data for bet {bet_uuid}: {barcode_data}"
)
# Generate barcode image
barcode_image
=
generate_barcode_image
(
barcode_data
,
standard
,
width
,
height
)
...
...
@@ -5521,8 +5535,22 @@ def get_bet_barcode_data(bet_id):
"barcode_data"
:
None
})
# Format bet ID for barcode
# First try to get saved barcode data from bet
barcode_data
=
None
session
=
api_bp
.
db_manager
.
get_session
()
try
:
from
..database.models
import
BetModel
bet
=
session
.
query
(
BetModel
)
.
filter_by
(
uuid
=
bet_uuid
)
.
first
()
if
bet
and
bet
.
barcode_data
:
barcode_data
=
bet
.
barcode_data
logger
.
debug
(
f
"Using saved barcode data for bet {bet_uuid}: {barcode_data}"
)
finally
:
session
.
close
()
# If no saved barcode data, format bet ID for barcode (fallback)
if
not
barcode_data
:
barcode_data
=
format_bet_id_for_barcode
(
bet_uuid
,
standard
)
logger
.
debug
(
f
"Using generated barcode data for bet {bet_uuid}: {barcode_data}"
)
# Generate barcode image and convert to base64
barcode_image_bytes
=
generate_barcode_image
(
barcode_data
,
standard
,
width
,
height
)
...
...
mbetterclient/web_dashboard/templates/dashboard/bet_details.html
View file @
1c223d1c
...
...
@@ -445,6 +445,8 @@
"fixture_id"
:
"{{ bet.fixture_id }}"
,
"total_amount"
:
{{
bet
.
total_amount
|
round
(
2
)
}},
"bet_count"
:
{{
bet
.
bet_count
}},
"barcode_standard"
:
"{{ bet.barcode_standard }}"
,
"barcode_data"
:
"{{ bet.barcode_data }}"
,
"bet_details"
:
[
{
%
for
detail
in
bet
.
bet_details
%
}
{
...
...
@@ -809,11 +811,21 @@ function generateVerificationCodes(betUuid) {
shouldShowQR
=
false
;
// Default to not showing on error
}
// Check barcode settings
fetch
(
`/api/barcode-data/
${
betUuid
}
`
)
// Check barcode settings - use saved barcode data instead of regenerating
const
betData
=
window
.
betData
;
if
(
betData
&&
betData
.
barcode_data
&&
betData
.
barcode_standard
)
{
// Use saved barcode data from bet
fetch
(
'/api/barcode-settings'
)
.
then
(
response
=>
response
.
json
())
.
then
(
data
=>
{
if
(
data
.
success
&&
data
.
enabled
&&
data
.
barcode_data
&&
data
.
barcode_data
.
show_on_thermal
&&
data
.
barcode_data
.
image_base64
)
{
.
then
(
settings
=>
{
if
(
settings
.
success
&&
settings
.
settings
&&
settings
.
settings
.
show_on_thermal
)
{
// Generate barcode image using the saved barcode data
fetch
(
`/api/barcode/
${
betUuid
}
`
)
.
then
(
response
=>
response
.
blob
())
.
then
(
blob
=>
{
const
reader
=
new
FileReader
();
reader
.
onload
=
function
()
{
const
base64
=
reader
.
result
;
// Add barcode to receipt
const
barcodeHtml
=
`
<div class="receipt-barcode" id="barcode-container-
${
betUuid
}
">
...
...
@@ -826,13 +838,20 @@ function generateVerificationCodes(betUuid) {
// Display barcode
const
barcodeElement
=
document
.
getElementById
(
`barcode-
${
betUuid
}
`
);
if
(
barcodeElement
)
{
barcodeElement
.
innerHTML
=
`<img src="data:image/png;base64,
${
data
.
barcode_data
.
image_base64
}
" alt="Barcode" class="barcode-img" style="width:
${
data
.
barcode_data
.
width
}
px; height:
${
data
.
barcode_data
.
height
}
px;">`
;
barcodeElement
.
innerHTML
=
`<img src="
${
base64
}
" alt="Barcode" class="barcode-img" style="width: 200px; height: 100
px;">`
;
}
};
reader
.
readAsDataURL
(
blob
);
})
.
catch
(
error
=>
{
console
.
warn
(
'Failed to generate barcode image:'
,
error
);
});
}
})
.
catch
(
error
=>
{
console
.
warn
(
'Failed to check barcode settings:'
,
error
);
});
}
}
function
printThermalReceipt
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment