Forráskód Böngészése

feat: add PDV (VAT) calculation and breakdown in Predracun

unknown 6 napja
szülő
commit
d09788f43c

+ 1 - 0
backend/config.py

@@ -34,3 +34,4 @@ ZIRO_RACUN = "510-1234567890123-45"
 COMPANY_NAME = "RADIONICA 3D"
 COMPANY_PIB = "01234567"
 COMPANY_ADDRESS = "Cetinjski Put, Podgorica, Montenegro"
+PDV_RATE = 21 # In percent

+ 35 - 9
backend/services/uplatnica_generator.py

@@ -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)
 
     # 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:
-        # 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(100, 8, f"Usluge 3D stampe (Narudzba {order_id})", border=1)
         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:
         for i, item in enumerate(items):
             pdf.cell(10, 8, str(i + 1), 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')
-            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
-    pdf.ln(5)
     pdf.set_font("helvetica", "B", 12)
     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
     pdf.ln(20)

+ 1 - 0
src/components/ModelUploadSection.vue

@@ -253,6 +253,7 @@
             <div class="text-right">
               <span class="text-3xl font-display font-bold text-primary">{{ estimatedPrice }}</span>
               <span class="text-xs font-bold text-primary ml-1 uppercase">EUR</span>
+              <p class="text-[9px] text-muted-foreground mt-1 opacity-60">incl. 21% PDV</p>
             </div>
           </div>
         </Transition>