|
@@ -176,28 +176,54 @@ def generate_predracun(order_id, company_name, company_pib, company_address, amo
|
|
|
pdf.cell(30, 8, "Iznos / Total", border=1, fill=True, align='R', ln=True)
|
|
pdf.cell(30, 8, "Iznos / Total", border=1, fill=True, align='R', ln=True)
|
|
|
|
|
|
|
|
# Table Content
|
|
# Table Content
|
|
|
- pdf.set_font("helvetica", "", 10)
|
|
|
|
|
|
|
+ pdf.set_font("helvetica", "", 9)
|
|
|
|
|
+ pdv_rate = getattr(config, 'PDV_RATE', 21)
|
|
|
|
|
+
|
|
|
|
|
+ total_base = 0.0
|
|
|
|
|
+ total_pdv = 0.0
|
|
|
|
|
+
|
|
|
if not items:
|
|
if not items:
|
|
|
- # Fallback if no specific file items provided
|
|
|
|
|
|
|
+ # Fallback
|
|
|
|
|
+ price_total = float(amount)
|
|
|
|
|
+ price_base = price_total / (1 + pdv_rate/100)
|
|
|
|
|
+ pdv_amount = price_total - price_base
|
|
|
|
|
+ total_base = price_base
|
|
|
|
|
+ total_pdv = pdv_amount
|
|
|
|
|
+
|
|
|
pdf.cell(10, 8, "1", border=1)
|
|
pdf.cell(10, 8, "1", border=1)
|
|
|
pdf.cell(100, 8, f"Usluge 3D stampe (Narudzba {order_id})", border=1)
|
|
pdf.cell(100, 8, f"Usluge 3D stampe (Narudzba {order_id})", border=1)
|
|
|
pdf.cell(20, 8, "1", border=1, align='C')
|
|
pdf.cell(20, 8, "1", border=1, align='C')
|
|
|
- pdf.cell(30, 8, format_amount(amount), border=1, align='R')
|
|
|
|
|
- pdf.cell(30, 8, format_amount(amount), border=1, align='R', ln=True)
|
|
|
|
|
|
|
+ pdf.cell(30, 8, format_amount(price_base), border=1, align='R')
|
|
|
|
|
+ pdf.cell(30, 8, format_amount(price_total), border=1, align='R', ln=True)
|
|
|
else:
|
|
else:
|
|
|
for i, item in enumerate(items):
|
|
for i, item in enumerate(items):
|
|
|
pdf.cell(10, 8, str(i + 1), border=1)
|
|
pdf.cell(10, 8, str(i + 1), border=1)
|
|
|
pdf.cell(100, 8, str(item.get('name', '3D Print'))[:50], border=1)
|
|
pdf.cell(100, 8, str(item.get('name', '3D Print'))[:50], border=1)
|
|
|
pdf.cell(20, 8, str(item.get('quantity', 1)), border=1, align='C')
|
|
pdf.cell(20, 8, str(item.get('quantity', 1)), border=1, align='C')
|
|
|
- price = float(item.get('price', 0))
|
|
|
|
|
- pdf.cell(30, 8, format_amount(price), border=1, align='R')
|
|
|
|
|
- pdf.cell(30, 8, format_amount(price * item.get('quantity', 1)), border=1, align='R', ln=True)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ p_total = float(item.get('price', 0)) * item.get('quantity', 1)
|
|
|
|
|
+ p_base = p_total / (1 + pdv_rate/100)
|
|
|
|
|
+ p_pdv = p_total - p_base
|
|
|
|
|
+
|
|
|
|
|
+ total_base += p_base
|
|
|
|
|
+ total_pdv += p_pdv
|
|
|
|
|
+
|
|
|
|
|
+ pdf.cell(30, 8, format_amount(p_base / item.get('quantity', 1)), border=1, align='R')
|
|
|
|
|
+ pdf.cell(30, 8, format_amount(p_total), border=1, align='R', ln=True)
|
|
|
|
|
+
|
|
|
|
|
+ # Breakdown
|
|
|
|
|
+ pdf.ln(5)
|
|
|
|
|
+ pdf.set_font("helvetica", "", 10)
|
|
|
|
|
+ pdf.cell(160, 6, "Osnovica / Base Amount:", align='R')
|
|
|
|
|
+ pdf.cell(30, 6, format_amount(total_base), align='R', ln=True)
|
|
|
|
|
+
|
|
|
|
|
+ pdf.cell(160, 6, f"PDV {pdv_rate}% / VAT Amount:", align='R')
|
|
|
|
|
+ pdf.cell(30, 6, format_amount(total_pdv), align='R', ln=True)
|
|
|
|
|
|
|
|
# Total
|
|
# Total
|
|
|
- pdf.ln(5)
|
|
|
|
|
pdf.set_font("helvetica", "B", 12)
|
|
pdf.set_font("helvetica", "B", 12)
|
|
|
pdf.cell(160, 10, "UKUPNO / TOTAL (EUR):", align='R')
|
|
pdf.cell(160, 10, "UKUPNO / TOTAL (EUR):", align='R')
|
|
|
- pdf.cell(30, 10, format_amount(amount), align='R', ln=True)
|
|
|
|
|
|
|
+ pdf.cell(30, 10, format_amount(float(amount)), align='R', ln=True)
|
|
|
|
|
|
|
|
# Footer
|
|
# Footer
|
|
|
pdf.ln(20)
|
|
pdf.ln(20)
|