Kgshop commited on
Commit
c3cdd4e
·
verified ·
1 Parent(s): ecd4d72

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +75 -57
app.py CHANGED
@@ -2059,12 +2059,13 @@ ORDER_TEMPLATE = '''
2059
  .customer-details span { font-weight: 600; color: #1a1a1a; }
2060
 
2061
  .table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 20px; border-radius: 8px; border: 1px solid var(--border); }
2062
- table { width: 100%; border-collapse: collapse; }
2063
- th, td { border-bottom: 1px solid var(--border); padding: 10px 5px; text-align: center; font-size: 0.9rem; }
2064
- th { background: #fafafa; font-weight: 700; color: #636e72; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.5px; }
2065
- .img-cell img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; border: 1px solid #eee; }
 
2066
  .total-row { background: #fafafa; font-weight: 800; }
2067
- .total-row td { font-size: 1rem; border-bottom: none; }
2068
 
2069
  .cart-item-controls { display: inline-flex; align-items: center; background: var(--surface); border-radius: 8px; border: 1px solid var(--border); overflow: hidden; margin-bottom: 5px; }
2070
  .cart-item-controls button { border: none; background: #f8f9fa; width: 30px; height: 30px; font-size: 1rem; cursor: pointer; color: var(--primary); transition: background 0.2s; }
@@ -2106,28 +2107,22 @@ ORDER_TEMPLATE = '''
2106
  body.invoice-mode table { min-width: 100%; }
