paperless_to_xero 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,6 +7,7 @@ module PaperlessToXero
7
7
  class Converter
8
8
  VAT_RATE_CHANGE_2008_12_01 = Date.parse('2008-12-01')
9
9
  VAT_RATE_CHANGE_2010_01_01 = Date.parse('2010-01-01')
10
+ VAT_RATE_CHANGE_2011_01_04 = Date.parse('2011-01-04')
10
11
  attr_reader :input_path, :output_path
11
12
 
12
13
  def initialize(input_path, output_path)
@@ -145,9 +146,15 @@ module PaperlessToXero
145
146
  when nil
146
147
  'No VAT'
147
148
  else
148
- return 'VAT - 15%' if date >= VAT_RATE_CHANGE_2008_12_01 && date < VAT_RATE_CHANGE_2010_01_01
149
- 'VAT - 17.5%'
149
+ base_uk_vat_rate_on_date(date)
150
150
  end
151
151
  end
152
+
153
+ def base_uk_vat_rate_on_date(date)
154
+ return 'VAT - 15%' if date >= VAT_RATE_CHANGE_2008_12_01 && date < VAT_RATE_CHANGE_2010_01_01
155
+ return 'VAT - 17.5%' if date >= VAT_RATE_CHANGE_2010_01_01 && date < VAT_RATE_CHANGE_2011_01_04
156
+ return 'VAT - 20%' if date >= VAT_RATE_CHANGE_2011_01_04
157
+ 'VAT - 17.5%'
158
+ end
152
159
  end
153
160
  end
@@ -19,6 +19,7 @@ module PaperlessToXero
19
19
  '15% (EU VAT ID)' => 1.15.to_d,
20
20
  '15% (VAT on expenses)' => 1.15.to_d,
21
21
  '17.5% (VAT on expenses)' => 1.175.to_d,
22
+ '20% (VAT on expenses)' => 1.2.to_d,
22
23
  'Zero Rated Expenses' => 0,
23
24
  '15% (Luxembourg, VAT on expenses)' => 1.15.to_d
24
25
  }
@@ -78,6 +79,8 @@ module PaperlessToXero
78
79
  '15% (EU VAT ID)'
79
80
  when 'VAT - 15%'
80
81
  '15% (VAT on expenses)'
82
+ when 'VAT - 20%'
83
+ '20% (VAT on expenses)'
81
84
  when 'VAT - 17.5%'
82
85
  '17.5% (VAT on expenses)'
83
86
  when 'VAT - 0%'
@@ -5,8 +5,8 @@ module PaperlessToXero
5
5
 
6
6
  module Version
7
7
  MAJOR = 1
8
- MINOR = 1
9
- POINT = 1
8
+ MINOR = 2
9
+ POINT = 2
10
10
  FULL = [PaperlessToXero::Version::MAJOR, PaperlessToXero::Version::MINOR, PaperlessToXero::Version::POINT].join('.')
11
11
  end
12
12
  end
@@ -0,0 +1,2 @@
1
+ "Date","Merchant","Currency","Amount","Tax","Category","Payment Method","Notes","Description","Reference #","Status"
2
+ 03/01/2011,"Apple Store, Regent Street","£","117.50","17.50","429 - General Expenses","Debit Card",,"Phone case","2011-01-03-05",
@@ -0,0 +1,2 @@
1
+ "Date","Merchant","Currency","Amount","Tax","Category","Payment Method","Notes","Description","Reference #","Status"
2
+ 04/01/2011,"Apple Store, Regent Street","£","120","20","429 - General Expenses","Debit Card",,"Phone case","2011-01-04-05",
@@ -242,6 +242,40 @@ describe PaperlessToXero::Converter do
242
242
  ]
243
243
  )
244
244
  end
