intacctrb 0.4.9 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/lib/intacctrb.rb +1 -0
- data/lib/intacctrb/ap_payment.rb +24 -13
- data/lib/intacctrb/ap_payment_request.rb +168 -0
- data/lib/intacctrb/bill.rb +1 -1
- data/lib/intacctrb/exceptions/ap_payment.rb +6 -0
- data/lib/intacctrb/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0dfc25041760de6446265c128bc2b744fb6224d
|
4
|
+
data.tar.gz: 26d7d99bc4ef1b20d8330f170ce02143e2330df5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db81d916f34730c96190eab884e9a69e9935346b46897de5e1703355a6fadab3ee0dd9c47651613e06fe97bc15e96b5676ac9c72ac9898aa42fc9553686ad36b
|
7
|
+
data.tar.gz: 4a0feca79cee93376bb4a9ed726cd73e2a99c4391792e40b7fe825906e048274b49ad15cccf712604ff2a540b02987d9f9c758213db7ca851198c88f74dd7c4b
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/lib/intacctrb.rb
CHANGED
data/lib/intacctrb/ap_payment.rb
CHANGED
@@ -5,15 +5,20 @@ module IntacctRB
|
|
5
5
|
|
6
6
|
def create
|
7
7
|
return false if object.intacct_system_id.present?
|
8
|
+
|
8
9
|
send_xml('create') do |xml|
|
9
10
|
xml.function(controlid: "f1") {
|
10
|
-
xml.send("
|
11
|
+
xml.send("create_appayment") {
|
11
12
|
ap_payment_xml xml
|
12
13
|
}
|
13
14
|
}
|
14
15
|
end
|
15
|
-
|
16
|
-
successful?
|
16
|
+
|
17
|
+
if !successful?
|
18
|
+
raise IntacctRB::Exceptions::APPayment.new(response.at('//error//description2'))
|
19
|
+
end
|
20
|
+
|
21
|
+
object.intacct_id
|
17
22
|
end
|
18
23
|
|
19
24
|
def reverse
|
@@ -127,22 +132,28 @@ module IntacctRB
|
|
127
132
|
end
|
128
133
|
|
129
134
|
def ap_payment_xml xml
|
135
|
+
xml.key object.intacct_id if object.intacct_id
|
130
136
|
xml.bankaccountid object.bank_account_id if object.bank_account_id
|
131
137
|
xml.chargecardid object.charge_card_id if object.charge_card_id
|
132
138
|
xml.vendorid object.vendor_id
|
139
|
+
xml.memo object.memo
|
133
140
|
xml.paymentmethod object.payment_method
|
134
|
-
xml.
|
135
|
-
xml.year object.payment_date.
|
136
|
-
xml.month object.payment_date.
|
137
|
-
xml.day object.payment_date.
|
141
|
+
xml.checkdate {
|
142
|
+
xml.year Date.parse(object.payment_date).year
|
143
|
+
xml.month Date.parse(object.payment_date).month
|
144
|
+
xml.day Date.parse(object.payment_date).day
|
138
145
|
}
|
139
|
-
xml.
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
146
|
+
xml.checkno object.check_number
|
147
|
+
xml.billno object.bill_number
|
148
|
+
xml.payitems {
|
149
|
+
object.line_items.each do |line_item|
|
150
|
+
xml.payitem {
|
151
|
+
xml.glaccountno line_item.account_number
|
152
|
+
xml.paymentamount line_item.amount
|
153
|
+
xml.locationid line_item.location_id
|
154
|
+
}
|
155
|
+
end
|
144
156
|
}
|
145
|
-
xml.documentnumber object.check_number
|
146
157
|
end
|
147
158
|
|
148
159
|
def set_intacct_system_id
|
@@ -0,0 +1,168 @@
|
|
1
|
+
module IntacctRB
|
2
|
+
class APPaymentRequest < 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
|
+
send_xml('create') do |xml|
|
9
|
+
xml.function(controlid: "f1") {
|
10
|
+
xml.send("create_paymentrequest") {
|
11
|
+
ap_payment_xml xml
|
12
|
+
}
|
13
|
+
}
|
14
|
+
end
|
15
|
+
puts response
|
16
|
+
successful?
|
17
|
+
end
|
18
|
+
|
19
|
+
def reverse
|
20
|
+
return false unless object.id.present?
|
21
|
+
|
22
|
+
send_xml('delete') do |xml|
|
23
|
+
xml.function(controlid: "1") {
|
24
|
+
xml.reverse_appayment(key: object.id) do |xml|
|
25
|
+
xml.datereversed do |xml|
|
26
|
+
xml.year object.date.year
|
27
|
+
xml.month object.date.month
|
28
|
+
xml.day object.date.day
|
29
|
+
end
|
30
|
+
end
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
successful?
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_list(options = {})
|
38
|
+
send_xml('get_list') do |xml|
|
39
|
+
xml.function(controlid: "f4") {
|
40
|
+
xml.get_list(object: "appayment", maxitems: (options[:max_items] || 0),
|
41
|
+
start: (options[:start] || 0), showprivate:"true") {
|
42
|
+
if options[:filters]
|
43
|
+
xml.filter {
|
44
|
+
xml.logical(logical_operator: "and") do
|
45
|
+
options[:filters][:and_filters].each do |filter|
|
46
|
+
xml.expression do
|
47
|
+
filter.each_pair do |k,v|
|
48
|
+
xml.send(k,v)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
if options[:filters][:or_filters]
|
53
|
+
xml.logical(logical_operator: "or") do
|
54
|
+
options[:filters][:or_filters].each do |filter|
|
55
|
+
xml.expression do
|
56
|
+
filter.each_pair do |k,v|
|
57
|
+
xml.send(k,v)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
}
|
65
|
+
end
|
66
|
+
if options[:fields]
|
67
|
+
xml.fields {
|
68
|
+
fields.each do |field|
|
69
|
+
xml.field field.to_s
|
70
|
+
end
|
71
|
+
}
|
72
|
+
end
|
73
|
+
}
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
77
|
+
puts response
|
78
|
+
if successful?
|
79
|
+
@data = []
|
80
|
+
@response.xpath('//appayment').each do |payment|
|
81
|
+
item = OpenStruct.new({
|
82
|
+
id: payment.at("key").content,
|
83
|
+
vendor_id: payment.at("vendorid").content,
|
84
|
+
payment_amount: payment.at("paymentamount").content,
|
85
|
+
payment_trx_amount: payment.at("paymenttrxamount").content,
|
86
|
+
payment_method: payment.at("paymentmethod").content,
|
87
|
+
payment_account_id: payment.at("financialentity").content,
|
88
|
+
state: payment.at("transactionstate").content,
|
89
|
+
date: get_date_at('paymentdate', payment),
|
90
|
+
date_cleared: get_date_at('cleareddate', payment),
|
91
|
+
cleared: payment.at("cleared").content,
|
92
|
+
})
|
93
|
+
payment.xpath('.//appaymentitem').each do |payment_item|
|
94
|
+
item[:payment_items] ||= []
|
95
|
+
item[:payment_items] << {
|
96
|
+
bill_id: payment_item.at('billkey').content,
|
97
|
+
line_item_id: payment_item.at('lineitemkey').content,
|
98
|
+
gl_account_number: payment_item.at('glaccountno').content,
|
99
|
+
amount: payment_item.at('amount').content,
|
100
|
+
department_id: payment_item.at('departmentid').content,
|
101
|
+
location_id: payment_item.at('locationid').content,
|
102
|
+
trx_amount: payment_item.at('trx_amount').content,
|
103
|
+
currency: payment_item.at('currency').content
|
104
|
+
}
|
105
|
+
end
|
106
|
+
@data << item
|
107
|
+
end
|
108
|
+
@data
|
109
|
+
else
|
110
|
+
false
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def get_date_at(xpath, object)
|
115
|
+
year = object.at("#{xpath}/year").content
|
116
|
+
month = object.at("#{xpath}/month").content
|
117
|
+
day = object.at("#{xpath}/day").content
|
118
|
+
if [year,month,day].any?(&:empty?)
|
119
|
+
nil
|
120
|
+
else
|
121
|
+
Date.new(year.to_i,month.to_i,day.to_i)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def intacct_object_id
|
126
|
+
"#{intacct_bill_prefix}#{object.payment.id}"
|
127
|
+
end
|
128
|
+
|
129
|
+
def ap_payment_xml xml
|
130
|
+
xml.bankaccountid object.bank_account_id if object.bank_account_id
|
131
|
+
xml.chargecardid object.charge_card_id if object.charge_card_id
|
132
|
+
xml.vendorid object.vendor_id
|
133
|
+
xml.paymentmethod object.payment_method
|
134
|
+
xml.paymentdate {
|
135
|
+
xml.year object.payment_date.strftime("%Y")
|
136
|
+
xml.month object.payment_date.strftime("%m")
|
137
|
+
xml.day object.payment_date.strftime("%d")
|
138
|
+
}
|
139
|
+
xml.paymentrequestitems {
|
140
|
+
xml.paymentrequestitem {
|
141
|
+
xml.key object.bill_key
|
142
|
+
xml.paymentamount object.amount
|
143
|
+
}
|
144
|
+
}
|
145
|
+
xml.documentnumber object.check_number
|
146
|
+
end
|
147
|
+
|
148
|
+
def set_intacct_system_id
|
149
|
+
object.payment.intacct_system_id = intacct_object_id
|
150
|
+
end
|
151
|
+
|
152
|
+
def delete_intacct_system_id
|
153
|
+
object.payment.intacct_system_id = nil
|
154
|
+
end
|
155
|
+
|
156
|
+
def delete_intacct_key
|
157
|
+
object.payment.intacct_key = nil
|
158
|
+
end
|
159
|
+
|
160
|
+
def set_date_time type
|
161
|
+
if %w(create update delete).include? type
|
162
|
+
if object.payment.respond_to? :"intacct_#{type}d_at"
|
163
|
+
object.payment.send("intacct_#{type}d_at=", DateTime.now)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
data/lib/intacctrb/bill.rb
CHANGED
data/lib/intacctrb/version.rb
CHANGED
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.
|
4
|
+
version: 0.5.0
|
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-
|
11
|
+
date: 2017-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -170,10 +170,12 @@ files:
|
|
170
170
|
- lib/intacctrb.rb
|
171
171
|
- lib/intacctrb/account.rb
|
172
172
|
- lib/intacctrb/ap_payment.rb
|
173
|
+
- lib/intacctrb/ap_payment_request.rb
|
173
174
|
- lib/intacctrb/attachment.rb
|
174
175
|
- lib/intacctrb/base.rb
|
175
176
|
- lib/intacctrb/bill.rb
|
176
177
|
- lib/intacctrb/customer.rb
|
178
|
+
- lib/intacctrb/exceptions/ap_payment.rb
|
177
179
|
- lib/intacctrb/exceptions/attachment.rb
|
178
180
|
- lib/intacctrb/exceptions/base.rb
|
179
181
|
- lib/intacctrb/exceptions/bill.rb
|