2107
  body.invoice-mode th, body.invoice-mode td { border: 1px solid #000; }
2108
 
2109
- body.receipt-mode { padding: 0; background: #fff; margin: 0; }
2110
  body.receipt-mode .invoice-box { display: none !important; }
2111
- body.receipt-mode .receipt-box { display: block !important; width: 100%; max-width: 80mm; margin: 0 auto; font-family: 'Courier New', Courier, monospace; font-size: 12px; color: #000; padding: 5px; }
2112
- body.receipt-mode .receipt-box table { width: 100%; border-collapse: collapse; margin: 5px 0; border: none; }
2113
- body.receipt-mode .receipt-box th, body.receipt-mode .receipt-box td { padding: 4px 0; text-align: left; vertical-align: top; border-bottom: 1px dashed #ccc; font-size: 12px; border-top: none; border-left: none; border-right: none; }
2114
  body.receipt-mode .receipt-box .dashed-line { border-top: 1px dashed #000; margin: 5px 0; }
2115
  }
2116
  @media (max-width: 600px) {
2117
- body { padding: 10px 10px calc(100px + env(safe-area-inset-bottom)); }
2118
- .invoice-box { padding: 15px 10px; border-radius: 12px; }
2119
- .header h1 { font-size: 1.3rem; }
2120
- .info-row { font-size: 0.85rem; flex-direction: column; gap: 5px; }
2121
- .info-row > div { align-items: flex-start !important; }
2122
- .table-responsive { border: none; margin-bottom: 10px; }
2123
- th, td { padding: 6px 2px; font-size: 0.75rem; }
2124
- th { font-size: 0.65rem; }
2125
- .img-col { display: none !important; }
2126
- .cart-item-controls button { width: 22px; height: 22px; font-size: 0.8rem; }
2127
- .cart-item-controls input { width: 26px; font-size: 0.8rem; }
2128
- .total-row td { font-size: 0.85rem; }
2129
- .btn { padding: 12px 10px; font-size: 0.9rem; }
2130
- .btn i { font-size: 1.1rem; }
2131
  }
2132
  </style>
2133
  </head>
@@ -2200,9 +2195,9 @@ ORDER_TEMPLATE = '''
2200
  <table>
2201
  <thead>
2202
  <tr>
2203
- <th style="width: 40px;">№</th>
2204
  <th style="text-align: left;">Наименование</th>
2205
- <th class="img-col">Фото</th>
2206
  <th>Кол-во</th>
2207
  <th>Цена</th>
2208
  <th>Сумма</th>
@@ -2215,7 +2210,7 @@ ORDER_TEMPLATE = '''
2215
  {% set assembled = order.assembled.get(item.c_key, 0) if order.assembled else 0 %}
2216
  {% if item.quantity > 0 %}
2217
  <tr>
2218
- <td>{{ loop.index }}</td>
2219
  <td style="text-align: left; font-weight: 500;">
2220
  {{ item.name }}
2221
  <div style="font-size: 0.75rem; color: #b2bec3; margin-top: 2px;">Категория: {{ item.category }}</div>
@@ -2227,7 +2222,7 @@ ORDER_TEMPLATE = '''
2227
  <div style="font-size: 0.8rem; color: #e17055; margin-top: 2px;">Скидка: -{{ item.discount }} {{ currency_code }} за ед.</div>
2228
  {% endif %}
2229
  </td>
2230
- <td class="img-cell img-col"><img src="{{ item.photo_url }}" alt="img"></td>
2231
  <td style="text-align: center;">
2232
  <div class="screen-only">
2233
  <div style="display:flex; flex-direction:column; align-items:center; gap:4px;">
@@ -2280,7 +2275,7 @@ ORDER_TEMPLATE = '''
2280
  {% endif %}
2281
  {% endfor %}
2282
  <tr class="total-row">
2283
- <td colspan="6" style="text-align: right; padding-right: 15px; border-bottom: none;">
2284
  Общее кол-во: {{ total_qty }} шт<br>
2285
  {% if order.global_discount > 0 %}
2286
  <div style="color:#e17055; font-size:0.9rem; margin-bottom:5px;">Применена общая скидка: -{{ order.global_discount }} {{ currency_code }}</div>
@@ -2288,14 +2283,14 @@ ORDER_TEMPLATE = '''
2288
  {% if settings.commission_enabled and order.commission_amount and order.commission_amount > 0 %}
2289
  <div style="color:#0984e3; font-size:0.9rem; margin-bottom:5px;">Комиссия ({{ settings.commission_percent }}%): +{{ order.commission_amount }} {{ currency_code }}</div>
2290
  {% endif %}
2291
- <div style="font-size: 1.2rem; margin-top: 5px;">Итого: {{ order.total_price }} {{ currency_code }}</div>
2292
  </td>
2293
  </tr>
2294
  </tbody>
2295
  </table>
2296
  </div>
2297
 
2298
- <div class="qr-codes print-only">
2299
  {% if settings.qr_code_1_url %}
2300
  <img src="{{ settings.qr_code_1_url }}" alt="QR Code 1">
2301
  {% endif %}
@@ -2306,39 +2301,53 @@ ORDER_TEMPLATE = '''
2306
  </div>
2307
 
2308
  <div class="receipt-box">
2309
- <div style="text-align: center; margin-bottom: 10px;">
2310
  <div style="font-weight: bold; font-size: 16px;">{{ settings.organization_name }}</div>
2311
  {% if settings.invoice_contacts %}
 
2312
  {% for contact in settings.invoice_contacts.split(',') %}
2313
- {% if contact.strip() %}<div>{{ contact.strip() }}</div>{% endif %}
 
 
2314
  {% endfor %}
 
2315
  {% endif %}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2316
  </div>
2317
- <div class="dashed-line"></div>
2318
- <div><strong>Чек №:</strong> {{ order.id }}</div>
2319
- <div><strong>Дата:</strong> {{ order.created_at }}</div>
2320
- {% if order.customer_name %}<div><strong>Клиент:</strong> {{ order.customer_name }}</div>{% endif %}
2321
- {% if order.staff_name %}<div><strong>Кассир:</strong> {{ order.staff_name }}</div>{% endif %}
2322
  <div class="dashed-line"></div>
2323
 
2324
- <table style="width:100%; margin: 10px 0; border:none;">
2325
  <thead>
2326
  <tr>
2327
- <th style="text-align:left; border-bottom:1px dashed #000; padding-bottom:5px;">Товар</th>
2328
- <th style="text-align:center; border-bottom:1px dashed #000; padding-bottom:5px;">Кол</th>
2329
- <th style="text-align:right; border-bottom:1px dashed #000; padding-bottom:5px;">Сумма</th>
2330
  </tr>
2331
  </thead>
2332
  <tbody>
2333
  {% for item in order.cart %}
2334
  {% if item.quantity > 0 %}
2335
  <tr>
2336
- <td style="padding: 5px 0; border:none;">
2337
  {{ item.name }}{% if item.variant_name %} ({{ item.variant_name }}){% endif %}<br>
2338
- <span style="font-size:10px; color:#555;">{{ item.calculated_price | round(2) }} {{ currency_code }}</span>
2339
  </td>
2340
- <td style="text-align:center; padding: 5px 0; border:none;">{{ item.quantity }}</td>
2341
- <td style="text-align:right; padding: 5px 0; border:none;">{{ (item.calculated_price * item.quantity) | round(2) }}</td>
2342
  </tr>
2343
  {% endif %}
2344
  {% endfor %}
@@ -2346,40 +2355,49 @@ ORDER_TEMPLATE = '''
2346
  </table>
2347
 
2348
  <div class="dashed-line"></div>
2349
- <div style="display: flex; justify-content: space-between; margin-top: 5px;">
2350
- <span>Итого кол-во:</span>
2351
- <span>{{ total_qty }}</span>
2352
  </div>
2353
  {% if order.global_discount > 0 %}
2354
- <div style="display: flex; justify-content: space-between;">
2355
  <span>Скидка:</span>
2356
  <span>-{{ order.global_discount }} {{ currency_code }}</span>
2357
  </div>
2358
  {% endif %}
2359
  {% if settings.commission_enabled and order.commission_amount and order.commission_amount > 0 %}
2360
- <div style="display: flex; justify-content: space-between;">
2361
  <span>Комиссия:</span>
2362
  <span>+{{ order.commission_amount }} {{ currency_code }}</span>
2363
  </div>
2364
  {% endif %}
2365
- <div style="display: flex; justify-content: space-between; font-weight: bold; font-size: 14px; margin-top: 5px;">
2366
- <span>ИТОГО:</span>
 
2367
  <span>{{ order.total_price }} {{ currency_code }}</span>
2368
  </div>
2369
 
2370
  {% if order.is_debt %}
2371
- <div style="display: flex; justify-content: space-between; margin-top: 5px;">
2372
  <span>Оплачено:</span>
2373
  <span>{{ order.paid_amount }} {{ currency_code }}</span>
2374
  </div>
2375
- <div style="display: flex; justify-content: space-between; font-weight: bold;">
2376
  <span>В ДОЛГ:</span>
2377
  <span>{{ order.debt_amount }} {{ currency_code }}</span>
2378
  </div>
 
2379
  {% endif %}
2380
-
2381
- <div class="dashed-line" style="margin-top:10px;"></div>
2382
- <div style="text-align: center; margin-top: 10px; font-size: 12px;">Спасибо за покупку!</div>
 
 
 
 
 
 
 
2383
  </div>
2384
 
2385
  <div class="action-bar">
 
2059
  .customer-details span { font-weight: 600; color: #1a1a1a; }
2060
 
2061
  .table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 20px; border-radius: 8px; border: 1px solid var(--border); }
2062
+ table { width: 100%; border-collapse: collapse; min-width: 100%; }
2063
+ th, td { border-bottom: 1px solid var(--border); padding: 12px; text-align: center; font-size: 0.95rem; }
2064
+ th { background: #fafafa; font-weight: 700; color: #636e72; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.5px; }
2065
+ .num-col { display: table-cell; }
2066
+ .img-cell img { width: 45px; height: 45px; object-fit: cover; border-radius: 8px; border: 1px solid #eee; }
2067
  .total-row { background: #fafafa; font-weight: 800; }
2068
+ .total-row td { font-size: 1.1rem; border-bottom: none; }
2069
 
2070
  .cart-item-controls { display: inline-flex; align-items: center; background: var(--surface); border-radius: 8px; border: 1px solid var(--border); overflow: hidden; margin-bottom: 5px; }
2071
  .cart-item-controls button { border: none; background: #f8f9fa; width: 30px; height: 30px; font-size: 1rem; cursor: pointer; color: var(--primary); transition: background 0.2s; }
 
2107
  body.invoice-mode table { min-width: 100%; }
2108
  body.invoice-mode th, body.invoice-mode td { border: 1px solid #000; }
2109
 
2110
+ body.receipt-mode { padding: 0; background: #fff; display: block; }
2111
  body.receipt-mode .invoice-box { display: none !important; }
2112
+ body.receipt-mode .receipt-box { display: block !important; width: 80mm; margin: 0 auto; font-family: 'Courier New', Courier, monospace; font-size: 12px; color: #000; }
 
 
2113
  body.receipt-mode .receipt-box .dashed-line { border-top: 1px dashed #000; margin: 5px 0; }
2114
  }
2115
  @media (max-width: 600px) {
2116
+ .header h1 { font-size: 1.4rem; }
2117
+ .info-row { font-size: 0.9rem; }
2118
+ .invoice-box { padding: 15px 10px; }
2119
+ .btn { font-size: 0.9rem; flex-direction: column; padding: 10px; gap: 4px; }
2120
+ .btn i { font-size: 1.2rem; }
2121
+ th, td { padding: 6px 4px; font-size: 0.8rem; }
2122
+ .img-cell img { width: 35px; height: 35px; }
2123
+ .cart-item-controls input { width: 30px; font-size: 0.9rem; }
2124
+ .cart-item-controls button { width: 24px; height: 24px; font-size: 0.8rem; }
2125
+ .num-col { display: none; }
 
 
 
 
2126
  }
2127
  </style>
2128
  </head>
 
2195
  <table>
2196
  <thead>
2197
  <tr>
2198
+ <th class="num-col" style="width: 40px;">№</th>
2199
  <th style="text-align: left;">Наименование</th>
2200
+ <th>Фот��</th>
2201
  <th>Кол-во</th>
2202
  <th>Цена</th>
2203
  <th>Сумма</th>
 
2210
  {% set assembled = order.assembled.get(item.c_key, 0) if order.assembled else 0 %}
2211
  {% if item.quantity > 0 %}
2212
  <tr>
2213
+ <td class="num-col">{{ loop.index }}</td>
2214
  <td style="text-align: left; font-weight: 500;">
2215
  {{ item.name }}
2216
  <div style="font-size: 0.75rem; color: #b2bec3; margin-top: 2px;">Категория: {{ item.category }}</div>
 
2222
  <div style="font-size: 0.8rem; color: #e17055; margin-top: 2px;">Скидка: -{{ item.discount }} {{ currency_code }} за ед.</div>
2223
  {% endif %}
2224
  </td>
2225
+ <td class="img-cell"><img src="{{ item.photo_url }}" alt="img"></td>
2226
  <td style="text-align: center;">
2227
  <div class="screen-only">
2228
  <div style="display:flex; flex-direction:column; align-items:center; gap:4px;">
 
2275
  {% endif %}
2276
  {% endfor %}
2277
  <tr class="total-row">
2278
+ <td colspan="6" style="text-align: right; padding-right: 20px;">
2279
  Общее кол-во: {{ total_qty }} шт<br>
2280
  {% if order.global_discount > 0 %}
2281
  <div style="color:#e17055; font-size:0.9rem; margin-bottom:5px;">Применена общая скидка: -{{ order.global_discount }} {{ currency_code }}</div>
 
2283
  {% if settings.commission_enabled and order.commission_amount and order.commission_amount > 0 %}
2284
  <div style="color:#0984e3; font-size:0.9rem; margin-bottom:5px;">Комиссия ({{ settings.commission_percent }}%): +{{ order.commission_amount }} {{ currency_code }}</div>
2285
  {% endif %}
2286
+ Итого: {{ order.total_price }} {{ currency_code }}
2287
  </td>
2288
  </tr>
2289
  </tbody>
2290
  </table>
2291
  </div>
2292
 
2293
+ <div class="qr-codes">
2294
  {% if settings.qr_code_1_url %}
2295
  <img src="{{ settings.qr_code_1_url }}" alt="QR Code 1">
2296
  {% endif %}
 
2301
  </div>
2302
 
2303
  <div class="receipt-box">
2304
+ <div style="text-align: center;">
2305
  <div style="font-weight: bold; font-size: 16px;">{{ settings.organization_name }}</div>
2306
  {% if settings.invoice_contacts %}
2307
+ <div style="font-size: 12px;">
2308
  {% for contact in settings.invoice_contacts.split(',') %}
2309
+ {% if contact.strip() %}
2310
+ <div>{{ contact.strip() }}</div>
2311
+ {% endif %}
2312
  {% endfor %}
2313
+ </div>
2314
  {% endif %}
2315
+ <div class="dashed-line"></div>
2316
+ <div style="font-weight: bold; font-size: 14px;">ТОВАРНЫЙ ЧЕК № {{ order.id }}</div>
2317
+ <div style="font-size: 12px;">{{ order.created_at }}</div>
2318
+ <div class="dashed-line"></div>
2319
+ </div>
2320
+
2321
+ <div style="font-size: 12px; margin-bottom: 5px;">
2322
+ {% if order.status != 'pos' and order.status != 'returned' %}
2323
+ {% if order.customer_name %}<div>Покупатель: {{ order.customer_name }}</div>{% endif %}
2324
+ {% if order.customer_phone %}<div>Тел: {{ order.customer_phone }}</div>{% endif %}
2325
+ {% else %}
2326
+ <div>Покупатель: {{ order.customer_name if order.customer_name else 'Розничный покупатель' }}</div>
2327
+ {% if order.customer_whatsapp %}<div>WA: {{ order.customer_whatsapp }}</div>{% endif %}
2328
+ {% endif %}
2329
+ {% if order.staff_name %}<div>Кассир: {{ order.staff_name }}</div>{% endif %}
2330
  </div>
 
 
 
 
 
2331
  <div class="dashed-line"></div>
2332
 
2333
+ <table style="width: 100%; font-size: 12px; text-align: left; border-collapse: collapse;">
2334
  <thead>
2335
  <tr>
2336
+ <th style="padding-bottom: 5px; border:none; text-align: left;">Товар</th>
2337
+ <th style="text-align: center; padding-bottom: 5px; border:none;">Кол</th>
2338
+ <th style="text-align: right; padding-bottom: 5px; border:none;">Сумма</th>
2339
  </tr>
2340
  </thead>
2341
  <tbody>
2342
  {% for item in order.cart %}
2343
  {% if item.quantity > 0 %}
2344
  <tr>
2345
+ <td style="padding: 3px 5px 3px 0; border:none; text-align: left;">
2346
  {{ item.name }}{% if item.variant_name %} ({{ item.variant_name }}){% endif %}<br>
2347
+ <span style="font-size: 10px; color: #555;">{{ item.calculated_price | round(2) }} {{ currency_code }}</span>
2348
  </td>
2349
+ <td style="text-align: center; padding: 3px 0; vertical-align: top; border:none;">{{ item.quantity }}</td>
2350
+ <td style="text-align: right; padding: 3px 0; vertical-align: top; border:none;">{{ (item.calculated_price * item.quantity) | round(2) }}</td>
2351
  </tr>
2352
  {% endif %}
2353
  {% endfor %}
 
2355
  </table>
2356
 
2357
  <div class="dashed-line"></div>
2358
+ <div style="display: flex; justify-content: space-between; font-size: 12px; margin: 3px 0;">
2359
+ <span>Итог ({{ total_qty }} шт):</span>
2360
+ <span>{{ order.total_price }} {{ currency_code }}</span>
2361
  </div>
2362
  {% if order.global_discount > 0 %}
2363
+ <div style="display: flex; justify-content: space-between; font-size: 12px; margin: 3px 0;">
2364
  <span>Скидка:</span>
2365
  <span>-{{ order.global_discount }} {{ currency_code }}</span>
2366
  </div>
2367
  {% endif %}
2368
  {% if settings.commission_enabled and order.commission_amount and order.commission_amount > 0 %}
2369
+ <div style="display: flex; justify-content: space-between; font-size: 12px; margin: 3px 0;">
2370
  <span>Комиссия:</span>
2371
  <span>+{{ order.commission_amount }} {{ currency_code }}</span>
2372
  </div>
2373
  {% endif %}
2374
+ <div class="dashed-line"></div>
2375
+ <div style="display: flex; justify-content: space-between; font-weight: bold; font-size: 16px; margin: 10px 0;">
2376
+ <span>К ОПЛАТЕ:</span>
2377
  <span>{{ order.total_price }} {{ currency_code }}</span>
2378
  </div>
2379
 
2380
  {% if order.is_debt %}
2381
+ <div style="display: flex; justify-content: space-between; font-size: 12px; margin-top: 5px;">
2382
  <span>Оплачено:</span>
2383
  <span>{{ order.paid_amount }} {{ currency_code }}</span>
2384
  </div>
2385
+ <div style="display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 5px; color: #d63031;">
2386
  <span>В ДОЛГ:</span>
2387
  <span>{{ order.debt_amount }} {{ currency_code }}</span>
2388
  </div>
2389
+ <div class="dashed-line"></div>
2390
  {% endif %}
2391
+
2392
+ <div style="text-align: center; margin-top: 10px;">
2393
+ {% if settings.qr_code_1_url %}
2394
+ <img src="{{ settings.qr_code_1_url }}" style="max-width: 100px; display: inline-block; margin: 5px;">
2395
+ {% endif %}
2396
+ {% if settings.qr_code_2_url %}
2397
+ <img src="{{ settings.qr_code_2_url }}" style="max-width: 100px; display: inline-block; margin: 5px;">
2398
+ {% endif %}
2399
+ </div>
2400
+ <div style="text-align: center; margin-top: 15px; font-size: 12px; font-weight: bold;">*** СПАСИБО ЗА ПОКУПКУ! ***</div>
2401
  </div>
2402
 
2403
  <div class="action-bar">