dorsale 2.1.8 → 2.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/fonts/BryantPro-Bold.otf +0 -0
- data/app/assets/fonts/BryantPro-Bold.ttf +0 -0
- data/app/assets/fonts/BryantPro-Regular.otf +0 -0
- data/app/assets/fonts/BryantPro-Regular.ttf +0 -0
- data/app/assets/fonts/fonts/BryantPro-Bold.otf +0 -0
- data/app/assets/fonts/fonts/BryantPro-Bold.ttf +0 -0
- data/app/assets/fonts/fonts/BryantPro-Regular.otf +0 -0
- data/app/assets/fonts/fonts/BryantPro-Regular.ttf +0 -0
- data/app/pdfs/dorsale/billing_machine/invoice_pdf.rb +345 -135
- data/app/pdfs/dorsale/billing_machine/quotation_pdf.rb +23 -20
- data/config/locales/billing_machine.en.yml +30 -0
- data/config/locales/billing_machine.fr.yml +33 -0
- data/lib/dorsale/engine.rb +1 -0
- data/lib/dorsale/version.rb +1 -1
- data/spec/pdfs/dorsale/billing_machine/invoice_pdf_spec.rb +151 -171
- data/spec/pdfs/dorsale/billing_machine/quotation_pdf_spec.rb +166 -168
- metadata +10 -2
@@ -1,18 +1,6 @@
|
|
1
1
|
require "rails_helper"
|
2
2
|
|
3
|
-
describe ::Dorsale::BillingMachine::
|
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
|
-
def self.it_should_not_write(string)
|
12
|
-
it "should write '#{string}'" do
|
13
|
-
text.strings.should_not include string
|
14
|
-
end
|
15
|
-
end
|
3
|
+
describe ::Dorsale::BillingMachine::QuotationPdf, pdfs: true do
|
16
4
|
|
17
5
|
let(:customer) {
|
18
6
|
create(:customer_vault_corporation)
|
@@ -35,14 +23,15 @@ describe ::Dorsale::BillingMachine::InvoicePdf, pdfs: true do
|
|
35
23
|
contact_email: 'email@example.org',
|
36
24
|
iban: 'FR76 0000 0000 0000 0000 0000 000',
|
37
25
|
bic_swift: 'PSSTTHEGAME',
|
38
|
-
custom_info_1: "
|
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 " +
|
39
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 ' +
|
40
28
|
'recouvrement d’un montant de 999999€'
|
41
29
|
) }
|
42
30
|
|
43
|
-
let(:quotation) {
|
31
|
+
let(:quotation) {
|
32
|
+
|
33
|
+
q = create(:billing_machine_quotation,
|
44
34
|
date: '16/04/2014',
|
45
|
-
expires_at: '10/06/2014',
|
46
35
|
id_card: id_card,
|
47
36
|
customer: customer,
|
48
37
|
commercial_discount: 100.23,
|
@@ -50,211 +39,220 @@ describe ::Dorsale::BillingMachine::InvoicePdf, pdfs: true do
|
|
50
39
|
vat_amount: 355.26,
|
51
40
|
total_all_taxes: 2167.79,
|
52
41
|
vat_rate: 19.6,
|
53
|
-
comments: 'this is the quotation comment')
|
42
|
+
comments: 'this is the quotation comment')
|
54
43
|
|
55
|
-
|
56
|
-
|
44
|
+
create(:billing_machine_quotation_line,
|
45
|
+
quotation: q,
|
57
46
|
quantity: 3.14,
|
58
47
|
unit: 'heures',
|
59
48
|
unit_price: 2.54,
|
60
|
-
total: 7.98)
|
49
|
+
total: 7.98)
|
61
50
|
|
62
|
-
|
63
|
-
|
51
|
+
create(:billing_machine_quotation_line,
|
52
|
+
quotation: q,
|
64
53
|
label: 'Truc',
|
65
54
|
quantity: 42.42,
|
66
55
|
unit: 'nuts',
|
67
56
|
unit_price: 42.54,
|
68
|
-
total: 1804.55)
|
57
|
+
total: 1804.55)
|
69
58
|
|
70
|
-
|
59
|
+
q.reload
|
60
|
+
}
|
61
|
+
|
62
|
+
let(:pdf) {
|
63
|
+
quotation.pdf
|
64
|
+
}
|
65
|
+
|
66
|
+
let(:content) {
|
67
|
+
tempfile = Tempfile.new("pdf")
|
68
|
+
tempfile.binmode
|
69
|
+
tempfile.write(pdf.render)
|
70
|
+
tempfile.flush
|
71
|
+
Yomu.new(tempfile.path).text
|
72
|
+
}
|
71
73
|
|
72
74
|
describe "#initialize" do
|
73
75
|
it 'inherits from Prawn::Document' do
|
74
|
-
pdf.
|
75
|
-
end
|
76
|
-
|
77
|
-
it 'inherits from CommonQuotation' do
|
78
|
-
pdf.should be_kind_of(::Dorsale::BillingMachine::QuotationPdf)
|
76
|
+
expect(pdf).to be_kind_of(Prawn::Document)
|
79
77
|
end
|
80
78
|
|
81
79
|
it 'should assign @main_document' do
|
82
|
-
|
80
|
+
expect(pdf.main_document).to eq quotation
|
83
81
|
end
|
84
82
|
end
|
85
83
|
|
86
|
-
describe
|
87
|
-
let(:
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
it 'should not crash' do
|
92
|
-
pdf.build
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
before do
|
97
|
-
quotation.lines << quotation_line
|
98
|
-
quotation.lines << quotation_line_2
|
84
|
+
describe 'when the id card is empty' do
|
85
|
+
let(:id_card) {
|
86
|
+
::Dorsale::BillingMachine::IdCard.create(id_card_name: 'default')
|
87
|
+
}
|
88
|
+
it 'should not crash' do
|
99
89
|
pdf.build
|
100
90
|
end
|
101
|
-
|
102
|
-
it_should_write 'HEYHO'
|
103
|
-
it_should_write 'SIRET 000 000 000 00000 APE 0000A'
|
104
|
-
it_should_write 'SARL au capital de 1.000.000.000 euros'
|
105
|
-
it_should_write 'RCS MARSEILLE 000 000 000'
|
106
|
-
it_should_write 'N° TVA FR 00 000 000 000 000 00'
|
107
|
-
it_should_write '42 Avenue de Ruby'
|
108
|
-
it_should_write '13004 Marseille'
|
109
|
-
end
|
110
|
-
|
111
|
-
context 'in Entete de facturation' do
|
91
|
+
end
|
112
92
|
|
113
|
-
|
93
|
+
describe 'Id card informations' do
|
94
|
+
it 'is expected to print the right information' do
|
95
|
+
expect(content).to include 'HEYHO'
|
96
|
+
expect(content).to include 'SIRET 000 000 000 00000 '
|
97
|
+
expect(content).to include 'SARL au capital de 1.000.000.000 €'
|
98
|
+
expect(content).to include 'RCS MARSEILLE 000 000 000'
|
99
|
+
expect(content).to include 'TVA FR 00 000 000 000 000 00'
|
100
|
+
expect(content).to include '42 Avenue de Ruby'
|
101
|
+
expect(content).to include '13004 Marseille'
|
102
|
+
end
|
103
|
+
end
|
114
104
|
|
105
|
+
describe 'Header' do
|
115
106
|
it "should write invoice tracking id" do
|
116
|
-
|
107
|
+
expect(content).to include 'Devis'
|
108
|
+
expect(content).to include 'Numéro :'
|
109
|
+
expect(content).to include quotation.tracking_id
|
117
110
|
end
|
118
|
-
it "should write 'Marseille le ' and invoice date" do
|
119
|
-
text.strings.should include 'Marseille le ' + '16 avril 2014'
|
120
|
-
end
|
121
|
-
|
122
|
-
context 'in Informations contact' do
|
123
|
-
it_should_write 'Contact :'
|
124
|
-
it_should_write ' Jane Doe'
|
125
|
-
it_should_write 'Tél :'
|
126
|
-
it_should_write ' +33.6.00.00.00.00'
|
127
|
-
it_should_write 'Fax:'
|
128
|
-
it_should_write ' +33.9.00.00.00.00'
|
129
|
-
it_should_write 'Email:'
|
130
|
-
it_should_write ' email@example.org'
|
131
|
-
end
|
132
|
-
|
133
|
-
context 'in Informations client' do
|
134
|
-
it_should_write 'A l’attention de :'
|
135
|
-
|
136
|
-
it "should write customer name" do
|
137
|
-
text.strings.should include quotation.customer.name
|
138
|
-
end
|
139
|
-
|
140
|
-
it "should write customer address" do
|
141
|
-
text.strings.should include quotation.customer.address.street
|
142
|
-
text.strings.should include quotation.customer.address.street_bis
|
143
|
-
end
|
144
|
-
|
145
|
-
it "should write customer zip and city" do
|
146
|
-
text.strings.should include quotation.customer.address.zip.to_s +
|
147
|
-
' ' + quotation.customer.address.city.to_s
|
148
|
-
end
|
149
111
|
|
150
|
-
|
151
|
-
|
152
|
-
end
|
153
|
-
end # context in Informations client
|
154
|
-
end # context in Entete de facturation
|
155
|
-
|
156
|
-
it "shoud write 'Objet :' and invoice label" do
|
157
|
-
text.strings.should include 'Objet :'
|
158
|
-
text.strings.should include ' ' + quotation.label
|
112
|
+
it "is expected to print invoice date" do
|
113
|
+
expect(content).to include 'Date : ' + '16/04/2014'
|
159
114
|
end
|
160
115
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
116
|
+
it 'is expected to print contact informations' do
|
117
|
+
expect(content).to include 'Jane Doe'
|
118
|
+
expect(content).to include 'Téléphone :'
|
119
|
+
expect(content).to include ' +33.6.00.00.00.00'
|
120
|
+
expect(content).to include 'Fax :'
|
121
|
+
expect(content).to include ' +33.9.00.00.00.00'
|
122
|
+
expect(content).to include 'Email :'
|
123
|
+
expect(content).to include ' email@example.org'
|
124
|
+
end
|
125
|
+
end
|
167
126
|
|
127
|
+
describe 'customer information' do
|
128
|
+
it "should write customer name" do
|
129
|
+
expect(content).to include 'Client :'
|
130
|
+
expect(content).to include quotation.customer.name
|
131
|
+
end
|
168
132
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
end
|
174
|
-
end
|
133
|
+
it "is expected to print customer address" do
|
134
|
+
expect(content).to include quotation.customer.address.street
|
135
|
+
expect(content).to include quotation.customer.address.street_bis
|
136
|
+
end
|
175
137
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
138
|
+
it "is expected to print customer zip and city" do
|
139
|
+
expect(content).to include quotation.customer.address.zip.to_s +
|
140
|
+
' ' + quotation.customer.address.city.to_s
|
141
|
+
end
|
180
142
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
143
|
+
it "is expected to print 'Objet :' and invoice label" do
|
144
|
+
expect(content).to include 'Objet : '
|
145
|
+
expect(content).to include quotation.label
|
146
|
+
end
|
147
|
+
end
|
185
148
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
149
|
+
describe "product table" do
|
150
|
+
it "is expected to print the header" do
|
151
|
+
expect(content).to include 'DÉSIGNATION'
|
152
|
+
expect(content).to include 'QTITÉ'
|
153
|
+
expect(content).to include 'UNITÉ'
|
154
|
+
expect(content).to include 'P.U €HT'
|
155
|
+
expect(content).to include 'TOTAL €HT'
|
156
|
+
end
|
157
|
+
it 'is expected to print invoice line label of each invoice line' do
|
158
|
+
quotation.lines.each do |line|
|
159
|
+
expect(content).to include line.label
|
160
|
+
end
|
161
|
+
end
|
191
162
|
|
192
|
-
|
163
|
+
it 'is expected to print invoice line quantity of each line' do
|
164
|
+
expect(content).to include '3,14'
|
165
|
+
expect(content).to include '42,42'
|
166
|
+
end
|
193
167
|
|
194
|
-
|
195
|
-
|
168
|
+
it 'is expected to print invoice line unit_price of each line' do
|
169
|
+
expect(content).to include '2,54 €'
|
170
|
+
expect(content).to include '42,54 €'
|
171
|
+
end
|
196
172
|
|
197
|
-
|
198
|
-
|
173
|
+
it 'is expected to print invoice line total of each line' do
|
174
|
+
expect(content).to include '7,98 €'
|
175
|
+
expect(content).to include '1 804,55 €'
|
176
|
+
end
|
177
|
+
end
|
199
178
|
|
200
|
-
|
201
|
-
|
179
|
+
describe 'Total table' do
|
180
|
+
it 'is expected to print all the invoice synthesis' do
|
181
|
+
expect(content).to include 'REMISE'
|
182
|
+
expect(content).to include '- 100,23 €'
|
183
|
+
expect(content).to include 'TOTAL HT'
|
184
|
+
expect(content).to include '1 712,29 €'
|
185
|
+
expect(content).to include 'TVA 19,60 %'
|
186
|
+
expect(content).to include '335,61 €'
|
187
|
+
expect(content).to_not include 'ACOMPTE'
|
188
|
+
expect(content).to include 'TOTAL TTC'
|
189
|
+
expect(content).to include '2 047,90 €'
|
190
|
+
end
|
191
|
+
end
|
202
192
|
|
203
|
-
it_should_write 'Total TTC'
|
204
|
-
it_should_write '2.047,90 €'
|
205
193
|
|
206
|
-
|
207
|
-
|
194
|
+
describe 'Footer' do
|
195
|
+
it 'is expected to print invoice payment term' do
|
196
|
+
expect(content).to include 'Conditions de paiement :'
|
197
|
+
expect(content).to include quotation.payment_term.label
|
198
|
+
end
|
208
199
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
end
|
200
|
+
it 'is expected to print current and total page number' do
|
201
|
+
expect(content).to include 'page 1/1'
|
202
|
+
end
|
213
203
|
|
214
|
-
|
215
|
-
|
216
|
-
|
204
|
+
it 'is expected to print current and total page number' do
|
205
|
+
expect(content).to include quotation.comments
|
206
|
+
end
|
217
207
|
|
218
|
-
|
208
|
+
it 'is expected to print invoice legals and banks' do
|
209
|
+
expect(content).to_not include 'IBAN : FR76 0000 0000 0000 0000 0000 000'
|
210
|
+
expect(content).to_not include 'BIC / SWIFT : PSSTTHEGAME'
|
211
|
+
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'
|
212
|
+
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'
|
213
|
+
expect(content).to include 'recouvrement d’un montant de 999999€'
|
214
|
+
end
|
215
|
+
end
|
219
216
|
|
220
|
-
|
221
|
-
|
217
|
+
describe 'incomplete invoice' do
|
218
|
+
before(:each) do
|
219
|
+
quotation_incomplete = create(:billing_machine_quotation, total_duty: 1000, vat_amount: 196,
|
220
|
+
total_all_taxes: 1196,customer: customer, date: '2014-04-16', vat_rate: 19.6, id_card: id_card)
|
221
|
+
pdf_incomplete = quotation_incomplete.pdf
|
222
|
+
pdf_incomplete.build
|
223
|
+
tempfile = Tempfile.new("pdf")
|
224
|
+
tempfile.binmode
|
225
|
+
tempfile.write(pdf_incomplete.render)
|
226
|
+
tempfile.flush
|
227
|
+
@incomplete_content = Yomu.new(tempfile.path).text
|
222
228
|
end
|
223
229
|
|
224
|
-
|
225
|
-
|
226
|
-
|
230
|
+
it 'is expected not to print ACOMPTE' do
|
231
|
+
expect(@incomplete_content).to_not include 'ACOMPTE'
|
232
|
+
end
|
227
233
|
|
228
|
-
|
229
|
-
|
234
|
+
it 'is expected not to print REMISE' do
|
235
|
+
expect(@incomplete_content).to_not include 'REMISE'
|
230
236
|
end
|
231
237
|
|
232
|
-
|
233
|
-
|
234
|
-
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'
|
235
|
-
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'
|
236
|
-
it_should_write 'recouvrement d’un montant de 999999€'
|
238
|
+
it 'is expected to print TOTAL TTC' do
|
239
|
+
expect(@incomplete_content).to include 'TOTAL TTC'
|
237
240
|
end
|
238
|
-
end
|
241
|
+
end
|
239
242
|
|
240
|
-
describe "
|
241
|
-
it "
|
242
|
-
quotation
|
243
|
-
|
243
|
+
describe "attachment" do
|
244
|
+
it "should build attachments" do
|
245
|
+
quotation = create(:billing_machine_quotation)
|
246
|
+
attachment = create(:alexandrie_attachment, attachable: quotation)
|
247
|
+
pdf = quotation.pdf
|
244
248
|
pdf.build
|
245
|
-
|
249
|
+
|
250
|
+
text = Yomu.read(:text, pdf.render_with_attachments).split("\n")
|
251
|
+
expect(text).to include "page 1"
|
252
|
+
expect(text).to include "page 2"
|
246
253
|
end
|
247
254
|
end
|
255
|
+
end
|
248
256
|
|
249
|
-
it "should build attachments" do
|
250
|
-
quotation = create(:billing_machine_quotation)
|
251
|
-
attachment = create(:alexandrie_attachment, attachable: quotation)
|
252
|
-
pdf = quotation.pdf
|
253
|
-
pdf.build
|
254
257
|
|
255
|
-
text = Yomu.read(:text, pdf.render_with_attachments).split("\n")
|
256
|
-
expect(text).to include "page 1"
|
257
|
-
expect(text).to include "page 2"
|
258
|
-
end
|
259
258
|
|
260
|
-
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dorsale
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- agilidée
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -396,6 +396,14 @@ extensions: []
|
|
396
396
|
extra_rdoc_files: []
|
397
397
|
files:
|
398
398
|
- Rakefile
|
399
|
+
- app/assets/fonts/BryantPro-Bold.otf
|
400
|
+
- app/assets/fonts/BryantPro-Bold.ttf
|
401
|
+
- app/assets/fonts/BryantPro-Regular.otf
|
402
|
+
- app/assets/fonts/BryantPro-Regular.ttf
|
403
|
+
- app/assets/fonts/fonts/BryantPro-Bold.otf
|
404
|
+
- app/assets/fonts/fonts/BryantPro-Bold.ttf
|
405
|
+
- app/assets/fonts/fonts/BryantPro-Regular.otf
|
406
|
+
- app/assets/fonts/fonts/BryantPro-Regular.ttf
|
399
407
|
- app/assets/images/dorsale/avatar.png
|
400
408
|
- app/assets/javascripts/accounting.js
|
401
409
|
- app/assets/javascripts/dorsale/all.js
|