dorsale 2.1.8 → 2.1.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -47,15 +47,45 @@ en:
47
47
  custom_info_2: "custom informations (2)"
48
48
  custom_info_3: "custom informations (3)"
49
49
  logo: "logo"
50
+ pdf:
51
+ your_contact: "Your contact : "
52
+ contact_phone: "Phone : "
53
+ contact_email: "Email : "
54
+ contact_fax: "Fax : "
55
+ subject: "Subject : "
56
+ tracking_number: "Number : "
57
+ date: "Date : "
58
+ customer: "Customer :"
59
+ designation: "DESIGNATION"
60
+ quantity: "QUANTITY"
61
+ unity: "UNITY"
62
+ tax: "TAX %"
63
+ unit_price: "UNIT PRICE"
64
+ line_total: "TOTAL"
65
+ payment_terms: "Payment terms:"
66
+ iban: "IBAN :"
67
+ bic_swift: "BIC / SWIFT :"
68
+ info_phone: "Phone :"
69
+ info_fax: "Fax :"
70
+ capital: "capital :"
71
+ registration: "registration :"
72
+ siret: "SIRET "
73
+ tva: "TVA "
74
+ expires_at: "Expires at : "
50
75
 
51
76
  messages:
52
77
  invoices:
53
78
  create_ok : "Invoice successfully created."
54
79
  update_ok : "Invoice successfully updated."
80
+ create_error : "Impossible to create this invoice."
81
+ update_error : "Impossible to update this invoice."
55
82
  pay_ok : "This invoice has been marked payed."
56
83
  pay_error : "Impossible to mark this invoice as payed."
57
84
  quotations:
58
85
  create_ok : "Quotation successfully created."
59
86
  update_ok : "Quotation successfully created."
87
+ create_error : "Impossible to create this quotation."
88
+ update_error : "Impossible to update this quotation."
60
89
  copy_ok : "Quotation successfully duplicated."
61
90
  create_invoice_ok : "Invoice successfully created from quotation."
91
+
@@ -47,15 +47,48 @@ fr:
47
47
  custom_info_2: "information personalisées (2)"
48
48
  custom_info_3: "information personalisées (3)"
49
49
  logo: "logo"
50
+ pdfs:
51
+ your_contact: "Votre contact : "
52
+ contact_phone: "Téléphone : "
53
+ contact_email: "Email : "
54
+ contact_fax: "Fax : "
55
+ subject: "Objet : "
56
+ tracking_number: "Numéro : "
57
+ date: "Date : "
58
+ customer: "Client :"
59
+ designation: "DÉSIGNATION"
60
+ quantity: "QTITÉ"
61
+ unity: "UNITÉ"
62
+ tax: "TVA %"
63
+ unit_price: "P.U €HT"
64
+ line_total: "TOTAL €HT"
65
+ payment_terms: "Conditions de paiement :"
66
+ iban: "IBAN :"
67
+ bic_swift: "BIC / SWIFT :"
68
+ info_phone: "Tel. :"
69
+ info_fax: "Fax :"
70
+ capital: "au capital de"
71
+ registration: "RCS "
72
+ siret: "SIRET "
73
+ vat: "TVA "
74
+ commercial_discount: "REMISE"
75
+ total_duty: "TOTAL HT"
76
+ advance: "ACOMPTE"
77
+ total_all_taxes: "TOTAL TTC"
78
+ expires_at: "Date d'expiration : "
50
79
 
51
80
  messages:
52
81
  invoices:
53
82
  create_ok : "La facture a été créée."
54
83
  update_ok : "La facture a été modifiée."
84
+ create_error : "Erreur dans la création de la facture."
85
+ update_error : "Erreur dans la modification de la facture."
55
86
  pay_ok : "La facture a été marquée comme payée."
56
87
  pay_error : "Impossible de marquer la facture comme payée."
57
88
  quotations:
58
89
  create_ok : "Le devis a été créé."
59
90
  update_ok : "Le devis a été modifié."
91
+ create_error : "Erreur dans la création du devis."
92
+ update_error : "Erreur dans la modification du devis."
60
93
  copy_ok : "Le devis a été dupliqué."
61
94
  create_invoice_ok : "La facture a été créée depuis le devis"
@@ -43,6 +43,7 @@ require "dorsale/alexandrie/prawn"
43
43
  require "acts-as-taggable-on"
