ns_connector 0.0.14 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,430 @@
1
+ require 'ns_connector/resource'
2
+
3
+ # == SalesOrder resource
4
+ # === Fields
5
+ # * id
6
+ # * allowemptycards
7
+ # * althandlingcost
8
+ # * altsalestotal
9
+ # * altshippingcost
10
+ # * authcode
11
+ # * balance
12
+ # * billaddr3
13
+ # * billaddress
14
+ # * billaddressee
15
+ # * billaddresslist
16
+ # * billattention
17
+ # * billcity
18
+ # * billcountry
19
+ # * billingschedule
20
+ # * billisresidential
21
+ # * billphone
22
+ # * billstate
23
+ # * billzip
24
+ # * ccapproved
25
+ # * ccavsstreetmatch
26
+ # * ccavszipmatch
27
+ # * ccexpiredate
28
+ # * cchold
29
+ # * ccholdetails
30
+ # * cciavsmatch
31
+ # * ccname
32
+ # * ccnumber
33
+ # * ccprocessoraccount
34
+ # * ccsecuritycode
35
+ # * ccsecuritycodematch
36
+ # * ccstreet
37
+ # * cczipcode
38
+ # * class
39
+ # * consolidatebalance
40
+ # * couponcode
41
+ # * createddate
42
+ # * createdfrom
43
+ # * creditcard
44
+ # * creditcardprocessor
45
+ # * currency
46
+ # * currencyname
47
+ # * currencysymbol
48
+ # * customercode
49
+ # * customform
50
+ # * debitcardissueno
51
+ # * deferredrevenue
52
+ # * department
53
+ # * discountitem
54
+ # * discountrate
55
+ # * discounttotal
56
+ # * draccount
57
+ # * email
58
+ # * enddate
59
+ # * entity
60
+ # * entitynexus
61
+ # * estgrossprofit
62
+ # * estgrossprofitpercent
63
+ # * exchangerate
64
+ # * excludecommission
65
+ # * externalid
66
+ # * fob
67
+ # * fxaccount
68
+ # * getauth
69
+ # * giftcertapplied
70
+ # * handlingcost
71
+ # * handlingtax1rate
72
+ # * handlingtaxcode
73
+ # * ignoreavs
74
+ # * ignorecsc
75
+ # * intercostatus
76
+ # * intercotransaction
77
+ # * isbasecurrency
78
+ # * isdefaultshippingrequest
79
+ # * ismultishipto
80
+ # * ispurchasecard
81
+ # * istaxable
82
+ # * lastmodifieddate
83
+ # * leadsource
84
+ # * linkedtrackingnumbers
85
+ # * location
86
+ # * memo
87
+ # * message
88
+ # * messagesel
89
+ # * muccpromocodeinstance
90
+ # * nexus
91
+ # * opportunity
92
+ # * orderstatus
93
+ # * otherrefnum
94
+ # * overridehold
95
+ # * overrideholdchecked
96
+ # * overrideshippingcost
97
+ # * partner
98
+ # * paymenteventdate
99
+ # * paymenteventholdreason
100
+ # * paymenteventpurchasedatasent
101
+ # * paymenteventresult
102
+ # * paymenteventtype
103
+ # * paymenteventupdatedby
104
+ # * paymentmethod
105
+ # * paypalauthid
106
+ # * paypalprocess
107
+ # * paypalstatus
108
+ # * paypaltranid
109
+ # * pnrefnum
110
+ # * promocode
111
+ # * promocodepluginimpl
112
+ # * recognizedrevenue
113
+ # * returntrackingnumbers
114
+ # * revcommitstatus
115
+ # * revenuestatus
116
+ # * revreconrevcommitment
117
+ # * saleseffectivedate
118
+ # * salesgroup
119
+ # * salesrep
120
+ # * shipaddr3
121
+ # * shipaddress
122
+ # * shipaddressee
123
+ # * shipaddresslist
124
+ # * shipattention
125
+ # * shipcity
126
+ # * shipcomplete
127
+ # * shipcountry
128
+ # * shipdate
129
+ # * shipisresidential
130
+ # * shipmethod
131
+ # * shipoverride
132
+ # * shipphone
133
+ # * shippingcost
134
+ # * shippingcostoverridden
135
+ # * shippingtax1rate
136
+ # * shippingtaxcode
137
+ # * shipstate
138
+ # * shipzip
139
+ # * softdescriptor
140
+ # * source
141
+ # * startdate
142
+ # * status
143
+ # * statusRef
144
+ # * subsidiary
145
+ # * subtotal
146
+ # * syncpartnerteams
147
+ # * syncsalesteams
148
+ # * taxitem
149
+ # * taxrate
150
+ # * taxtotal
151
+ # * terms
152
+ # * threedstatuscode
153
+ # * tobeemailed
154
+ # * tobefaxed
155
+ # * tobeprinted
156
+ # * total
157
+ # * totalcostestimate
158
+ # * trandate
159
+ # * tranid
160
+ # * tranisvsoebundle
161
+ # * unbilledorders
162
+ # * validfrom
163
+ # * vsoeautocalc
164
+ # === Sublists
165
+ # * item
166
+ # * partners
167
+ # * salesteam
168
+ # * shipgroup
169
+
170
+ class NSConnector::SalesOrder < NSConnector::Resource
171
+ @type_id = 'salesorder'
172
+ @fields = [
173
+ :id,
174
+ :allowemptycards,
175
+ :althandlingcost,
176
+ :altsalestotal,
177
+ :altshippingcost,
178
+ :authcode,
179
+ :balance,
180
+ :billaddr3,
181
+ :billaddress,
182
+ :billaddressee,
183
+ :billaddresslist,
184
+ :billattention,
185
+ :billcity,
186
+ :billcountry,
187
+ :billingschedule,
188
+ :billisresidential,
189
+ :billphone,
190
+ :billstate,
191
+ :billzip,
192
+ :ccapproved,
193
+ :ccavsstreetmatch,
194
+ :ccavszipmatch,
195
+ :ccexpiredate,
196
+ :cchold,
197
+ :ccholdetails,
198
+ :cciavsmatch,
199
+ :ccname,
200
+ :ccnumber,
201
+ :ccprocessoraccount,
202
+ :ccsecuritycode,
203
+ :ccsecuritycodematch,
204
+ :ccstreet,
205
+ :cczipcode,
206
+ :class,
207
+ :consolidatebalance,
208
+ :couponcode,
209
+ :createddate,
210
+ :createdfrom,
211
+ :creditcard,
212
+ :creditcardprocessor,
213
+ :currency,
214
+ :currencyname,
215
+ :currencysymbol,
216
+ :customercode,
217
+ :customform,
218
+ :debitcardissueno,
219
+ :deferredrevenue,
220
+ :department,
221
+ :discountitem,
222
+ :discountrate,
223
+ :discounttotal,
224
+ :draccount,
225
+ :email,
226
+ :enddate,
227
+ :entity,
228
+ :entitynexus,
229
+ :estgrossprofit,
230
+ :estgrossprofitpercent,
231
+ :exchangerate,
232
+ :excludecommission,
233
+ :externalid,
234
+ :fob,
235
+ :fxaccount,
236
+ :getauth,
237
+ :giftcertapplied,
238
+ :handlingcost,
239
+ :handlingtax1rate,
240
+ :handlingtaxcode,
241
+ :ignoreavs,
242
+ :ignorecsc,
243
+ :intercostatus,
244
+ :intercotransaction,
245
+ :isbasecurrency,
246
+ :isdefaultshippingrequest,
247
+ :ismultishipto,
248
+ :ispurchasecard,
249
+ :istaxable,
250
+ :lastmodifieddate,
251
+ :leadsource,
252
+ :linkedtrackingnumbers,
253
+ :location,
254
+ :memo,
255
+ :message,
256
+ :messagesel,
257
+ :muccpromocodeinstance,
258
+ :nexus,
259
+ :opportunity,
260
+ :orderstatus,
261
+ :otherrefnum,
262
+ :overridehold,
263
+ :overrideholdchecked,
264
+ :overrideshippingcost,
265
+ :partner,
266
+ :paymenteventdate,
267
+ :paymenteventholdreason,
268
+ :paymenteventpurchasedatasent,
269
+ :paymenteventresult,
270
+ :paymenteventtype,
271
+ :paymenteventupdatedby,
272
+ :paymentmethod,
273
+ :paypalauthid,
274
+ :paypalprocess,
275
+ :paypalstatus,
276
+ :paypaltranid,
277
+ :pnrefnum,
278
+ :promocode,
279
+ :promocodepluginimpl,
280
+ :recognizedrevenue,
281
+ :returntrackingnumbers,
282
+ :revcommitstatus,
283
+ :revenuestatus,
284
+ :revreconrevcommitment,
285
+ :saleseffectivedate,
286
+ :salesgroup,
287
+ :salesrep,
288
+ :shipaddr3,
289
+ :shipaddress,
290
+ :shipaddressee,
291
+ :shipaddresslist,
292
+ :shipattention,
293
+ :shipcity,
294
+ :shipcomplete,
295
+ :shipcountry,
296
+ :shipdate,
297
+ :shipisresidential,
298
+ :shipmethod,
299
+ :shipoverride,
300
+ :shipphone,
301
+ :shippingcost,
302
+ :shippingcostoverridden,
303
+ :shippingtax1rate,
304
+ :shippingtaxcode,
305
+ :shipstate,
306
+ :shipzip,
307
+ :softdescriptor,
308
+ :source,
309
+ :startdate,
310
+ :status,
311
+ :statusRef,
312
+ :subsidiary,
313
+ :subtotal,
314
+ :syncpartnerteams,
315
+ :syncsalesteams,
316
+ :taxitem,
317
+ :taxrate,
318
+ :taxtotal,
319
+ :terms,
320
+ :threedstatuscode,
321
+ :tobeemailed,
322
+ :tobefaxed,
323
+ :tobeprinted,
324
+ :total,
325
+ :totalcostestimate,
326
+ :trandate,
327
+ :tranid,
328
+ :tranisvsoebundle,
329
+ :unbilledorders,
330
+ :validfrom,
331
+ :vsoeautocalc,
332
+ ]
333
+ @sublists = {
334
+ :item => [
335
+ :altsalesamt,
336
+ :amortizationperiod,
337
+ :amortizationtype,
338
+ :amount,
339
+ :billvariancestatus,
340
+ :commitinventory,
341
+ :costestimate,
342
+ :costestimaterate,
343
+ :costestimatetype,
344
+ :createdpo,
345
+ :createpo,
346
+ :createwo,
347
+ :daysbeforeexpiration,
348
+ :deferrevrec,
349
+ :description,
350
+ :expectedshipdate,
351
+ :fromjob,
352
+ :giftcertfrom,
353
+ :giftcertmessage,
354
+ :giftcertrecipientemail,
355
+ :giftcertrecipientname,
356
+ :id,
357
+ :inventorydetail,
358
+ :isclosed,
359
+ :isestimate,
360
+ :istaxable,
361
+ :isvsoebundle,
362
+ :item,
363
+ :itemsubtype,
364
+ :itemtype,
365
+ :job,
366
+ :licensecode,
367
+ :line,
368
+ :linenumber,
369
+ :matrixtype,
370
+ :options,
371
+ :porate,
372
+ :povendor,
373
+ :price,
374
+ :printitems,
375
+ :quantity,
376
+ :quantityavailable,
377
+ :quantitybackordered,
378
+ :quantitybilled,
379
+ :quantitycommitted,
380
+ :quantityfulfilled,
381
+ :quantityrevcommitted,
382
+ :rate,
383
+ :rateschedule,
384
+ :revrecenddate,
385
+ :revrecschedule,
386
+ :revrecstartdate,
387
+ :shipaddress,
388
+ :shipcarrier,
389
+ :shipmethod,
390
+ :taxcode,
391
+ :taxrate1,
392
+ :units,
393
+ :vsoeallocation,
394
+ :vsoeamount,
395
+ :vsoedeferral,
396
+ :vsoedelivered,
397
+ :vsoeisestimate,
398
+ :vsoepermitdiscount,
399
+ :vsoeprice,
400
+ :vsoesopgroup,
401
+ ],
402
+ :partners => [
403
+ :contribution,
404
+ :id,
405
+ :isprimary,
406
+ :partner,
407
+ :partnerrole,
408
+ :transaction,
409
+ ],
410
+ :salesteam => [
411
+ :contribution,
412
+ :employee,
413
+ :id,
414
+ :isprimary,
415
+ :issalesrep,
416
+ :salesrole,
417
+ :transaction,
418
+ ],
419
+ :shipgroup => [
420
+ :destinationaddress,
421
+ :handlingrate,
422
+ :id,
423
+ :shippingcarrier,
424
+ :shippingmethod,
425
+ :shippingrate,
426
+ :sourceaddress,
427
+ :weight,
428
+ ]
429
+ }
430
+ end
@@ -18,4 +18,26 @@ module NSConnector::SubList
18
18
  )
19
19
  end
20
20
  end
21
+
22
+ # Save our array of SubListItems in the order in which they appear.
23
+ # Arguments:: An array of SubListItem, the parent object and the fields
24
+ # Returns:: An array of SubListItem that have been saved
25
+ def self.save! sublist_items, parent, sublist_id, fields
26
+ data = sublist_items.uniq.map do |item|
27
+ item.store
28
+ end
29
+
30
+ NSConnector::Restlet.execute!(
31
+ :action => 'update_sublist',
32
+ :type_id => parent.type_id,
33
+ :parent_id => parent.id,
34
+ :fields => fields,
35
+ :sublist_id => sublist_id,
36
+ :data => data
37
+ )
38
+
39
+ # We have to do this in a second request as NetSuite needs a
40
+ # short time to think about any added records.
41
+ return NSConnector::SubList.fetch(parent, sublist_id, fields)
42
+ end
21
43
  end