moy_sklad 1.0.0.beta1

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.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +13 -0
  6. data/Rakefile +1 -0
  7. data/bin/gencountry +18 -0
  8. data/doc/xml/Company.xml +165 -0
  9. data/doc/xml/CustomEntity.xml +53 -0
  10. data/doc/xml/CustomerOrder.xml +168 -0
  11. data/doc/xml/Good.xml +127 -0
  12. data/doc/xml/GoodFolder.xml +53 -0
  13. data/doc/xml/MOYsklad.xsd +2450 -0
  14. data/doc/xml/PaymentIn.xml +81 -0
  15. data/doc/xml/README.md +1 -0
  16. data/lib/moy_sklad/client/attribute.rb +119 -0
  17. data/lib/moy_sklad/client/base.rb +112 -0
  18. data/lib/moy_sklad/client/collection.rb +52 -0
  19. data/lib/moy_sklad/client/formatter.rb +37 -0
  20. data/lib/moy_sklad/client/resource.rb +56 -0
  21. data/lib/moy_sklad/client.rb +5 -0
  22. data/lib/moy_sklad/configuration.rb +74 -0
  23. data/lib/moy_sklad/model/company.rb +23 -0
  24. data/lib/moy_sklad/model/country.rb +12 -0
  25. data/lib/moy_sklad/model/custom_entity.rb +4 -0
  26. data/lib/moy_sklad/model/customer_order.rb +21 -0
  27. data/lib/moy_sklad/model/data/country_codes.yml +249 -0
  28. data/lib/moy_sklad/model/demand.rb +20 -0
  29. data/lib/moy_sklad/model/good.rb +32 -0
  30. data/lib/moy_sklad/model/good_folder.rb +4 -0
  31. data/lib/moy_sklad/model/payment_in.rb +9 -0
  32. data/lib/moy_sklad/model/supply.rb +20 -0
  33. data/lib/moy_sklad/model/templates/company.builder +132 -0
  34. data/lib/moy_sklad/model/templates/custom_entity.builder +42 -0
  35. data/lib/moy_sklad/model/templates/customer_order.builder +151 -0
  36. data/lib/moy_sklad/model/templates/demand.builder +147 -0
  37. data/lib/moy_sklad/model/templates/good.builder +83 -0
  38. data/lib/moy_sklad/model/templates/good_folder.builder +41 -0
  39. data/lib/moy_sklad/model/templates/payment_in.builder +72 -0
  40. data/lib/moy_sklad/model/templates/supply.builder +144 -0
  41. data/lib/moy_sklad/model.rb +13 -0
  42. data/lib/moy_sklad/nokogiri/document.rb +28 -0
  43. data/lib/moy_sklad/version.rb +3 -0
  44. data/lib/moy_sklad.rb +4 -0
  45. data/moy_sklad.gemspec +28 -0
  46. data/spec/ms_config.rb +44 -0
  47. data/spec/spec_helper.rb +9 -0
  48. data/spec/unit/company_spec.rb +60 -0
  49. data/spec/unit/country_spec.rb +18 -0
  50. data/spec/unit/custom_entity_spec.rb +64 -0
  51. data/spec/unit/customer_order_spec.rb +131 -0
  52. data/spec/unit/demand_spec.rb +53 -0
  53. data/spec/unit/fail_spec.rb +12 -0
  54. data/spec/unit/good_folder_spec.rb +51 -0
  55. data/spec/unit/good_spec.rb +149 -0
  56. data/spec/unit/payment_in_spec.rb +120 -0
  57. data/spec/unit/supply_spec.rb +51 -0
  58. metadata +211 -0