44
44
  require "active_record_comma_type_cast"
45
45
 
46
+
46
47
  module Dorsale
47
48
  class Engine < ::Rails::Engine
48
49
  isolate_namespace Dorsale
@@ -1,3 +1,3 @@
1
1
  module Dorsale
2
- VERSION = "2.1.8"
2
+ VERSION = "2.1.9"
3
3
  end
@@ -2,12 +2,6 @@ require "rails_helper"
2
2
 
3
3
  describe ::Dorsale::BillingMachine::InvoicePdf, pdfs: true do
4
4
 
5
- def self.it_should_write(string)
6
- it "should write '#{string}'" do
7
- text.strings.should include string
8
- end
9
- end
10
-
11
5
  let(:customer) {
12
6
  create(:customer_vault_corporation)
13
7
  }
@@ -29,12 +23,14 @@ describe ::Dorsale::BillingMachine::InvoicePdf, pdfs: true do
29
23
  contact_email: 'email@example.org',
30
24
  iban: 'FR76 0000 0000 0000 0000 0000 000',
31
25
  bic_swift: 'PSSTTHEGAME',
32
- custom_info_1: "Mention légale" + "\n" + "Tout retard de règlement donnera lieu de plein droit et sans qu’aucune mise en demeure ne soit nécessaire au paiement de " +
26
+ custom_info_1: "Tout retard de règlement donnera lieu de plein droit et sans qu’aucune mise en demeure ne soit nécessaire au paiement de " +
33
27
  'pénalités de retard sur la base du taux BCE majoré de dix (10) points et au paiement d’une indemnité forfaitaire pour frais de ' +
34
28
  'recouvrement d’un montant de 999999€'
35
29
  ) }
36
30
 
37
- let(:invoice) { create(:billing_machine_invoice,
31
+ let(:invoice) {
32
+
33
+ i = create(:billing_machine_invoice,
38
34
  date: '16/04/2014',
39
35
  id_card: id_card,
40
36
  customer: customer,
@@ -44,218 +40,202 @@ describe ::Dorsale::BillingMachine::InvoicePdf, pdfs: true do
44
40
  total_all_taxes: 2167.79,
45
41
  advance: 1.79,
46
42
  vat_rate: 19.6,
47
- balance: 2166.0) }
43
+ balance: 2166.0)
48
44
 
49
- let(:invoice_line) { create(:billing_machine_invoice_line,
50
- invoice_id: invoice.id,
45
+ create(:billing_machine_invoice_line,
46
+ invoice: i,
51
47
  quantity: 3.14,
52
48
  unit: 'heures',
53
49
  unit_price: 2.54,
54
- total: 7.98) }
50
+ total: 7.98)
55
51
 
56
- let(:invoice_line_2) { create(:billing_machine_invoice_line,
57
- invoice_id: invoice.id,
52
+ create(:billing_machine_invoice_line,
53
+ invoice: i,
58
54
  label: 'Truc',
59
55
  quantity: 42.42,
60
56
  unit: 'nuts',
61
57
  unit_price: 42.54,
62
- total: 1804.55) }
58
+ total: 1804.55)
59
+
60
+ i.reload
61
+ }
63
62
 
64
63
  let(:pdf) {
65
64
  invoice.pdf
66
65
  }
67
66
 
67
+ let(:content) {
68
+ tempfile = Tempfile.new("pdf")
69
+ tempfile.binmode
70
+ tempfile.write(pdf.render)
71
+ tempfile.flush
72
+ Yomu.new(tempfile.path).text
73
+ }
74
+
68
75
  describe "#initialize" do
69
76
  it 'inherits from Prawn::Document' do
70
- pdf.should be_kind_of(Prawn::Document)
77
+ expect(pdf).to be_kind_of(Prawn::Document)
71
78
  end
72
79
 
73
80
  it 'should assign @main_document' do
74
- pdf.main_document.should eq(invoice)
81
+ expect(pdf.main_document).to eq invoice
75
82
  end
76
83
  end
77
84
 
