intacctrb 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c47eb57b4b19041d7132159c969818485fd91dd1
4
- data.tar.gz: ae177589589399ca12ad4b20fb3baa97d1b8c32f
3
+ metadata.gz: 30b63bbaba31ddbb33e76307484aacba28d123d0
4
+ data.tar.gz: b9a906512745354721255a1a6c445b0bebc7d394
5
5
  SHA512:
6
- metadata.gz: add483ca39dbf97f392659ea0702e07191c7e3c582f079b4cc6514dd0c229f125571d4fe82c27dd49b719ad450a17375c2b10e6b715da1f95e3814df2fa2a43c
7
- data.tar.gz: 8890f4cbe92c9a449814ae4fe8a3a7e63c403dde6c67512ab74a90206bee8481c9d479b3c61623323324228231ef08b3336c6a978370af4f60ac6da825051b01
6
+ metadata.gz: 3c905eee5af2b696c5e4d7bcc73d443e41d0e76e84fe2ebdbc62e308724b33155ac5d220bf90dc643b5b36ee4c0275e5689851e626470d3e950428b5761127ea
7
+ data.tar.gz: 229206df620b0e43979ae6473b5044b774515291fcc462a5d71148323240635f5c67d13a9a30437a822d851c13124e30d5b193cf34639f1a4bea12756b8ee169
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- intacctrb (0.3)
4
+ intacctrb (0.4)
5
5
  hooks
6
6
  nokogiri
7
7
 
data/lib/intacctrb.rb CHANGED
@@ -11,6 +11,10 @@ require "intacctrb/invoice"
11
11
  require "intacctrb/bill"
12
12
  require "intacctrb/ap_payment"
13
13
  require "intacctrb/account"
14
+ require "intacctrb/attachment"
15
+
16
+ require "intacctrb/exceptions/base"
17
+ require "intacctrb/exceptions/error"
14
18
 
15
19
  class Object
16
20
  def blank?
@@ -0,0 +1,57 @@
1
+ module IntacctRB
2
+ class Attachment < IntacctRB::Base
3
+ attr_accessor :customer_data
4
+ define_hook :custom_bill_fields, :bill_item_fields
5
+
6
+ def create
7
+ return false if object.intacct_system_id.present?
8
+
9
+ send_xml('create') do |xml|
10
+ xml.function(controlid: "f1") {
11
+ xml.create_supdoc {
12
+ attachment_xml xml
13
+ }
14
+ }
15
+ end
16
+
17
+ successful?
18
+ end
19
+
20
+ def get_date_at(xpath, object)
21
+ year = object.at("#{xpath}/year").content
22
+ month = object.at("#{xpath}/month").content
23
+ day = object.at("#{xpath}/day").content
24
+ if [year,month,day].any?(&:empty?)
25
+ nil
26
+ else
27
+ Date.new(year.to_i,month.to_i,day.to_i)
28
+ end
29
+ end
30
+
31
+ def attachment_xml xml
32
+ xml.supdocid object.supdoc_id
33
+ xml.supdocfoldername object.folder_name
34
+ xml.attachments {
35
+ object.attachments.each do |attachment|
36
+ xml.attachment {
37
+ xml.attachmentname attachment.name
38
+ xml.attachmenttype attachment.type
39
+ xml.attachmentdata attachment.data
40
+ }
41
+ end
42
+ }
43
+ end
44
+
45
+ def set_intacct_system_id
46
+ object.intacct_system_id = intacct_object_id
47
+ end
48
+
49
+ def delete_intacct_system_id
50
+ object.intacct_system_id = nil
51
+ end
52
+
53
+ def delete_intacct_key
54
+ object.intacct_key = nil
55
+ end
56
+ end
57
+ end
@@ -16,7 +16,11 @@ module IntacctRB
16
16
  }
17
17
  end
18
18
 
19
- successful?
19
+ if !successful?
20
+ raise IntacctRB::Exceptions::Error.new(response.at('//error//description2'))
21
+ end
22
+
23
+ object.intacct_id
20
24
  end
21
25
 
22
26
  def update
@@ -32,7 +36,11 @@ module IntacctRB
32
36
  }
33
37
  end
34
38
 
35
- successful?
39
+ if !successful?
40
+ raise(response.at('//error//description2'))
41
+ end
42
+
43
+ object.intacct_id
36
44
  end
37
45
 
38
46
  def delete
@@ -123,6 +131,7 @@ module IntacctRB
123
131
  xml.whendue object.due_date
124
132
  xml.action object.action
125
133
  xml.recordid object.record_id
134
+ xml.supdocid object.supdoc_id
126
135
 
127
136
  xml.apbillitems {
128
137
  object.line_items.each do |line_item|
@@ -0,0 +1,9 @@
1
+ module IntacctRB
2
+ module Exceptions
3
+ class Base < StandardError
4
+ def initialize(message)
5
+ super(message)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+ module IntacctRB
2
+ module Exceptions
3
+ class Error < IntacctRB::Exceptions::Base
4
+ end
5
+ end
6
+ end
@@ -157,8 +157,8 @@ module IntacctRB
157
157
  def je_xml xml
158
158
  xml.recordno object.intacct_id if object.intacct_id
159
159
  xml.journal object.journal_id
160
- xml.batch_date object.date.strftime('%Y-%m-%d') if object.date
161
- xml.reverse_date object.reverse_date.strftime('%Y-%m-%d') if object.reverse_date
160
+ xml.batch_date (object.date.try(:strftime, '%Y-%m-%d')) if object.date
161
+ xml.reverse_date (object.reverse_date.try(:strftime, '%Y-%m-%d')) if object.reverse_date
162
162
  xml.batch_title object.description
163
163
  xml.referenceno object.reference_number
164
164
  je_item_fields(xml)
@@ -95,6 +95,7 @@ module IntacctRB
95
95
  xml.status "active"
96
96
  xml.vendoraccountno object.vendor_account_number
97
97
  xml.paymethodkey object.payment_method
98
+ xml.onetime object.one_time || false
98
99
  xml.displaycontact {
99
100
  xml.contactname object.company_name
100
101
  xml.printas object.company_name
@@ -1,3 +1,3 @@
1
1
  module IntacctRB
2
- VERSION = "0.3"
2
+ VERSION = "0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: intacctrb
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Hale
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-24 00:00:00.000000000 Z
11
+ date: 2017-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -170,9 +170,12 @@ files:
170
170
  - lib/intacctrb.rb
171
171
  - lib/intacctrb/account.rb
172
172
  - lib/intacctrb/ap_payment.rb
173
+ - lib/intacctrb/attachment.rb
173
174
  - lib/intacctrb/base.rb
174
175
  - lib/intacctrb/bill.rb
175
176
  - lib/intacctrb/customer.rb
177
+ - lib/intacctrb/exceptions/base.rb
178
+ - lib/intacctrb/exceptions/error.rb
176
179
  - lib/intacctrb/invoice.rb
177
180
  - lib/intacctrb/journal_entry.rb
178
181
  - lib/intacctrb/vendor.rb