package de.assecutor.votianlt.model;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;

@Data
@NoArgsConstructor
public class InvoiceData {

    // Invoice details
    private String invoiceNumber;
    private LocalDate invoiceDate;
    private LocalDate dueDate;

    // Company information (sender)
    private String companyName;
    private String companyStreet;
    private String companyHouseNumber;
    private String companyZip;
    private String companyCity;
    private String companyPhone;
    private String companyEmail;
    private String companyWebsite;

    // Tax information
    private String taxNumber; // Steuernummer
    private String vatId; // USt-IdNr
    private String commercialRegister; // Handelsregistereintrag
    private String managingDirector; // Geschäftsführer

    // Bank details
    private String bankName;
    private String iban;
    private String bic;

    // Customer information (recipient)
    private String customerName;
    private String customerStreet;
    private String customerHouseNumber;
    private String customerZip;
    private String customerCity;
    private String customerCountry;

    // Invoice items
    private List<InvoiceItem> items;

    // Totals
    private BigDecimal subtotal;
    private BigDecimal vatAmount;
    private BigDecimal totalAmount;
    private BigDecimal vatRate = BigDecimal.valueOf(19.0); // 19% standard VAT rate

    @Data
    @NoArgsConstructor
    public static class InvoiceItem {
        private String description;
        private BigDecimal quantity;
        private String unit; // e.g., "Stück", "km", "h"
        private BigDecimal unitPrice;
        private BigDecimal totalPrice;
        private BigDecimal vatRate;

        public InvoiceItem(String description, BigDecimal quantity, String unit,
                          BigDecimal unitPrice, BigDecimal vatRate) {
            this.description = description;
            this.quantity = quantity;
            this.unit = unit;
            this.unitPrice = unitPrice;
            this.vatRate = vatRate;
            this.totalPrice = quantity.multiply(unitPrice);
        }
    }
}