78
- describe "#build" do
79
- let(:text) { PDF::Inspector::Text.analyze(pdf.render) }
80
-
81
- context 'when the id card is empty' do
82
- let(:id_card) {
83
- ::Dorsale::BillingMachine::IdCard.create(id_card_name: 'default')
84
- }
85
- it 'should not crash' do
86
- pdf.build
87
- end
88
- end
89
-
90
- before do
91
- invoice.lines << invoice_line
92
- invoice.lines << invoice_line_2
85
+ describe 'when the id card is empty' do
86
+ let(:id_card) {
87
+ ::Dorsale::BillingMachine::IdCard.create(id_card_name: 'default')
88
+ }
89
+ it 'should not crash' do
93
90
  pdf.build
94
91
  end
95
- context 'in Mentions légales - Coin supérieur droit' do
96
- it_should_write 'HEYHO'
97
- it_should_write 'SIRET 000 000 000 00000 APE 0000A'
98
- it_should_write 'SARL au capital de 1.000.000.000 euros'
99
- it_should_write 'RCS MARSEILLE 000 000 000'
100
- it_should_write 'N° TVA FR 00 000 000 000 000 00'
101
- it_should_write '42 Avenue de Ruby'
102
- it_should_write '13004 Marseille'
103
- end
104
-
105
- context 'in Entete de facturation' do
92
+ end
106
93
 
107
- it_should_write 'Facture'
94
+ describe 'Id card informations' do
95
+ it 'is expected to print the right information' do
96
+ expect(content).to include 'HEYHO'
97
+ expect(content).to include 'SIRET 000 000 000 00000 '
98
+ expect(content).to include 'SARL au capital de 1.000.000.000 €'
99
+ expect(content).to include 'RCS MARSEILLE 000 000 000'
100
+ expect(content).to include 'TVA FR 00 000 000 000 000 00'
101
+ expect(content).to include '42 Avenue de Ruby'
102
+ expect(content).to include '13004 Marseille'
103
+ end
104
+ end
108
105
 
106
+ describe 'Header' do
109
107
  it "should write invoice tracking id" do
110
- text.strings.should include '' + invoice.tracking_id
108
+ expect(content).to include 'Facture'
109
+ expect(content).to include 'Numéro :'
110
+ expect(content).to include invoice.tracking_id
111
111
  end
112
- it "should write 'Marseille le ' and invoice date" do
113
- text.strings.should include 'Marseille le ' + '16 avril 2014'
114
- end
115
-
116
- context 'in Informations contact' do
117
- it_should_write 'Contact :'
118
- it_should_write ' Jane Doe'
119
- it_should_write 'Tél :'
120
- it_should_write ' +33.6.00.00.00.00'
121
- it_should_write 'Fax:'
122
- it_should_write ' +33.9.00.00.00.00'
123
- it_should_write 'Email:'
124
- it_should_write ' email@example.org'
125
- end
126
-
127
- context 'in Informations client' do
128
- it_should_write 'A l’attention de :'
129
-
130
- it "should write customer name" do
131
- text.strings.should include invoice.customer.name
132
- end
133
112
 
134
- it "should write customer address" do
135
- text.strings.should include invoice.customer.address.street
136
- text.strings.should include invoice.customer.address.street_bis
137
- end
138
-
139
- it "should write customer zip and city" do
140
- text.strings.should include invoice.customer.address.zip.to_s +
141
- ' ' + invoice.customer.address.city.to_s
142
- end
143
-
144
- it "should write customer country" do
145
- text.strings.should include invoice.customer.address.country
146
- end
147
- end # context in Informations client
148
- end # context in Entete de facturation
149
-
150
- it "shoud write 'Objet :' and invoice label" do
151
- text.strings.should include 'Objet :'
152
- text.strings.should include ' ' + invoice.label
113
+ it "is expected to print invoice date" do
114
+ expect(content).to include 'Date : ' + '16/04/2014'
153
115
  end
154
116
 