@@ -0,0 +1,147 @@
1
+ xml.demand(name: name, stateUuid: stateUuid, targetAgentUuid: targetAgentUuid, sourceAgentUuid: sourceAgentUuid, targetStoreUuid: targetStoreUuid,
2
+ sourceStoreUuid: sourceStoreUuid, applicable: applicable, projectUuid: projectUuid, contractUuid: contractUuid,
3
+ moment: moment, targetAccountUuid: targetAccountUuid, sourceAccountUuid: sourceAccountUuid, payerVat: payerVat,
4
+ retailStoreUuid: retailStoreUuid, currencyUuid: currencyUuid, rate: rate, vatIncluded: vatIncluded,
5
+ employeeUuid: employeeUuid, customerOrderUuid: customerOrderUuid, factureUuid: factureUuid) {
6
+
7
+ xml.accountUuid_ accountUuid
8
+ xml.accountId_ accountId
9
+ xml.uuid_ uuid
10
+ xml.groupUuid_ groupUuid
11
+ xml.deleted_ deleted
12
+ xml.code_ code
13
+ xml.externalcode_ externalcode
14
+ xml.description_ description
15
+
16
+ to_a(:attribute).each do |a|
17
+ xml.attribute(metadataUuid: a.metadataUuid, valueText: a.valueText, valueString: a.valueString,
18
+ doubleValue: a.doubleValue, longValue: a.longValue, booleanValue: a.booleanValue,
19
+ timeValue: a.timeValue, entityValueUuid: a.entityValueUuid, agentValueUuid: a.agentValueUuid,
20
+ goodValueUuid: a.goodValueUuid, placeValueUuid: a.placeValueUuid, consignmentValueUuid: a.consignmentValueUuid,
21
+ contractValueUuid: a.contractValueUuid, projectValueUuid: a.projectValueUuid, employeeValueUuid: a.employeeValueUuid,
22
+ goodUuid: a.goodUuid) {
23
+
24
+ xml.accountUuid_ a.accountUuid
25
+ xml.accountId_ a.accountId
26
+ xml.uuid_ a.uuid
27
+ xml.groupUuid_ a.groupUuid
28
+ xml.deleted_ a.deleted
29
+
30
+ a.to_a(:file).each do |f|
31
+ xml.file(name: f.name, created: f.created, filename: f.filename, miniatureUuid: f.miniatureUuid) {
32
+
33
+ xml.accountUuid_ f.accountUuid
34
+ xml.accountId_ f.accountId
35
+ xml.uuid_ f.uuid
36
+ xml.groupUuid_ f.groupUuid
37
+ xml.deleted_ f.deleted
38
+ xml.code_ f.code
39
+ xml.externalcode_ f.externalcode
40
+ xml.description_ f.description
41
+ xml.contents_ f.contents
42
+ }
43
+ end
44
+ }
45
+ end
46
+
47
+ to_a(:document).each do |d|
48
+ xml.document(name: d.name, created: d.created, filename: d.filename, miniatureUuid: d.miniatureUuid,
49
+ emailedDate: d.emailedDate, publicId: d.publicId, operationUuid: d.operationUuid) {
50
+ xml.accountUuid_ d.accountUuid
51
+ xml.accountId_ d.accountId
52
+ xml.uuid_ d.uuid
53
+ xml.groupUuid_ d.groupUuid
54
+ xml.deleted_ d.deleted
55
+ xml.code_ d.code
56
+ xml.externalcode_ d.externalcode
57
+ xml.description_ d.description
58
+ xml.contents_ d.contents
59
+ }
60
+ end
61
+
62
+ xml.sum(sum: sum.sum, sumInCurrency: sum.sumInCurrency)
63
+
64
+ xml.invoicesOutUuid {
65
+ to_a(:invoicesOutUuid).each do |r|
66
+ xml.invoiceOutRef_ r
67
+ end
68
+ }
69
+
70
+ xml.paymentsUuid {
71
+ to_a(:paymentsUuid).each do |r|
72
+ xml.financeInRef r
73
+ end
74
+ }
75
+
76
+ to_a(:shipmentOut).each do |s|
77
+ xml.shipmentOut(discount: s.discount, quantity: s.quantity, goodPackUuid: s.goodPackUuid, consignmentUuid: s.consignmentUuid,
78
+ goodUuid: s.goodUuid, slotUuid: s.slotUuid, vat: s.vat, countryUuid: s.countryUuid, gtdUuid: s.gtdUuid) {
79
+
80
+ xml.accountUuid_ s.accountUuid
81
+ xml.accountId_ s.accountId
82
+ xml.uuid_ s.uuid
83
+ xml.groupUuid_ s.groupUuid
84
+ xml.reserve_ s.reserve
85
+
86
+ xml.basePrice(sum: s.basePrice.sum, sumInCurrency: s.basePrice.sumInCurrency)
87
+ xml.price(sum: s.price.sum, sumInCurrency: s.price.sumInCurrency)
88
+
89
+ xml.things {
90
+ s.to_a(:thingsRef).each do |t|
91
+
92
+ xml.thingRef(name: t.name, goodUuid: t.goodUuid) {
93
+ xml.accountUuid_ t.accountUuid
94
+ xml.accountId_ t.accountId
95
+ xml.uuid_ t.uuid
96
+ xml.groupUuid_ t.groupUuid
97
+ xml.deleted_ t.deleted
98
+ xml.code_ t.code
99
+ xml.externalcode_ t.externalcode
100
+ xml.description_ t.description
101
+
102
+ t.to_a(:attribute).each do |a|
103
+ xml.attribute(metadataUuid: a.metadataUuid, valueText: a.valueText, valueString: a.valueString,
104
+ doubleValue: a.doubleValue, longValue: a.longValue, booleanValue: a.booleanValue,
105
+ timeValue: a.timeValue, entityValueUuid: a.entityValueUuid, agentValueUuid: a.agentValueUuid,
106
+ goodValueUuid: a.goodValueUuid, placeValueUuid: a.placeValueUuid, consignmentValueUuid: a.consignmentValueUuid,
107
+ contractValueUuid: a.contractValueUuid, projectValueUuid: a.projectValueUuid, employeeValueUuid: a.employeeValueUuid,
108
+ goodUuid: a.goodUuid) {
109
+
110
+ xml.accountUuid_ a.accountUuid
111
+ xml.accountId_ a.accountId
112
+ xml.uuid_ a.uuid
113
+ xml.groupUuid_ a.groupUuid
114
+ xml.deleted_ a.deleted
115
+ a.to_a(:file).each do |f|
116
+ xml.file(name: f.name, created: f.created, filename: f.filename, miniatureUuid: f.miniatureUuid) {
117
+
118
+ xml.accountUuid_ f.accountUuid
119
+ xml.accountId_ f.accountId
120
+ xml.uuid_ f.uuid
121
+ xml.groupUuid_ f.groupUuid
122
+ xml.deleted_ f.deleted
123
+ xml.code_ f.code
124
+ xml.externalcode_ f.externalcode
125
+ xml.description_ f.description
126
+ xml.contents_ f.contents
127
+ }
128
+ end
129
+ }
130
+ end
131
+ }
132
+ end
133
+ }
134
+ }
135
+ end
136
+
137
+
138
+ xml.salesReturnsUuid {
139
+ to_a(:salesReturnsUuid).each do |r|
140
+ xml.salesReturnRef r
141
+ end
142
+ }
143
+
144
+ xml.extension(consigneeUuid: consigneeUuid, opened: opened, carrierUuid: carrierUuid, loadName: loadName,
145
+ consignorIndication: consignorIndication, transportFacility: transportFacility, goodPackQuantity: goodPackQuantity,
146
+ carNumber: carNumber)
147
+ }
@@ -0,0 +1,83 @@
1
+ xml.good(name: name, archived: archived, parentUuid: parentUuid, productCode: productCode,
2
+ vat: vat, minPrice: minPrice, uomUuid: uomUuid, countryUuid: countryUuid,
3
+ supplierUuid: supplierUuid, salePrice: salePrice, saleCurrencyUuid: saleCurrencyUuid,
4
+ buyCurrencyUuid: buyCurrencyUuid, isSerialTrackable: isSerialTrackable, buyPrice: buyPrice,
5
+ minimumBalance: minimumBalance, weight: weight, volume: volume) {
6
+
7
+ xml.accountUuid_ accountUuid
8
+ xml.accountId_ accountId
9
+ xml.uuid_ uuid
10
+ xml.groupUuid_ groupUuid
11
+ xml.deleted_ deleted
12
+ xml.code_ code
13
+ xml.externalcode_ externalcode
14
+ xml.description_ description
15
+
16
+ to_a(:attribute).each do |a|
17
+ xml.attribute(metadataUuid: a.metadataUuid, valueText: a.valueText, valueString: a.valueString,
18
+ doubleValue: a.doubleValue, longValue: a.longValue, booleanValue: a.booleanValue,
19
+ timeValue: a.timeValue, entityValueUuid: a.entityValueUuid, agentValueUuid: a.agentValueUuid,
20
+ goodValueUuid: a.goodValueUuid, placeValueUuid: a.placeValueUuid, consignmentValueUuid: a.consignmentValueUuid,
21
+ contractValueUuid: a.contractValueUuid, projectValueUuid: a.projectValueUuid, employeeValueUuid: a.employeeValueUuid,
22
+ goodUuid: a.goodUuid) {
23
+
24
+ xml.accountUuid_ a.accountUuid
25
+ xml.accountId_ a.accountId
26
+ xml.uuid_ a.uuid
27
+ xml.groupUuid_ a.groupUuid
28
+ xml.deleted_ a.deleted
29
+ a.to_a(:file).each do |f|
30
+ xml.file(name: f.name, created: f.created, filename: f.filename, miniatureUuid: f.miniatureUuid) {
31
+
32
+ xml.accountUuid_ f.accountUuid
33
+ xml.accountId_ f.accountId
34
+ xml.uuid_ f.uuid
35
+ xml.groupUuid_ f.groupUuid
36
+ xml.deleted_ f.deleted
37
+ xml.code_ f.code
38
+ xml.externalcode_ f.externalcode
39
+ xml.description_ f.description
40
+ xml.contents_ f.contents
41
+ }
42
+ end
43
+ }
44
+ end
45
+
46
+ xml.barcode(barcode: barcode.barcode, barcodeType: barcode.barcodeType) {
47
+ xml.accountUuid_ barcode.accountUuid
48
+ xml.accountId_ barcode.accountId
49
+ xml.uuid_ barcode.uuid
50
+ xml.groupUuid_ barcode.groupUuid
51
+ } unless xml.barcode.empty?
52
+
53
+ xml.salePrices {
54
+ salePrices.to_a(:price).each do |p|
55
+ xml.price(currencyUuid: p.currencyUuid, priceTypeUuid: p.priceTypeUuid, value: p.value) {
56
+ xml.accountUuid_ p.accountUuid
57
+ xml.accountId_ p.accountId
58
+ xml.uuid_ p.uuid
59
+ xml.groupUuid_ p.groupUuid
60
+ }
61
+ end
62
+ }
63
+
64
+ to_a(:pack).each do |p|
65
+ xml.pack(quantity: p.quantity, uomUuid: p.uomUuid) {
66
+ xml.accountUuid_ p.accountUuid
67
+ xml.accountId_ p.accountId
68
+ xml.uuid_ p.uuid
69
+ xml.groupUuid_ p.groupUuid
70
+ }
71
+ end
72
+
73
+ xml.preferences {
74
+ to_a(:preference).each do |p|
75
+ xml.preference(slotUuid: p.slotUuid) {
76
+ xml.accountUuid_ p.accountUuid
77
+ xml.accountId_ p.accountId
78
+ xml.uuid_ p.uuid
79
+ xml.groupUuid_ p.groupUuid
80
+ }
81
+ end
82
+ }
83
+ }
@@ -0,0 +1,41 @@
1
+ xml.goodFolder(name: name, archived: archived, parentUuid: parentUuid, productCode: productCode, vat: vat) {
2
+
3
+ xml.accountUuid_ accountUuid
4
+ xml.accountId_ accountId
5
+ xml.uuid_ uuid
6
+ xml.groupUuid_ groupUuid
7
+ xml.deleted_ deleted
8
+ xml.code_ code
9
+ xml.externalcode_ externalcode
10
+ xml.description_ description
11
+
12
+ to_a(:attribute).each do |a|
13
+ xml.attribute(metadataUuid: a.metadataUuid, valueText: a.valueText, valueString: a.valueString,
14
+ doubleValue: a.doubleValue, longValue: a.longValue, booleanValue: a.booleanValue,
15
+ timeValue: a.timeValue, entityValueUuid: a.entityValueUuid, agentValueUuid: a.agentValueUuid,
16
+ goodValueUuid: a.goodValueUuid, placeValueUuid: a.placeValueUuid, consignmentValueUuid: a.consignmentValueUuid,
17
+ contractValueUuid: a.contractValueUuid, projectValueUuid: a.projectValueUuid, employeeValueUuid: a.employeeValueUuid,
18
+ goodUuid: a.goodUuid) {
19
+
20
+ xml.accountUuid_ a.accountUuid
21
+ xml.accountId_ a.accountId
22
+ xml.uuid_ a.uuid
23
+ xml.groupUuid_ a.groupUuid
24
+ xml.deleted_ a.deleted
25
+ a.to_a(:file).each do |f|
26
+ xml.file(name: f.name, created: f.created, filename: f.filename, miniatureUuid: f.miniatureUuid) {
27
+
28
+ xml.accountUuid_ f.accountUuid
29
+ xml.accountId_ f.accountId
30
+ xml.uuid_ f.uuid
31
+ xml.groupUuid_ f.groupUuid
32
+ xml.deleted_ f.deleted
33
+ xml.code_ f.code
34
+ xml.externalcode_ f.externalcode
35
+ xml.description_ f.description
36
+ xml.contents_ f.contents
37
+ }
38
+ end
39
+ }
40
+ end
41
+ }
@@ -0,0 +1,72 @@
1
+ xml.paymentIn(name: name, stateUuid: stateUuid, targetAgentUuid: targetAgentUuid, sourceAgentUuid: sourceAgentUuid,
2
+ targetStoreUuid: targetStoreUuid, sourceStoreUuid: sourceStoreUuid, applicable: applicable, projectUuid: projectUuid,
3
+ contractUuid: contractUuid, moment: moment, targetAccountUuid: targetAccountUuid, sourceAccountUuid: sourceAccountUuid,
4
+ payerVat: payerVat, retailStoreUuid: retailStoreUuid, currencyUuid: currencyUuid, rate: rate, vatIncluded: vatIncluded,
5
+ created: created, createdBy: createdBy, employeeUuid: employeeUuid, expenseItemUuid: expenseItemUuid,
6
+ incomingDate: incomingDate, incomingNumber: incomingNumber, paymentPurpose: paymentPurpose, vatSum: vatSum,
7
+ commissionReportUuid: commissionReportUuid, customerOrderUuid: customerOrderUuid, factureOutUuid: factureOutUuid,
8
+ invoiceOutUuid: invoiceOutUuid, purchaseReturnUuid: purchaseReturnUuid) {
9
+
10
+ xml.accountUuid_ accountUuid
11
+ xml.accountId_ accountId
12
+ xml.uuid_ uuid
13
+ xml.groupUuid_ groupUuid
14
+ xml.deleted_ deleted
15
+ xml.code_ code
16
+ xml.externalcode_ externalcode
17
+ xml.description_ description
18
+
19
+ to_a(:attribute).each do |a|
20
+ xml.attribute(metadataUuid: a.metadataUuid, valueText: a.valueText, valueString: a.valueString,
21
+ doubleValue: a.doubleValue, longValue: a.longValue, booleanValue: a.booleanValue,
22
+ timeValue: a.timeValue, entityValueUuid: a.entityValueUuid, agentValueUuid: a.agentValueUuid,
23
+ goodValueUuid: a.goodValueUuid, placeValueUuid: a.placeValueUuid, consignmentValueUuid: a.consignmentValueUuid,
24
+ contractValueUuid: a.contractValueUuid, projectValueUuid: a.projectValueUuid, employeeValueUuid: a.employeeValueUuid,
25
+ goodUuid: a.goodUuid) {
26
+
27
+ xml.accountUuid_ a.accountUuid
28
+ xml.accountId_ a.accountId
29
+ xml.uuid_ a.uuid
30
+ xml.groupUuid_ a.groupUuid
31
+ xml.deleted_ a.deleted
32
+
33
+ a.to_a(:file).each do |f|
34
+ xml.file(name: f.name, created: f.created, filename: f.filename, miniatureUuid: f.miniatureUuid) {
35
+
36
+ xml.accountUuid_ f.accountUuid
37
+ xml.accountId_ f.accountId
38
+ xml.uuid_ f.uuid
39
+ xml.groupUuid_ f.groupUuid
40
+ xml.deleted_ f.deleted
41
+ xml.code_ f.code
42
+ xml.externalcode_ f.externalcode
43
+ xml.description_ f.description
44
+ xml.contents_ f.contents
45
+ }
46
+ end
47
+ }
48
+ end
49
+
50
+ to_a(:document) do |d|
51
+ xml.document(name: d.name, created: d.created, filename: d.filename, miniatureUuid: d.miniatureUuid,
52
+ emailedDate: d.emailedDate, publicId: d.publicId, operationUuid: d.operationUuid) {
53
+ xml.accountUuid_ d.accountUuid
54
+ xml.accountId_ d.accountId
55
+ xml.uuid_ d.uuid
56
+ xml.groupUuid_ d.groupUuid
57
+ xml.deleted_ d.deleted
58
+ xml.code_ d.code
59
+ xml.externalcode_ d.externalcode
60
+ xml.description_ d.description
61
+ xml.contents_ d.contents
62
+ }
63
+ end
64
+
65
+ xml.sum(sum: sum.sum, sumInCurrency: sum.sumInCurrency)
66
+
67
+ xml.demandsUuid {
68
+ to_a(:demandsUuid).each do |r|
69
+ xml.demandRef_ r
70
+ end
71
+ }
72
+ }
@@ -0,0 +1,144 @@
1
+ xml.supply(name: name, stateUuid: stateUuid, targetAgentUuid: targetAgentUuid, sourceAgentUuid: sourceAgentUuid,
2
+ targetStoreUuid: targetStoreUuid, sourceStoreUuid: sourceStoreUuid, applicable: applicable, projectUuid: projectUuid,
3
+ contractUuid: contractUuid, moment: moment, targetAccountUuid: targetAccountUuid, sourceAccountUuid: sourceAccountUuid,
4
+ payerVat: payerVat, retailStoreUuid: retailStoreUuid, currencyUuid: currencyUuid, rate: rate, vatIncluded: vatIncluded,
5
+ employeeUuid: employeeUuid, factureInUuid: factureInUuid, incomingDate: incomingDate, incomingNumber: incomingNumber,
6
+ overheadDistribution: overheadDistribution, purchaseOrderUuid: purchaseOrderUuid) {
7
+
8
+ xml.accountUuid_ accountUuid
9
+ xml.accountId_ accountId
10
+ xml.uuid_ uuid
11
+ xml.groupUuid_ groupUuid
12
+ xml.deleted_ deleted
13
+ xml.code_ code
14
+ xml.externalcode_ externalcode
15
+ xml.description_ description
16
+
17
+ to_a(:attribute).each do |a|
18
+ xml.attribute(metadataUuid: a.metadataUuid, valueText: a.valueText, valueString: a.valueString,
19
+ doubleValue: a.doubleValue, longValue: a.longValue, booleanValue: a.booleanValue,
20
+ timeValue: a.timeValue, entityValueUuid: a.entityValueUuid, agentValueUuid: a.agentValueUuid,
21
+ goodValueUuid: a.goodValueUuid, placeValueUuid: a.placeValueUuid, consignmentValueUuid: a.consignmentValueUuid,
22
+ contractValueUuid: a.contractValueUuid, projectValueUuid: a.projectValueUuid, employeeValueUuid: a.employeeValueUuid,
23
+ goodUuid: a.goodUuid) {
24
+
25
+ xml.accountUuid_ a.accountUuid
26
+ xml.accountId_ a.accountId
27
+ xml.uuid_ a.uuid
28
+ xml.groupUuid_ a.groupUuid
29
+ xml.deleted_ a.deleted
30
+ a.to_a(:file).each do |f|
31
+ xml.file(name: f.name, created: f.created, filename: f.filename, miniatureUuid: f.miniatureUuid) {
32
+
33
+ xml.accountUuid_ f.accountUuid
34
+ xml.accountId_ f.accountId
35
+ xml.uuid_ f.uuid
36
+ xml.groupUuid_ f.groupUuid
37
+ xml.deleted_ f.deleted
38
+ xml.code_ f.code
39
+ xml.externalcode_ f.externalcode
40
+ xml.description_ f.description
41
+ xml.contents_ f.contents
42
+ }
43
+ end
44
+ }
45
+ end
46
+
47
+ to_a(:document).each do |d|
48
+ xml.document(name: d.name, created: d.created, filename: d.filename, miniatureUuid: d.miniatureUuid,
49
+ emailedDate: d.emailedDate, publicId: d.publicId, operationUuid: d.operationUuid) {
50
+ xml.accountUuid_ d.accountUuid
51
+ xml.accountId_ d.accountId
52
+ xml.uuid_ d.uuid
53
+ xml.groupUuid_ d.groupUuid
54
+ xml.deleted_ d.deleted
55
+ xml.code_ d.code
56
+ xml.externalcode_ d.externalcode
57
+ xml.description_ d.description
58
+ xml.contents_ d.contents
59
+ }
60
+ end
61
+
62
+ xml.sum(sum: sum.sum, sumInCurrency: sum.sumInCurrency)
63
+
64
+ xml.invoicesInUuid {
65
+ to_a(:invoicesInUuid).each do |r|
66
+ xml.invoiceInRef_ r
67
+ end
68
+ }
69
+
70
+ xml.overhead(sum: overhead.sum, sumInCurrency: overhead.sumInCurrency)
71
+
72
+ xml.paymentsUuid {
73
+ to_a(:paymentsUuid).each do |r|
74
+ xml.financeInRef r
75
+ end
76
+ }
77
+
78
+ to_a(:shipmentIn).each do |s|
79
+ xml.shipmentIn(discount: s.discount, quantity: s.quantity, goodPackUuid: s.goodPackUuid, consignmentUuid: s.consignmentUuid,
80
+ goodUuid: s.goodUuid, slotUuid: s.slotUuid, vat: s.vat, countryUuid: s.countryUuid, gtdUuid: s.gtdUuid,
81
+ overhead: s.overhead) {
82
+
83
+ xml.accountUuid_ s.accountUuid
84
+ xml.accountId_ s.accountId
85
+ xml.uuid_ s.uuid
86
+ xml.groupUuid_ s.groupUuid
87
+
88
+ xml.basePrice(sum: s.basePrice.sum, sumInCurrency: s.basePrice.sumInCurrency)
89
+ xml.price(sum: s.price.sum, sumInCurrency: s.price.sumInCurrency)
90
+
91
+ xml.things {
92
+ s.to_a(:thingsRef).each do |t|
93
+
94
+ xml.thingRef(name: t.name, goodUuid: t.goodUuid) {
95
+ xml.accountUuid_ t.accountUuid
96
+ xml.accountId_ t.accountId
97
+ xml.uuid_ t.uuid
98
+ xml.groupUuid_ t.groupUuid
99
+ xml.deleted_ t.deleted
100
+ xml.code_ t.code
101
+ xml.externalcode_ t.externalcode
102
+ xml.description_ t.description
103
+
104
+ t.to_a(:attribute).each do |a|
105
+ xml.attribute(metadataUuid: a.metadataUuid, valueText: a.valueText, valueString: a.valueString,
106
+ doubleValue: a.doubleValue, longValue: a.longValue, booleanValue: a.booleanValue,
107
+ timeValue: a.timeValue, entityValueUuid: a.entityValueUuid, agentValueUuid: a.agentValueUuid,
108
+ goodValueUuid: a.goodValueUuid, placeValueUuid: a.placeValueUuid, consignmentValueUuid: a.consignmentValueUuid,
109
+ contractValueUuid: a.contractValueUuid, projectValueUuid: a.projectValueUuid, employeeValueUuid: a.employeeValueUuid,
110
+ goodUuid: a.goodUuid) {
111
+
112
+ xml.accountUuid_ a.accountUuid
113
+ xml.accountId_ a.accountId
114
+ xml.uuid_ a.uuid
115
+ xml.groupUuid_ a.groupUuid
116
+ xml.deleted_ a.deleted
117
+ a.to_a(:file).each do |f|
118
+ xml.file(name: f.name, created: f.created, filename: f.filename, miniatureUuid: f.miniatureUuid) {
119
+
120
+ xml.accountUuid_ f.accountUuid
121
+ xml.accountId_ f.accountId
122
+ xml.uuid_ f.uuid
123
+ xml.groupUuid_ f.groupUuid
124
+ xml.deleted_ f.deleted
125
+ xml.code_ f.code
126
+ xml.externalcode_ f.externalcode
127
+ xml.description_ f.description
128
+ xml.contents_ f.contents
129
+ }
130
+ end
131
+ }
132
+ end
133
+ }
134
+ end
135
+ }
136
+ }
137
+ end
138
+
139
+ xml.purchaseReturnsUuid {
140
+ to_a(:purchaseReturnsUuid).each do |r|
141
+ xml.purchaseReturnRef r
142
+ end
143
+ }
144
+ }
@@ -0,0 +1,13 @@
1
+ require 'nokogiri'
2
+ require 'moy_sklad/nokogiri/document'
3
+
4
+ require 'moy_sklad/model/good'
5
+ require 'moy_sklad/model/good_folder'
6
+ require 'moy_sklad/model/company'
7
+ require 'moy_sklad/model/customer_order'
8
+ require 'moy_sklad/model/payment_in'
9
+ require 'moy_sklad/model/custom_entity'
10
+ require 'moy_sklad/model/country'
11
+ require 'moy_sklad/model/supply'
12
+ require 'moy_sklad/model/demand'
13
+
@@ -0,0 +1,28 @@
1
+ require 'active_support/concern'
2
+
3
+ module Nokogiri::XML
4
+ module AttributeCheck
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ def create_element_with_attrcheck(name, *args, &block)
9
+ if args[0].is_a?(::MoySklad::Client::Attribute::MissingAttr)
10
+ return create_element_without_attrcheck(name, nil, &block)
11
+ end
12
+ if !args[0].is_a?(Hash)
13
+ return create_element_without_attrcheck(name, *args, &block)
14
+ end
15
+
16
+ args[0].delete_if do |k, v|
17
+ v.is_a?(::MoySklad::Client::Attribute::MissingAttr)
18
+ end
19
+
20
+ create_element_without_attrcheck(name, *args, &block)
21
+ end
22
+
23
+ alias_method_chain :create_element, :attrcheck
24
+ end
25
+ end
26
+
27
+ Nokogiri::XML::Document.send(:include, AttributeCheck)
28
+ end
@@ -0,0 +1,3 @@
1
+ module MoySklad
2
+ VERSION = '1.0.0.beta1'
3
+ end
data/lib/moy_sklad.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'moy_sklad/version'
2
+ require 'moy_sklad/configuration'
3
+ require 'moy_sklad/client'
4
+ require 'moy_sklad/model'
data/moy_sklad.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'moy_sklad/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'moy_sklad'
8
+ spec.version = MoySklad::VERSION
9
+ spec.authors = ['uno4ki', 'Sergey Zyablitsky']
10
+ spec.email = ['i.have@no.mail', 'sergey.zyablitsky@gmail.com']
11
+ spec.description = 'MoySklad API'
12
+ spec.summary = 'MoySklad API wrapper'
13
+ spec.homepage = 'https://github.com/uno4ki/moy_sklad'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(/^spec\//)
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.3'
22
+ spec.add_development_dependency 'rake', '~> 10.3'
23
+ spec.add_development_dependency 'rspec', '~> 3.1'
24
+
25
+ spec.add_dependency 'activesupport', '>= 3.2', '< 4.2'
26
+ spec.add_dependency 'activeresource', '>= 3.2', '< 4.2'
27
+ spec.add_dependency 'nokogiri', '~> 1.6'
28
+ end
data/spec/ms_config.rb ADDED
@@ -0,0 +1,44 @@
1
+ # All uuids should be filled with real data
2
+
3
+ TGT_AGENT = "uuid"
4
+ SRC_STORE = "uuid"
5
+ SRC_AGENT = "uuid"
6
+
7
+ # Some known items from MS
8
+ KNOWN_ITEMS = {
9
+ "uuid" => {quantity: 2, name: "Библиотека открытая", price: 142560},
10
+ "uuid" => {quantity: 1, name: "Люстра ", price: 15400.80},
11
+ "uuid" => {quantity: 7, name: "Пуф", price: 24840}
12
+ }
13
+
14
+ ORDER_OPTIONS = {
15
+ delivery: {
16
+ key: "uuid",
17
+ value: "uuid"
18
+ },
19
+ communicate: {
20
+ key: "uuid",
21
+ value: "uuid"
22
+ },
23
+ payments: {
24
+ key: "uuid",
25
+ value: "uuid"
26
+ },
27
+ source: {
28
+ key: "uuid",
29
+ value: "uuid"
30
+ }
31
+ }
32
+
33
+ CONFIRMED_UUID = "uuid"
34
+
35
+ CUSTOM_DICT = {
36
+ delivery_method: "uuid",
37
+ payment_method: "uuid"
38
+ }
39
+
40
+ PRICE_CUR = "uuid"
41
+
42
+ META_COUNTRY = {uuid: "uuid", value: :valueString}
43
+ META_ARTNO = {uuid: "uuid", value: :valueString}
44
+ META_LINK = {uuid: "uuid", value: :valueText}
@@ -0,0 +1,9 @@
1
+ require 'rspec'
2
+ require 'moy_sklad'
3
+
4
+ MoySklad.configure do |config|
5
+ config.user_name = ENV["MSKL_USER"]
6
+ config.password = ENV["MSKL_PASS"]
7
+ end
8
+
9
+ require 'ms_config'