245
+
246
+ it "correctly handles the last day of that VAT rate" do
247
+ @converter.stubs(:input_path).returns(fixture_path('single-vat-2011-01-03'))
248
+ @converter.parse
249
+
250
+ verify_invoice_details(
251
+ :invoice => {:date => Date.parse('2011-01-03'), :merchant => 'Apple Store, Regent Street',
252
+ :reference_id => '2011-01-03-05', :inc_vat_total => '117.50', :vat_total => '17.50',
253
+ :ex_vat_total => '100.00', :currency => 'GBP'},
254
+ :vat_inclusive => true,
255
+ :line_items => [
256
+ {:description => 'Phone case', :category => '429', :vat_type => '17.5% (VAT on expenses)',
257
+ :vat_inclusive_amount => '117.50', :vat_exclusive_amount => '100.00', :vat_amount => '17.50'}
258
+ ]
259
+ )
260
+ end
261
+ end
262
+
263
+ describe "2011-01-04's move to 20% VAT" do
264
+ it "correctly handles the first day of that VAT rate" do
265
+ @converter.stubs(:input_path).returns(fixture_path('single-vat-2011-01-04'))
266
+ @converter.parse
267
+
268
+ verify_invoice_details(
269
+ :invoice => {:date => Date.parse('2011-01-04'), :merchant => 'Apple Store, Regent Street',
270
+ :reference_id => '2011-01-04-05', :inc_vat_total => '120.00', :vat_total => '20.00',
271
+ :ex_vat_total => '100.00', :currency => 'GBP'},
272
+ :vat_inclusive => true,
273
+ :line_items => [
274
+ {:description => 'Phone case', :category => '429', :vat_type => '20% (VAT on expenses)',
275
+ :vat_inclusive_amount => '120.00', :vat_exclusive_amount => '100.00', :vat_amount => '20.00'}
276
+ ]
277
+ )
278
+ end
245
279
  end
246
280
  end
247
281
 
@@ -144,7 +144,8 @@ describe PaperlessToXero::InvoiceItem do
144
144
  'VAT - Luxembourg' => '15% (Luxembourg, VAT on expenses)',
145
145
  'VAT - EU' => '15% (EU VAT ID)',
146
146
  'VAT - EU - EU372000063' => '15% (EU VAT ID)',
147
- 'VAT - 17.5%' => '17.5% (VAT on expenses)',
147
+ 'VAT - 20%' => '20% (VAT on expenses)',
148
+ 'VAT - 17.5%' => '17.5% (VAT on expenses)',
148
149
  'VAT - 15%' => '15% (VAT on expenses)',
149
150
  'VAT - 0%' => 'Zero Rated Expenses',
150
151
  'VAT' => '15% (VAT on expenses)',
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperless_to_xero
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
5
- prerelease: false
4
+ hash: 27
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 1
10
- version: 1.2.1
9
+ - 2
10
+ version: 1.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Patterson
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-02-27 00:00:00 +00:00
18
+ date: 2011-02-28 00:00:00 +00:00
19
19
  default_executable: paperless_to_xero
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -97,6 +97,8 @@ files:
97
97
  - spec/fixtures/single-vat-2009-12-31.csv
98
98
  - spec/fixtures/single-vat-2009.csv
99
99
  - spec/fixtures/single-vat-2010-01-01.csv
100
+ - spec/fixtures/single-vat-2011-01-03.csv
101
+ - spec/fixtures/single-vat-2011-01-04.csv
100
102
  - spec/fixtures/single-vat-pre-2008-12.csv
101
103
  - spec/fixtures/single-zero_rated.csv
102
104
  has_rdoc: true
@@ -130,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
132
  requirements: []
131
133
 
132
134
  rubyforge_project: paperless_to_xero
133
- rubygems_version: 1.3.7
135
+ rubygems_version: 1.5.3
134
136
  signing_key:
135
137
  specification_version: 3
136
138
  summary: Convert Paperless CSV exports to Xero invoice import CSV
@@ -159,5 +161,7 @@ test_files:
159
161
  - spec/fixtures/single-vat-2009-12-31.csv
160
162
  - spec/fixtures/single-vat-2009.csv
161
163
  - spec/fixtures/single-vat-2010-01-01.csv
164
+ - spec/fixtures/single-vat-2011-01-03.csv
165
+ - spec/fixtures/single-vat-2011-01-04.csv
162
166
  - spec/fixtures/single-vat-pre-2008-12.csv
163
167
  - spec/fixtures/single-zero_rated.csv