155
- context "in Tableau" do
156
- it_should_write 'Prestation'
157
- it_should_write 'Prix'
158
- it_should_write 'unitaire'
159
- it_should_write 'Quantité'
160
- it_should_write 'Total HT'
161
-
162
-
163
- context "in Lignes de facturation" do
164
- it 'should write invoice line label of each invoice line' do
165
- invoice.lines.each do |line|
166
- text.strings.should include line.label
167
- end
168
- end
169
-
170
- it 'should write invoice line quantity of each line' do
171
- text.strings.should include '3,14'
172
- text.strings.should include '42,42'
173
- end
174
-
175
- it 'should write invoice line unit_price of each line' do
176
- text.strings.should include '2,54 €'
177
- text.strings.should include '42,54 €'
178
- end
179
-
180
- it 'should write invoice line total of each line' do
181
- text.strings.should include '7,98 €'
182
- text.strings.should include '1.804,55 €'
183
- end
184
- end # context in Lignes de facturation
185
-
186
- context 'in Synthèse' do
117
+ it 'is expected to print contact informations' do
118
+ expect(content).to include 'Jane Doe'
119
+ expect(content).to include 'Téléphone :'
120
+ expect(content).to include ' +33.6.00.00.00.00'
121
+ expect(content).to include 'Fax :'
122
+ expect(content).to include ' +33.9.00.00.00.00'
123
+ expect(content).to include 'Email :'
124
+ expect(content).to include ' email@example.org'
125
+ end
126
+ end
187
127
 
188
- it_should_write 'Remise commerciale'
189
- it_should_write '100,23 €'
128
+ describe 'customer information' do
129
+ it "should write customer name" do
130
+ expect(content).to include 'Client :'
131
+ expect(content).to include invoice.customer.name
132
+ end
190
133
 
191
- it_should_write 'Total HT'
192
- it_should_write '1.712,29 €'
134
+ it "is expected to print customer address" do
135
+ expect(content).to include invoice.customer.address.street
136
+ expect(content).to include invoice.customer.address.street_bis
137
+ end
193
138
 
194
- it_should_write 'TVA 19,6 %'
195
- it_should_write '335,61 €'
139
+ it "is expected to print customer zip and city" do
140
+ expect(content).to include invoice.customer.address.zip.to_s +
141
+ ' ' + invoice.customer.address.city.to_s
142
+ end
196
143
 
197
- it_should_write 'Total TTC'
198
- it_should_write '2.047,90 '
144
+ it "is expected to print 'Objet :' and invoice label" do
145
+ expect(content).to include 'Objet : '
146
+ expect(content).to include invoice.label
147
+ end
148
+ end
199
149
 
200
- it_should_write 'Acompte reçu sur commande'
201
- it_should_write '1,79 €'
150
+ describe "product table" do
151
+ it "is expected to print the header" do
152
+ expect(content).to include 'DÉSIGNATION'
153
+ expect(content).to include 'QTITÉ'
154
+ expect(content).to include 'UNITÉ'
155
+ expect(content).to include 'P.U €HT'
156
+ expect(content).to include 'TOTAL €HT'
157
+ end
158
+ it 'is expected to print invoice line label of each invoice line' do
159
+ invoice.lines.each do |line|
160
+ expect(content).to include line.label
161
+ end
162
+ end
202
163
 
203
- it_should_write 'Solde à payer'
204
- it 'should write balance calculated using total_all_taxes - advance' do
205
- text.strings.should include '2.046,11 €'
206
- end
164
+ it 'is expected to print invoice line quantity of each line' do
165
+ expect(content).to include '3,14'
166
+ expect(content).to include '42,42'
167
+ end
207
168
 
169
+ it 'is expected to print invoice line unit_price of each line' do
170
+ expect(content).to include '2,54 €'
171
+ expect(content).to include '42,54 €'
172
+ end
208
173
 
209
- context 'without advance' do
174
+ it 'is expected to print invoice line total of each line' do
175
+ expect(content).to include '7,98 €'
176
+ expect(content).to include '1 804,55 €'
177
+ end
178
+ end
210
179
 
211
- before(:each) do
212
- invoice_incomplete=create(:billing_machine_invoice, total_duty: 1000, vat_amount: 196,
213
- total_all_taxes: 1196, advance: 0, balance: 1146 , customer: customer,
214
- date: '2014-04-16', vat_rate: 19.6, id_card: id_card)
215
- pdf_incomplete = invoice_incomplete.pdf
216
- pdf_incomplete.build
217
- @text_incomplete = PDF::Inspector::Text.analyze(pdf_incomplete.render)
218
- end
180
+ describe 'Total table' do
181
+ it 'is expected to print all the invoice synthesis' do
182
+ expect(content).to include 'REMISE'
183
+ expect(content).to include '- 100,23 €'
184
+ expect(content).to include 'TOTAL HT'
185
+ expect(content).to include '1 712,29 €'
186
+ expect(content).to include 'TVA 19,60 %'
187
+ expect(content).to include '335,61 €'
188
+ expect(content).to include 'ACOMPTE'
189
+ expect(content).to include '1,79 €'
190
+ expect(content).to include 'TOTAL TTC'
191
+ expect(content).to include '2 046,11 €'
192
+ end
193
+ end
219
194
 
