- 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 passible 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.
+ 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 passible 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 }}
-
+
Total
+
{{ .Total }}
diff --git a/cmd/pdf/main.go b/cmd/pdf/main.go
new file mode 100644
index 0000000..83f34f3
--- /dev/null
+++ b/cmd/pdf/main.go
@@ -0,0 +1,123 @@
+package main
+
+import (
+ "bytes"
+ "html/template"
+ "log"
+ "os"
+)
+
+func main() {
+ // Define the invoice data structure
+ type Invoice struct {
+ Host struct {
+ Name string
+ Address string
+ ZipCode string
+ City string
+ Phone string
+ Email string
+ }
+ Name string
+ PhoneNumber string
+ CustomersNumber int
+ Platform string
+ ID string
+ From string
+ To string
+ Total string
+ AmountPaid string
+ BalanceDue string
+ Lines []struct {
+ Name string
+ Quantity int
+ Price string
+ Total string
+ }
+ Payments []struct {
+ Date string
+ Method string
+ Amount string
+ }
+ }
+
+ // Read the template file
+ tmpl, err := template.ParseFiles("assets/html/invoice.html")
+ if err != nil {
+ log.Fatalf("Error parsing template: %v", err)
+ }
+
+ // Create sample invoice data
+ invoice := Invoice{
+ Host: struct {
+ Name string
+ Address string
+ ZipCode string
+ City string
+ Phone string
+ Email string
+ }{
+ Name: "VillaFleurie",
+ Address: "4 rue Gerty Archimede",
+ ZipCode: "97190",
+ City: "Le Gosier",
+ Phone: "+590 690 44 15 30",
+ Email: "location.villafleurie@gmail.com",
+ },
+ Name: "VillaFleurie",
+ PhoneNumber: "+590 690 44 15 30",
+ CustomersNumber: 2,
+ Platform: "Privée",
+ ID: "VFNI0332",
+ From: "15 Janvier 2025",
+ To: "15 Mars 2025",
+ Total: "2065.00 €",
+ AmountPaid: "1565.00 €",
+ BalanceDue: "500.00 €",
+ Lines: []struct {
+ Name string
+ Quantity int
+ Price string
+ Total string
+ }{
+ {
+ Name: "T2",
+ Quantity: 59,
+ Price: "35.00",
+ Total: "2065.00",
+ },
+ },
+ Payments: []struct {
+ Date string
+ Method string
+ Amount string
+ }{
+ {
+ "–",
+ "Espèces",
+ "500.00",
+ },
+ {
+ "–",
+ "Chèque",
+ "1065.00",
+ },
+ },
+ }
+
+ // Create a buffer to store the rendered HTML
+ var buf bytes.Buffer
+
+ // Execute the template with the invoice data
+ if err := tmpl.Execute(&buf, invoice); err != nil {
+ log.Fatalf("Error executing template: %v", err)
+ }
+
+ // Write the rendered HTML to a file
+ outputPath := "output.html"
+ if err := os.WriteFile(outputPath, buf.Bytes(), 0644); err != nil {
+ log.Fatalf("Error writing HTML file: %v", err)
+ }
+
+ log.Printf("HTML file created successfully: %s", outputPath)
+}
diff --git a/internal/service/booking/mocks_test.go b/internal/service/booking/mocks_test.go
index 279eacb..500af71 100644
--- a/internal/service/booking/mocks_test.go
+++ b/internal/service/booking/mocks_test.go
@@ -71,6 +71,16 @@ func (m *MockStore) UpdateItem(id int, item string, paymentMethod string, paymen
return args.Get(0).(*Item), args.Error(1)
}
+func (m *MockStore) CreatePayment(p *Payment) (*Payment, error) {
+ args := m.Called(p)
+ return args.Get(0).(*Payment), args.Error(1)
+}
+
+// MockParserClient is a mock implementation of the parser.Client interface
+type MockParserClient struct {
+ mock.Mock
+}
+
// MockCalendarClient is a mock implementation of the calendar.Client interface
type MockCalendarClient struct {
mock.Mock
diff --git a/internal/service/booking/sync_test.go b/internal/service/booking/sync_test.go
deleted file mode 100644
index 8d549a5..0000000
--- a/internal/service/booking/sync_test.go
+++ /dev/null
@@ -1,59 +0,0 @@
-package booking_test
-
-import (
- "testing"
- "time"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/rjNemo/rentease/internal/service/booking"
-)
-
-const content = " Date d'arrivée jeu. 3 avr. 2025 Date de départ dim. 6 avr. 2025 Durée de séjour : 3 nuits Nombre de personnes : \n 2\n Nombre d'hébergements \n 1\n Montant total € 186 Nom du client : \n Olga Korovina\n \n ru\n \n okorov.905387@guest.booking.com\n Contactez vos clients ! Indiquez-leur l'heure à laquelle vous souhaitez les accueillir ou l'endroit où ils récupéreront leurs clés. Un simple appel suffit : Afficher le numéro de téléphone Vous pouvez également leur envoyer un e-mail ou un message. Langue préférée \n russe\n Canal : Booking.com Code IATA/TIDS : \n PC029090\n Numéro de réservation : \n 4453602306\n Montant soumis à commission : € 177 Reçu jeu. 2 janv. 2025 Commission : € 31,86 Bloc-notes (usage interne) Ajoutez une note ici \n\n Maison 1 Chambre T2 - VillaFleurie au bourg du Gosier)\n € 186 jeu. 3 avr. 2025 dim. 6 avr. 2025 Nom du client \n Olga Korovina\n Occupation maximum 2 adultes, 2 enfants (3 personnes max.) Photo de l'hébergement Date Tarif Tarif par nuit \n 03 - 04 avril\n \n Standard Rate\n € 59\n 04 - 05 avril\n \n Standard Rate\n € 59\n 05 - 06 avril\n \n Standard Rate\n € 59Sous-total € 177\n Taxe de séjour\n € 1.50 par personne et par nuit € 9Tarif total de l'hébergement € 186 Le tarif comprend 8.9 % de TVA Conversation avec le client \n Aucun message\n \n Les conversations avec vos clients apparaîtront ici.\n Booking.com reçoit tous les messages écrits ici et les traite selon sa Charte de confidentialité et informations sur les cookies Conditions "
-
-func TestParseFromApi(t *testing.T) {
- externalId := "4453602306"
- tests := []struct {
- name string
- rawContent string
- expected *booking.Booking
- }{
- {
- name: "parse booking from raw content",
- rawContent: content,
- expected: &booking.Booking{
- From: time.Date(2025, time.April, 3, 0, 0, 0, 0, time.UTC),
- To: time.Date(2025, time.April, 6, 0, 0, 0, 0, time.UTC),
- Name: "Olga Korovina",
- Email: "okorov.905387@guest.booking.com",
- Platform: "Booking",
- CustomerNumber: 2,
- PlatformFees: 31.86,
- ExternalId: &externalId,
- Canceled: false,
- Items: []booking.Item{
- {
- BookingId: 0,
- Item: "T2",
- Quantity: 3,
- Price: 59.0,
- PaymentMethod: "Card",
- },
- },
- },
- },
- }
-
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- t.Parallel()
- bs, _ := booking.NewService(&booking.MockStore{}, nil, nil, nil)
-
- actual, err := bs.ParseFromApi(tt.rawContent)
- if err != nil {
- t.Errorf("unexpected error: %v", err)
- }
- assert.Equal(t, tt.expected, actual, "expected %v, got %v", tt.expected, actual)
- })
- }
-}
diff --git a/justfile b/justfile
index fa34875..fb26a22 100644
--- a/justfile
+++ b/justfile
@@ -48,3 +48,7 @@ format:
# Lint the code
lint:
@golangci-lint run ./...
+
+pdf:
+ @go run cmd/pdf/main.go
+ @open output.html
diff --git a/output.html b/output.html
new file mode 100644
index 0000000..6f0c951
--- /dev/null
+++ b/output.html
@@ -0,0 +1,292 @@
+
+
+
+
+
+
+
+
+ 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 passible 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.
+