diff --git a/assets/html/invoice.html b/assets/html/invoice.html new file mode 100644 index 0000000..bdb9732 --- /dev/null +++ b/assets/html/invoice.html @@ -0,0 +1,115 @@ + + + Au : +ss="text-break product_name"> + {{ row.name }} + + {{ row.quantity }} +e d'intérêts de retard. Le montant des pénalités résulte de l'application aux sommes restant dues d'un taux d'intérêt légal en vigueur au moment de l'incident.
+ + +
+
+
+
+ Total +
+
+ {{ total }} € +
+
+
+ + {{row.price }} € + {{ row.total }} € + + {% endfor %} + + + +
+
+ Notes
+ TVA non applicable, art. 293 B du CGI
+ Dispensé d’immatriculation au registre du commerce et des sociétés (RCS) et au répertoire des métiers.
+ Conditions de paiement : paiement à réception de facture. Aucun escompte consenti pour règlement anticipé ou désistement. Tout incident de paiement est passibl {{ to }} + + + + + Montant : + {{ total }} € + + + +
+
+
+ + + + + + + + + + + {% for row in lines %} + +
ObjetQuantitéPrixTotal
+ + + + + + + +
+ +
+ {{ host.name }}
+ {{ host.address }}
+ {{ host.zip_code}} {{ host.city }}
+ Tel : {{ host.phone }}
+ Mail : {{ host.email }}
+
+
+
+
+ + + + + + + + + + + + + + + + + + +
+ {{name}}
+ Tel : {{phone_number}}
+ Voyageurs : {{ customers_number }}
+ Plateforme : {{platform}}
+ + + + + + + + + + + diff --git a/config/host.go b/config/host.go index 16b7e6b..09d455d 100644 --- a/config/host.go +++ b/config/host.go @@ -1,6 +1,12 @@ package config type Host struct { + Name string + Address string + City string + ZipCode string + PhoneNumber string + Email string InvoicePrefix string PaymentMethods []string Platforms []string @@ -15,6 +21,12 @@ type HostItem struct { func NewHost() *Host { return &Host{ + Name: "VillaFleurie", + Address: "4 rue Gerty Archimede", + City: "Le Gosier", + ZipCode: "97190", + PhoneNumber: "+590 690 44 15 30", + Email: "location.villafleurie@gmail.com", CustomerSeed: 239, InvoicePrefix: "VFNI", PaymentMethods: []string{"Card", "Cash", "Cheque", "Transfer"}, diff --git a/internal/pdf/service.go b/internal/pdf/service.go index 984f014..e0152bd 100644 --- a/internal/pdf/service.go +++ b/internal/pdf/service.go @@ -45,6 +45,14 @@ func (ps PdfService) BuildInvoice(b *booking.Booking, hc *config.Host) error { ProjectId string `json:"projectId"` }{ Context: map[string]any{ + "host": map[string]any{ + "name": hc.Name, + "address": hc.Address, + "zip": hc.ZipCode, + "city": hc.City, + "phone": hc.PhoneNumber, + "email": hc.Email, + }, "id": b.InvoiceNumber(hc), "name": b.Name, "phone_number": b.PhoneNumber, @@ -74,7 +82,50 @@ func (ps PdfService) BuildInvoice(b *booking.Booking, hc *config.Host) error { return err } - // build request to third-party API + return ps.sendData(payload) +} + +func (ps PdfService) BuildReport(r *booking.Report) error { + // data := struct { + // Context map[string]any `w` + // Path string `json:"path"` + // ProjectId string `json:"projectId"` + // }{ + // Context: map[string]any{ + // "id": r.InvoiceNumber(hc), + // "name": r.Name, + // "phone_number": r.PhoneNumber, + // "customers_number": r.CustomerNumber, + // "platform": r.Platform, + // "from": r.From.Format("02/01/2006"), + // "to": r.To.Format("02/01/2006"), + // "lines": u.Map(b.Items, func(i booking.Item) map[string]any { + // return map[string]any{ + // "name": i.Item, + // "quantity": i.Quantity, + // "price": i.Price, + // "total": i.Price * float64(i.Quantity), + // } + // }), + // "total": strconv.FormatFloat(u.Reduce(b.Items, func(i booking.Item, sum float64) float64 { + // return sum + i.Price*float64(i.Quantity) + // }, 0.0), 'f', 2, 64), + // }, + // Path: ps.invoicePath, + // ProjectId: ps.projectId, + // } + + // payload, err := json.Marshal(data) + // if err != nil { + // log.Warnf("Error marshalling JSON:", err) + // return err + // } + // + // return ps.sendData(payload) + return nil +} + +func (ps PdfService) sendData(payload []byte) error { req, err := http.NewRequest("POST", ps.url, bytes.NewBuffer(payload)) if err != nil { log.Warnf("Error creating request:", err) diff --git a/internal/views/base.templ b/internal/views/base.templ index 560d3a3..88efe3d 100644 --- a/internal/views/base.templ +++ b/internal/views/base.templ @@ -10,7 +10,7 @@ templ BaseLayout() { - +
+ Nº de facture : {{id}}
+ Du : {{ from }}