220
- it 'should not write Acompte reçu sur commande' do
221
- @text_incomplete.strings.should_not include 'Acompte reçu sur commande'
222
- end
223
195
 
224
- it 'should not write Remise commerciale' do
225
- @text_incomplete.strings.should_not include 'Remise commerciale'
226
- end
196
+ describe 'Footer' do
197
+ it 'is expected to print invoice payment term' do
198
+ expect(content).to include 'Conditions de paiement :'
199
+ expect(content).to include invoice.payment_term.label
200
+ end
227
201
 
228
- it 'should not write Solde à payer' do
229
- @text_incomplete.strings.should_not include 'Solde à payer'
230
- end
202
+ it 'is expected to print current and total page number' do
203
+ expect(content).to include 'page 1/1'
204
+ end
231
205
 
232
- end
233
- end
234
- end # context in Tableau
235
- it_should_write 'Conditions de paiement :'
206
+ it 'is expected to print invoice legals and banks' do
207
+ expect(content).to include 'IBAN : FR76 0000 0000 0000 0000 0000 000'
208
+ expect(content).to include 'BIC / SWIFT : PSSTTHEGAME'
209
+ expect(content).to include 'Tout retard de règlement donnera lieu de plein droit et sans qu’aucune mise en demeure ne soit nécessaire au paiement de'
210
+ expect(content).to include 'pénalités de retard sur la base du taux BCE majoré de dix (10) points et au paiement d’une indemnité forfaitaire pour frais de'
211
+ expect(content).to include 'recouvrement d’un montant de 999999€'
212
+ end
213
+ end
236
214
 
237
- it 'should write invoice payment term' do
238
- text.strings.should include invoice.payment_term.label
215
+ describe 'incomplete invoice' do
216
+ before(:each) do
217
+ invoice_incomplete=create(:billing_machine_invoice, total_duty: 1000, vat_amount: 196,
218
+ total_all_taxes: 1196, advance: 0, balance: 1146 , customer: customer,
219
+ date: '2014-04-16', vat_rate: 19.6, id_card: id_card)
220
+ pdf_incomplete = invoice_incomplete.pdf
221
+ pdf_incomplete.build
222
+ tempfile = Tempfile.new("pdf")
223
+ tempfile.binmode
224
+ tempfile.write(pdf_incomplete.render)
225
+ tempfile.flush
226
+ @incomplete_content = Yomu.new(tempfile.path).text
239
227
  end
240
228
 
241
- it_should_write 'Coordonnées bancaires :'
242
- it_should_write 'IBAN : FR76 0000 0000 0000 0000 0000 000'
243
- it_should_write 'BIC / SWIFT : PSSTTHEGAME'
229
+ it 'is expected not to print ACOMPTE' do
230
+ expect(@incomplete_content).to_not include 'ACOMPTE'
231
+ end
244
232
 
245
- context 'in Mentions légales - Bas de page' do
246
- it_should_write 'Mention légale'
247
- it_should_write 'Tout retard de règlement donnera lieu de plein droit et sans qu’aucune mise en demeure ne soit nécessaire au paiement de'
248
- it_should_write 'pénalités de retard sur la base du taux BCE majoré de dix (10) points et au paiement d’une indemnité forfaitaire pour frais de'
249
- it_should_write 'recouvrement d’un montant de 999999€'
233
+ it 'is expected not to print REMISE' do
234
+ expect(@incomplete_content).to_not include 'REMISE'
250
235
  end
251
- end # describe #build
252
236
 
253
- describe "missing data" do
254
- it "missing payment_term should be OK" do
255
- invoice = create(:billing_machine_invoice, payment_term: nil)
256
- pdf = invoice.pdf
257
- pdf.build
258
- PDF::Inspector::Text.analyze(pdf.render)
237
+ it 'is expected to print TOTAL TTC' do
238
+ expect(@incomplete_content).to include 'TOTAL TTC'
259
239
  end
260
240
  end
261
- end
241
+ end