crunchaccounting-api 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/crunchaccounting-api.rb +21 -5
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 49a5d2789710062012d399193d9bceccbeb37585
4
- data.tar.gz: ef876975580ed903538622672712f8ae9235fe43
3
+ metadata.gz: '0419084eb489b5419b3fb4f986b027d78217700a'
4
+ data.tar.gz: ca55b6ae3a4fa1a4ff1b3cca16136f9e01ddedfd
5
5
  SHA512:
6
- metadata.gz: df041d42161e0bb8d2454b6b94f4acefe8e0ecdaa9b3be8d76c4fbbb2ca668c56c47bd312013c2afd79fee898eecfbca923a050a1db843daa9a9d10d1879e917
7
- data.tar.gz: d736fada0e4933383349cd0110e63edd8d01d057fc5a807d728d0f80c71736a1917bc4bfb57d86fc646e50278c787f88c065ef499b8c2c28bfc1a9041b31f186
6
+ metadata.gz: 62442f5874a78e3cce2cc8fd38accd8674d39f436481a43a72c2446967cd5c193beba359ac1fcb34fab5945642d21bcadb471063663287c80df1e8913132700a
7
+ data.tar.gz: 6072559b0f710c50a408f93247355557c765413d39a467d579264ca602e2c8457bfe64177087b9c3cc5a338bb547f9091fc3c4937851b2541a3d988eb675f742
@@ -190,13 +190,17 @@ class CrunchAPI
190
190
  def subject_to_vat?(expense_type)
191
191
  if [
192
192
  "GENERAL_INSURANCE",
193
- "MILEAGE_ALLOWANCE"
193
+ "MILEAGE_ALLOWANCE",
194
+ "MEDICAL_INSURANCE_CONTRIBUTIONS",
195
+ "BANK_CHARGES",
194
196
  ].include? expense_type
195
197
  return false
196
198
  end
197
199
 
198
200
  if [
199
- "ACCOUNTANCY"
201
+ "ACCOUNTANCY",
202
+ "CHILDCARE_VOUCHER_ADMIN_FEES",
203
+ "WEB_HOSTING_CLOUD_SERVICES"
200
204
  ].include? expense_type
201
205
  return true
202
206
  end
@@ -209,8 +213,8 @@ class CrunchAPI
209
213
 
210
214
  if subject_to_vat?(expense_type)
211
215
  gross_amount = amount
212
- vat_amount = (amount / 100) * @vat_rate
213
- net_amount = amount - vat_amount
216
+ vat_amount = ((amount / 100) * @vat_rate).round(2)
217
+ net_amount = (amount - vat_amount).round(2)
214
218
  else
215
219
  gross_amount = amount
216
220
  vat_amount = 0
@@ -355,6 +359,18 @@ class CrunchAPI
355
359
  false
356
360
  end
357
361
 
362
+ def find_invoice(client_id, date)
363
+ invoices["salesInvoice"].each do |invoice|
364
+ if invoice["salesInvoiceDetails"]["client"]["clientId"] == client_id and
365
+ invoice["salesInvoiceDetails"]["issuedDate"] == date
366
+
367
+ return invoice
368
+ end
369
+ end
370
+
371
+ false
372
+ end
373
+
358
374
  def issue_invoice(invoice)
359
375
  put "/rest/v2/sales_invoices/#{invoice["salesInvoiceId"]}/issue"
360
376
  end
@@ -436,7 +452,7 @@ class CrunchAPI
436
452
  amount = rate * quantity
437
453
 
438
454
  if add_vat
439
- vat = (amount / 100) * @vat_rate
455
+ vat = ((amount / 100) * @vat_rate).round(2)
440
456
  vat_type = "STANDARD"
441
457
  else
442
458
  vat = 0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crunchaccounting-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - m4rkw
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-20 00:00:00.000000000 Z
11
+ date: 2017-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth