moy_sklad 1.0.0.beta1 → 1.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/moy_sklad/model/cash_in.rb +9 -0
- data/lib/moy_sklad/model/templates/cash_in.builder +71 -0
- data/lib/moy_sklad/model/templates/payment_in.builder +3 -4
- data/lib/moy_sklad/model.rb +1 -1
- data/lib/moy_sklad/version.rb +1 -1
- data/spec/unit/cash_in_spec.rb +120 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0003b6f3f8990034da10eb5bba8256c4e155b78d
|
4
|
+
data.tar.gz: 861428d9afee9fcc7fbbea9514ffc794afc8a1b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ab25dbeedd3313751d47c9aa11b7a331cf46681af2f199edfbf2737d5d75dd34fd155599ab1a10ac982b5d2d317c53297a68ae3e9bc317a367df2865a1d9c08
|
7
|
+
data.tar.gz: 1d209a77a948f99aac93a476f54b959b8f935c3e4a30615d2fc530ef8d2031ef366a884e1d62083c397c6ee40c5a7fcfc488574218b14bba1b03e03fc4186111
|
@@ -0,0 +1,71 @@
|
|
1
|
+
xml.cashIn(name: name, stateUuid: stateUuid, targetAgentUuid: targetAgentUuid, sourceAgentUuid: sourceAgentUuid, targetStoreUuid: targetStoreUuid,
|
2
|
+
sourceStoreUuid: sourceStoreUuid, applicable: applicable, projectUuid: projectUuid, contractUuid: contractUuid, moment: moment,
|
3
|
+
targetAccountUuid: targetAccountUuid, sourceAccountUuid: sourceAccountUuid, payerVat: payerVat, retailStoreUuid: retailStoreUuid,
|
4
|
+
currencyUuid: currencyUuid, rate: rate, vatIncluded: vatIncluded, employeeUuid: employeeUuid, expenseItemUuid: expenseItemUuid,
|
5
|
+
incomingDate: incomingDate, incomingNumber: incomingNumber, paymentPurpose: paymentPurpose, vatSum: vatSum,
|
6
|
+
commissionReportUuid: commissionReportUuid, customerOrderUuid: customerOrderUuid, factureOutUuid: factureOutUuid,
|
7
|
+
invoiceOutUuid: invoiceOutUuid, purchaseReturnUuid: purchaseReturnUuid) {
|
8
|
+
|
9
|
+
xml.accountUuid_ accountUuid
|
10
|
+
xml.accountId_ accountId
|
11
|
+
xml.uuid_ uuid
|
12
|
+
xml.groupUuid_ groupUuid
|
13
|
+
xml.deleted_ deleted
|
14
|
+
xml.code_ code
|
15
|
+
xml.externalcode_ externalcode
|
16
|
+
xml.description_ description
|
17
|
+
|
18
|
+
to_a(:attribute).each do |a|
|
19
|
+
xml.attribute(metadataUuid: a.metadataUuid, valueText: a.valueText, valueString: a.valueString,
|
20
|
+
doubleValue: a.doubleValue, longValue: a.longValue, booleanValue: a.booleanValue,
|
21
|
+
timeValue: a.timeValue, entityValueUuid: a.entityValueUuid, agentValueUuid: a.agentValueUuid,
|
22
|
+
goodValueUuid: a.goodValueUuid, placeValueUuid: a.placeValueUuid, consignmentValueUuid: a.consignmentValueUuid,
|
23
|
+
contractValueUuid: a.contractValueUuid, projectValueUuid: a.projectValueUuid, employeeValueUuid: a.employeeValueUuid,
|
24
|
+
goodUuid: a.goodUuid) {
|
25
|
+
|
26
|
+
xml.accountUuid_ a.accountUuid
|
27
|
+
xml.accountId_ a.accountId
|
28
|
+
xml.uuid_ a.uuid
|
29
|
+
xml.groupUuid_ a.groupUuid
|
30
|
+
xml.deleted_ a.deleted
|
31
|
+
|
32
|
+
a.to_a(:file).each do |f|
|
33
|
+
xml.file(name: f.name, created: f.created, filename: f.filename, miniatureUuid: f.miniatureUuid) {
|
34
|
+
|
35
|
+
xml.accountUuid_ f.accountUuid
|
36
|
+
xml.accountId_ f.accountId
|
37
|
+
xml.uuid_ f.uuid
|
38
|
+
xml.groupUuid_ f.groupUuid
|
39
|
+
xml.deleted_ f.deleted
|
40
|
+
xml.code_ f.code
|
41
|
+
xml.externalcode_ f.externalcode
|
42
|
+
xml.description_ f.description
|
43
|
+
xml.contents_ f.contents
|
44
|
+
}
|
45
|
+
end
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
to_a(:document) do |d|
|
50
|
+
xml.document(name: d.name, created: d.created, filename: d.filename, miniatureUuid: d.miniatureUuid,
|
51
|
+
emailedDate: d.emailedDate, publicId: d.publicId, operationUuid: d.operationUuid) {
|
52
|
+
xml.accountUuid_ d.accountUuid
|
53
|
+
xml.accountId_ d.accountId
|
54
|
+
xml.uuid_ d.uuid
|
55
|
+
xml.groupUuid_ d.groupUuid
|
56
|
+
xml.deleted_ d.deleted
|
57
|
+
xml.code_ d.code
|
58
|
+
xml.externalcode_ d.externalcode
|
59
|
+
xml.description_ d.description
|
60
|
+
xml.contents_ d.contents
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
xml.sum(sum: sum.sum, sumInCurrency: sum.sumInCurrency)
|
65
|
+
|
66
|
+
xml.demandsUuid {
|
67
|
+
to_a(:demandsUuid).each do |r|
|
68
|
+
xml.demandRef_ r
|
69
|
+
end
|
70
|
+
}
|
71
|
+
}
|
@@ -2,10 +2,9 @@ xml.paymentIn(name: name, stateUuid: stateUuid, targetAgentUuid: targetAgentUuid
|
|
2
2
|
targetStoreUuid: targetStoreUuid, sourceStoreUuid: sourceStoreUuid, applicable: applicable, projectUuid: projectUuid,
|
3
3
|
contractUuid: contractUuid, moment: moment, targetAccountUuid: targetAccountUuid, sourceAccountUuid: sourceAccountUuid,
|
4
4
|
payerVat: payerVat, retailStoreUuid: retailStoreUuid, currencyUuid: currencyUuid, rate: rate, vatIncluded: vatIncluded,
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
invoiceOutUuid: invoiceOutUuid, purchaseReturnUuid: purchaseReturnUuid) {
|
5
|
+
employeeUuid: employeeUuid, expenseItemUuid: expenseItemUuid, incomingDate: incomingDate, incomingNumber: incomingNumber,
|
6
|
+
paymentPurpose: paymentPurpose, vatSum: vatSum, commissionReportUuid: commissionReportUuid, customerOrderUuid: customerOrderUuid,
|
7
|
+
factureOutUuid: factureOutUuid, invoiceOutUuid: invoiceOutUuid, purchaseReturnUuid: purchaseReturnUuid) {
|
9
8
|
|
10
9
|
xml.accountUuid_ accountUuid
|
11
10
|
xml.accountId_ accountId
|
data/lib/moy_sklad/model.rb
CHANGED
data/lib/moy_sklad/version.rb
CHANGED
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'CashIn' do
|
4
|
+
|
5
|
+
describe :index do
|
6
|
+
it "should return list of payments" do
|
7
|
+
payments = MoySklad::Model::CashIn.find(:all)
|
8
|
+
expect(payments.metadata[:total]).to eq(payments.length)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe :find do
|
13
|
+
it "should return payment" do
|
14
|
+
payment = MoySklad::Model::CashIn.new
|
15
|
+
payment.name = "test - payment"
|
16
|
+
payment.sum.sum = 1000 * 100
|
17
|
+
expect(payment.save).to eq(true)
|
18
|
+
expect(payment.uuid.length).to eq(36)
|
19
|
+
|
20
|
+
uuid = payment.uuid
|
21
|
+
payment = MoySklad::Model::CashIn.find(uuid)
|
22
|
+
expect(payment.name).to eq("test - payment")
|
23
|
+
expect(payment.sum.sum).to eq("100000.0")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe :create do
|
28
|
+
|
29
|
+
it "should create new empty CashIn" do
|
30
|
+
payment = MoySklad::Model::CashIn.new
|
31
|
+
expect(payment.save).to eq(true)
|
32
|
+
expect(payment.uuid.length).to eq(36)
|
33
|
+
payment.destroy
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should create new non-empty CashIn" do
|
37
|
+
payment = MoySklad::Model::CashIn.new
|
38
|
+
payment.name = "test - payment"
|
39
|
+
payment.sum.sum = 1000 * 100
|
40
|
+
expect(payment.save).to eq(true)
|
41
|
+
expect(payment.uuid.length).to eq(36)
|
42
|
+
|
43
|
+
uuid = payment.uuid
|
44
|
+
payment = MoySklad::Model::CashIn.find(uuid)
|
45
|
+
expect(payment.name).to eq("test - payment")
|
46
|
+
expect(payment.sum.sum).to eq("100000.0")
|
47
|
+
expect(payment.sum.sumInCurrency).to eq("100000.0")
|
48
|
+
payment.destroy
|
49
|
+
|
50
|
+
expect{MoySklad::Model::CashIn.find(uuid)}.to raise_error(ActiveResource::ResourceNotFound)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should create new order + payment", pending: 'need real data in config' do
|
54
|
+
order = MoySklad::Model::CustomerOrder.new
|
55
|
+
order.name = "Test with payment - API"
|
56
|
+
order.applicable = true
|
57
|
+
order.targetAgentUuid = TGT_AGENT
|
58
|
+
order.sourceStoreUuid = SRC_STORE
|
59
|
+
order.sourceAgentUuid = SRC_AGENT
|
60
|
+
order.stateUuid = CONFIRMED_UUID
|
61
|
+
order.sum.sum = "100"
|
62
|
+
order.sum.sumInCurrency = "100"
|
63
|
+
|
64
|
+
KNOWN_ITEMS.each do |id, info|
|
65
|
+
order.addItem(id, {quantity: info[:quantity],
|
66
|
+
basePrice: { sum: info[:price] * 100, sumInCurrency: info[:price] * 100},
|
67
|
+
price: { sum: info[:price] * 100, sumInCurrency: info[:price] * 100}})
|
68
|
+
end
|
69
|
+
|
70
|
+
ORDER_OPTIONS.each do |type, opt|
|
71
|
+
order.setAttribute({uuid: opt[:key], value: :entityValueUuid}, opt[:value])
|
72
|
+
end
|
73
|
+
|
74
|
+
expect(order.save).to eq(true)
|
75
|
+
expect(order.uuid.length).to eq(36)
|
76
|
+
uuid = order.uuid
|
77
|
+
|
78
|
+
payment = MoySklad::Model::CashIn.new
|
79
|
+
payment.sum.sum = order.sum.sum
|
80
|
+
payment.targetAgentUuid = TGT_AGENT
|
81
|
+
payment.sourceAgentUuid = SRC_AGENT
|
82
|
+
payment.describe = "Just a test"
|
83
|
+
payment.customerOrderUuid = uuid
|
84
|
+
|
85
|
+
expect(payment.save).to eq(true)
|
86
|
+
expect(payment.uuid.length).to eq(36)
|
87
|
+
|
88
|
+
# check order and bounded payment
|
89
|
+
order = MoySklad::Model::CustomerOrder.find(uuid)
|
90
|
+
expect(order.paymentsUuid.to_a(:financeInRef).first).to eq(payment.uuid)
|
91
|
+
|
92
|
+
# Order can be destroyed only after the payment
|
93
|
+
expect{order.destroy}.to raise_error(ActiveResource::ResourceNotFound)
|
94
|
+
payment.destroy
|
95
|
+
order.destroy
|
96
|
+
end
|
97
|
+
|
98
|
+
it "create payment and update applicable status", pending: 'need real data in config' do
|
99
|
+
|
100
|
+
payment = MoySklad::Model::CashIn.new
|
101
|
+
payment.targetAgentUuid = TGT_AGENT
|
102
|
+
payment.sourceAgentUuid = SRC_AGENT
|
103
|
+
payment.sum.sum = 1000 * 100
|
104
|
+
expect(payment.save).to eq(true)
|
105
|
+
uuid = payment.uuid
|
106
|
+
|
107
|
+
payment = MoySklad::Model::CashIn.find(uuid)
|
108
|
+
expect(payment.applicable).to eq("false")
|
109
|
+
payment.applicable = "true"
|
110
|
+
expect(payment.save).to eq(true)
|
111
|
+
|
112
|
+
payment = MoySklad::Model::CashIn.find(uuid)
|
113
|
+
expect(payment.applicable).to eq("true")
|
114
|
+
|
115
|
+
payment.destroy
|
116
|
+
|
117
|
+
expect{MoySklad::Model::CashIn.find(uuid)}.to raise_error(ActiveResource::ResourceNotFound)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moy_sklad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- uno4ki
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-11-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- lib/moy_sklad/client/resource.rb
|
140
140
|
- lib/moy_sklad/configuration.rb
|
141
141
|
- lib/moy_sklad/model.rb
|
142
|
+
- lib/moy_sklad/model/cash_in.rb
|
142
143
|
- lib/moy_sklad/model/company.rb
|
143
144
|
- lib/moy_sklad/model/country.rb
|
144
145
|
- lib/moy_sklad/model/custom_entity.rb
|
@@ -149,6 +150,7 @@ files:
|
|
149
150
|
- lib/moy_sklad/model/good_folder.rb
|
150
151
|
- lib/moy_sklad/model/payment_in.rb
|
151
152
|
- lib/moy_sklad/model/supply.rb
|
153
|
+
- lib/moy_sklad/model/templates/cash_in.builder
|
152
154
|
- lib/moy_sklad/model/templates/company.builder
|
153
155
|
- lib/moy_sklad/model/templates/custom_entity.builder
|
154
156
|
- lib/moy_sklad/model/templates/customer_order.builder
|
@@ -162,6 +164,7 @@ files:
|
|
162
164
|
- moy_sklad.gemspec
|
163
165
|
- spec/ms_config.rb
|
164
166
|
- spec/spec_helper.rb
|
167
|
+
- spec/unit/cash_in_spec.rb
|
165
168
|
- spec/unit/company_spec.rb
|
166
169
|
- spec/unit/country_spec.rb
|
167
170
|
- spec/unit/custom_entity_spec.rb
|
@@ -199,6 +202,7 @@ summary: MoySklad API wrapper
|
|
199
202
|
test_files:
|
200
203
|
- spec/ms_config.rb
|
201
204
|
- spec/spec_helper.rb
|
205
|
+
- spec/unit/cash_in_spec.rb
|
202
206
|
- spec/unit/company_spec.rb
|
203
207
|
- spec/unit/country_spec.rb
|
204
208
|
- spec/unit/custom_entity_spec.rb
|