Commit f1e2e13b29c6df0a5d45c63629b4e2acc48f25a4
Committed by
GitHub
1 parent
762ae45f
Implemented PorTor Business Object (#16)
Showing
8 changed files
with
125 additions
and
264 deletions
Show diff stats
lib/syspro.rb
@@ -51,6 +51,7 @@ require 'syspro/business_objects/models/purchase_orders/comment_line' | @@ -51,6 +51,7 @@ require 'syspro/business_objects/models/purchase_orders/comment_line' | ||
51 | require 'syspro/business_objects/models/comsfm_item' | 51 | require 'syspro/business_objects/models/comsfm_item' |
52 | require 'syspro/business_objects/models/invsws_item' | 52 | require 'syspro/business_objects/models/invsws_item' |
53 | require 'syspro/business_objects/models/inv' | 53 | require 'syspro/business_objects/models/inv' |
54 | +require 'syspro/business_objects/models/receipt_interospection' | ||
54 | 55 | ||
55 | require 'syspro/business_objects/parsers/combrw_parser' | 56 | require 'syspro/business_objects/parsers/combrw_parser' |
56 | require 'syspro/business_objects/parsers/comfch_parser' | 57 | require 'syspro/business_objects/parsers/comfch_parser' |
lib/syspro/business_objects/models/receipt_interospection.rb
0 → 100644
1 | +module Syspro | ||
2 | + module BusinessObjects | ||
3 | + module Models | ||
4 | + class ReceiptInterospection | ||
5 | + attr_accessor :purchase_order, | ||
6 | + :warehouse, | ||
7 | + :stock_code, | ||
8 | + :quantity, | ||
9 | + :counted_quantity_complete, | ||
10 | + :delivery_note, | ||
11 | + :certificate, | ||
12 | + :lot | ||
13 | + end | ||
14 | + end | ||
15 | + end | ||
16 | +end | ||
0 | \ No newline at end of file | 17 | \ No newline at end of file |
lib/syspro/business_objects/parsers/portor_parser.rb
@@ -11,6 +11,8 @@ module Syspro | @@ -11,6 +11,8 @@ module Syspro | ||
11 | end | 11 | end |
12 | 12 | ||
13 | def parse | 13 | def parse |
14 | + error_numbers = doc.xpath("//ErrorNumber").map{|e| e.text} | ||
15 | + | ||
14 | gl_journal = doc.first_element_child.xpath('GlJournal') | 16 | gl_journal = doc.first_element_child.xpath('GlJournal') |
15 | gl_journal_obj = gl_journal.children.map do |el| | 17 | gl_journal_obj = gl_journal.children.map do |el| |
16 | next if el.name == 'text' | 18 | next if el.name == 'text' |
@@ -27,7 +29,7 @@ module Syspro | @@ -27,7 +29,7 @@ module Syspro | ||
27 | key[:entry_number] = doc.first_element_child.xpath('EntryNumber') | 29 | key[:entry_number] = doc.first_element_child.xpath('EntryNumber') |
28 | key[:warehouse] = doc.first_element_child.xpath('Warehouse') | 30 | key[:warehouse] = doc.first_element_child.xpath('Warehouse') |
29 | key[:gl_journal] = gl_journal_obj | 31 | key[:gl_journal] = gl_journal_obj |
30 | - | 32 | + |
31 | receipts = doc.first_element_child.xpath('Receipt') | 33 | receipts = doc.first_element_child.xpath('Receipt') |
32 | receipts_obj = receipts.flat_map do |el| | 34 | receipts_obj = receipts.flat_map do |el| |
33 | el.elements.map do |inner| | 35 | el.elements.map do |inner| |
@@ -45,13 +47,15 @@ module Syspro | @@ -45,13 +47,15 @@ module Syspro | ||
45 | ) | 47 | ) |
46 | end | 48 | end |
47 | 49 | ||
48 | - PorTorObject.new( | ||
49 | - key, | ||
50 | - receipt_models | ||
51 | - ) | 50 | + grns = doc.xpath("//Grn").map{|e| e.text} |
51 | + | ||
52 | + { | ||
53 | + error_numbers: error_numbers, | ||
54 | + key: key, | ||
55 | + receipt: receipt_models, | ||
56 | + grns: grns | ||
57 | + } | ||
52 | end | 58 | end |
53 | - | ||
54 | - PorTorObject = Struct.new(:key, :receipts) | ||
55 | end | 59 | end |
56 | end | 60 | end |
57 | end | 61 | end |
lib/syspro/business_objects/portor.rb
@@ -9,30 +9,36 @@ module Syspro | @@ -9,30 +9,36 @@ module Syspro | ||
9 | include Syspro::ApiOperations::Transaction | 9 | include Syspro::ApiOperations::Transaction |
10 | include Syspro::BusinessObjects::Parsers | 10 | include Syspro::BusinessObjects::Parsers |
11 | 11 | ||
12 | - attr_accessor :transaction_date, :ignore_warnings, :non_stocked_wh_to_use, :grn_matching_action, | ||
13 | - :allow_blank_supplier, :apply_if_entire_document_valid, :validate_only, | ||
14 | - :manual_serial_transfers_allowed, :ignore_analysis | 12 | + attr_accessor :transaction_date, |
13 | + :ignore_warnings, | ||
14 | + :non_stocked_wh_to_use, | ||
15 | + :grn_matching_action, | ||
16 | + :allow_blank_supplier, | ||
17 | + :apply_if_entire_document_valid, | ||
18 | + :validate_only, | ||
19 | + :manual_serial_transfers_allowed, | ||
20 | + :ignore_analysis, | ||
21 | + # :receipts # NOT implemented yet | ||
22 | + :receipt_interospections | ||
15 | 23 | ||
16 | def call(user_id) | 24 | def call(user_id) |
17 | - raise NotImplementedError.new("PORTOR not implemented yet.") | ||
18 | - #xml_parameters = params_template.result(binding) | ||
19 | - #xml_in = template.result(binding) | ||
20 | - #business_object = 'PORTOR' | ||
21 | - #params = { 'UserId' => user_id, | ||
22 | - #'BusinessObject' => business_object, | ||
23 | - #'XmlParameters' => xml_parameters, | ||
24 | - #'XmlIn' => xml_in } | ||
25 | - #resp = PorTor.post(params) | ||
26 | - | ||
27 | - #parse_response(resp) | 25 | + xml_parameters = params_template.result(binding) |
26 | + xml_in = template.result(binding) | ||
27 | + business_object = 'PORTOR' | ||
28 | + params = { 'UserId' => user_id, | ||
29 | + 'BusinessObject' => business_object, | ||
30 | + 'XmlParameters' => xml_parameters, | ||
31 | + 'XmlIn' => xml_in } | ||
32 | + resp = PorTor.post(params) | ||
33 | + parse_response(resp) | ||
28 | end | 34 | end |
29 | 35 | ||
30 | def template | 36 | def template |
31 | - ERB.new File.read(File.expand_path('schemas/portor.xml.erb', File.dirname(__FILE__))), nil, '%' | 37 | + ERB.new File.read(File.expand_path('schemas/portor_doc.xml.erb', File.dirname(__FILE__))), nil, '%' |
32 | end | 38 | end |
33 | 39 | ||
34 | def params_template | 40 | def params_template |
35 | - ERB.new File.read(File.expand_path('schemas/portor_doc.xml.erb', File.dirname(__FILE__))), nil, '%' | 41 | + ERB.new File.read(File.expand_path('schemas/portor.xml.erb', File.dirname(__FILE__))), nil, '%' |
36 | end | 42 | end |
37 | 43 | ||
38 | def parse_response(resp) | 44 | def parse_response(resp) |
@@ -40,6 +46,10 @@ module Syspro | @@ -40,6 +46,10 @@ module Syspro | ||
40 | parser = PorTorParser.new(resp[0].data) | 46 | parser = PorTorParser.new(resp[0].data) |
41 | parser.parse | 47 | parser.parse |
42 | end | 48 | end |
49 | + | ||
50 | + def render_xml(inner_text, dflt_value = "") | ||
51 | + inner_text ? inner_text.to_s : dflt_value | ||
52 | + end | ||
43 | end | 53 | end |
44 | end | 54 | end |
45 | end | 55 | end |
lib/syspro/business_objects/schemas/portor.xml.erb
1 | <?xml version="1.0" encoding="Windows-1252"?> | 1 | <?xml version="1.0" encoding="Windows-1252"?> |
2 | -<!-- Copyright 1994-2010 SYSPRO Ltd.--> | ||
3 | -<!-- | ||
4 | - This is an example XML instance to demonstrate | ||
5 | - use of the Purchase Order Receipts Business Object | ||
6 | ---> | ||
7 | -<PostPurchaseOrderReceipts xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="portordoc.xsd"> | ||
8 | - <Item> | ||
9 | - <Receipt> | ||
10 | - <Journal/> | ||
11 | - <PurchaseOrder>436</PurchaseOrder> | ||
12 | - <PurchaseOrderLine>1</PurchaseOrderLine> | ||
13 | - <Warehouse/> | ||
14 | - <StockCode/> | ||
15 | - <Quantity>750.000</Quantity> | ||
16 | - <UnitOfMeasure/> | ||
17 | - <Units/> | ||
18 | - <Pieces/> | ||
19 | - <DeliveryNote/> | ||
20 | - <Cost/> | ||
21 | - <CostBasis>P</CostBasis> | ||
22 | - <SwitchOnGRNMatching>N</SwitchOnGRNMatching> | ||
23 | - <GRNNumber>311</GRNNumber> | ||
24 | - <Reference/> | ||
25 | - <GRNSource>1</GRNSource> | ||
26 | - <UseSingleTypeABCElements>N</UseSingleTypeABCElements> | ||
27 | - <Lot/> | ||
28 | - <LotExpiryDate/> | ||
29 | - <Certificate/> | ||
30 | - <Concession/> | ||
31 | - <Bins> | ||
32 | - <BinLocation>A1</BinLocation> | ||
33 | - <BinQuantity>750.000</BinQuantity> | ||
34 | - <BinUnits/> | ||
35 | - <BinPieces/> | ||
36 | - </Bins> | ||
37 | - <Serials> | ||
38 | - <SerialNumber>0205</SerialNumber> | ||
39 | - <SerialQuantity>1</SerialQuantity> | ||
40 | - <SerialUnits/> | ||
41 | - <SerialPieces/> | ||
42 | - <SerialExpiryDate/> | ||
43 | - <SerialLocation/> | ||
44 | - </Serials> | ||
45 | - <SerialRange> | ||
46 | - <SerialPrefix>999</SerialPrefix> | ||
47 | - <SerialSuffix>1</SerialSuffix> | ||
48 | - <StartSerialNumber/> | ||
49 | - <SerialQuantity>8</SerialQuantity> | ||
50 | - <SerialExpiryDate/> | ||
51 | - <SerialLocation/> | ||
52 | - </SerialRange> | ||
53 | - <PurchaseOrderLineComplete>N</PurchaseOrderLineComplete> | ||
54 | - <IncreaseSalesOrderQuantity>N</IncreaseSalesOrderQuantity> | ||
55 | - <ChangeSalesOrderStatus>N</ChangeSalesOrderStatus> | ||
56 | - <ApplyCostMultiplier>Y</ApplyCostMultiplier> | ||
57 | - <CostMultiplier/> | ||
58 | - <NonMerchandiseCost>150.00</NonMerchandiseCost> | ||
59 | - <NonMerchandiseDistribution> | ||
60 | - <NmReference>Cost Ref</NmReference> | ||
61 | - <NmLedgerCode>00-1170</NmLedgerCode> | ||
62 | - <NmSupplier>0000026</NmSupplier> | ||
63 | - <NmAmount>150.00</NmAmount> | ||
64 | - <NmAnalysisEntry/> | ||
65 | - <NmAnalysisLineEntry> | ||
66 | - <AnalysisCode1>Air</AnalysisCode1> | ||
67 | - <AnalysisCode2>Conf</AnalysisCode2> | ||
68 | - <AnalysisCode3>East</AnalysisCode3> | ||
69 | - <AnalysisCode4/> | ||
70 | - <AnalysisCode5/> | ||
71 | - <StartDate/> | ||
72 | - <EndDate/> | ||
73 | - <EntryAmount>100</EntryAmount> | ||
74 | - <Comment>Analysis entry details</Comment> | ||
75 | - </NmAnalysisLineEntry> | ||
76 | - <DebitNmAnalysisEntry/> | ||
77 | - <DebitNmAnalysisLineEntry> | ||
78 | - <AnalysisCode1>Air</AnalysisCode1> | ||
79 | - <AnalysisCode2>Conf</AnalysisCode2> | ||
80 | - <AnalysisCode3>East</AnalysisCode3> | ||
81 | - <AnalysisCode4/> | ||
82 | - <AnalysisCode5/> | ||
83 | - <StartDate/> | ||
84 | - <EndDate/> | ||
85 | - <EntryAmount>100</EntryAmount> | ||
86 | - <Comment>Analysis entry details</Comment> | ||
87 | - </DebitNmAnalysisLineEntry> | ||
88 | - </NonMerchandiseDistribution> | ||
89 | - <Notation>P/O Receipt note</Notation> | ||
90 | - <LedgerCode>00-1540</LedgerCode> | ||
91 | - <PasswordForLedgerCode/> | ||
92 | - <DebitLedgerCode/> | ||
93 | - <PasswordForDebitLedgerCode/> | ||
94 | - <CountryOfOrigin/> | ||
95 | - <DeliveryTerms/> | ||
96 | - <NatureOfTransaction/> | ||
97 | - <ModeOfTransport/> | ||
98 | - <TradersReference/> | ||
99 | - <TariffCode/> | ||
100 | - <UnitMass/> | ||
101 | - <SupplementaryUnits>N</SupplementaryUnits> | ||
102 | - <SupplementaryUnitsFactor></SupplementaryUnitsFactor> | ||
103 | - <AnalysisEntry/> | ||
104 | - <AnalysisLineEntry> | ||
105 | - <AnalysisCode1>Air</AnalysisCode1> | ||
106 | - <AnalysisCode2>Conf</AnalysisCode2> | ||
107 | - <AnalysisCode3>East</AnalysisCode3> | ||
108 | - <AnalysisCode4/> | ||
109 | - <AnalysisCode5/> | ||
110 | - <StartDate/> | ||
111 | - <EndDate/> | ||
112 | - <EntryAmount>100</EntryAmount> | ||
113 | - <Comment>Analysis entry details</Comment> | ||
114 | - </AnalysisLineEntry> | ||
115 | - <DebitAnalysisEntry/> | ||
116 | - <DebitAnalysisLineEntry> | ||
117 | - <AnalysisCode1>Air</AnalysisCode1> | ||
118 | - <AnalysisCode2>Conf</AnalysisCode2> | ||
119 | - <AnalysisCode3>East</AnalysisCode3> | ||
120 | - <AnalysisCode4/> | ||
121 | - <AnalysisCode5/> | ||
122 | - <StartDate/> | ||
123 | - <EndDate/> | ||
124 | - <EntryAmount>100</EntryAmount> | ||
125 | - <Comment>Analysis entry details</Comment> | ||
126 | - </DebitAnalysisLineEntry> | ||
127 | - <eSignature/> | ||
128 | - </Receipt> | ||
129 | - </Item> | ||
130 | - <Item> | ||
131 | - <ReceiptIntoInspection> | ||
132 | - <Journal/> | ||
133 | - <PurchaseOrder>436</PurchaseOrder> | ||
134 | - <PurchaseOrderLine>2</PurchaseOrderLine> | ||
135 | - <Warehouse/> | ||
136 | - <StockCode/> | ||
137 | - <Quantity>50.000</Quantity> | ||
138 | - <UnitOfMeasure/> | ||
139 | - <Units/> | ||
140 | - <Pieces/> | ||
141 | - <CountedQuantityComplete>N</CountedQuantityComplete> | ||
142 | - <DeliveryNote/> | ||
143 | - <DeliveryDate/> | ||
144 | - <Certificate/> | ||
145 | - <Narration/> | ||
146 | - <SwitchOnGRNMatching>N</SwitchOnGRNMatching> | ||
147 | - <GRNNumber>301</GRNNumber> | ||
148 | - <Lot/> | ||
149 | - <LotExpiryDate/> | ||
150 | - <PurchaseOrderLineComplete>N</PurchaseOrderLineComplete> | ||
151 | - <Serials> | ||
152 | - <SerialNumber>0205</SerialNumber> | ||
153 | - <SerialQuantity>50</SerialQuantity> | ||
154 | - <SerialUnits/> | ||
155 | - <SerialPieces/> | ||
156 | - <SerialExpiryDate/> | ||
157 | - <SerialLocation/> | ||
158 | - </Serials> | ||
159 | - <SerialRange> | ||
160 | - <SerialPrefix>98</SerialPrefix> | ||
161 | - <SerialSuffix>1</SerialSuffix> | ||
162 | - <StartSerialNumber/> | ||
163 | - <SerialQuantity>8</SerialQuantity> | ||
164 | - <SerialExpiryDate/> | ||
165 | - <SerialLocation/> | ||
166 | - </SerialRange> | ||
167 | - <eSignature/> | ||
168 | - </ReceiptIntoInspection> | ||
169 | - </Item> | ||
170 | - <Item> | ||
171 | - <ReceiptFromInspection> | ||
172 | - <Journal/> | ||
173 | - <GRNNumber>312</GRNNumber> | ||
174 | - <Quantity>10.000</Quantity> | ||
175 | - <Units/> | ||
176 | - <Pieces/> | ||
177 | - <DeliveryNote/> | ||
178 | - <Concession/> | ||
179 | - <Cost/> | ||
180 | - <CostBasis>P</CostBasis> | ||
181 | - <Reference/> | ||
182 | - <GRNSource>1</GRNSource> | ||
183 | - <UseSingleTypeABCElements>N</UseSingleTypeABCElements> | ||
184 | - <Bins> | ||
185 | - <BinLocation>A1</BinLocation> | ||
186 | - <BinQuantity>10.000</BinQuantity> | ||
187 | - <BinUnits/> | ||
188 | - <BinPieces/> | ||
189 | - </Bins> | ||
190 | - <SelectAvailableSerials>N</SelectAvailableSerials> | ||
191 | - <Serials> | ||
192 | - <SerialNumber>0205</SerialNumber> | ||
193 | - <SerialQuantity>1</SerialQuantity> | ||
194 | - <SerialUnits/> | ||
195 | - <SerialPieces/> | ||
196 | - <SerialExpiryDate/> | ||
197 | - <SerialLocation/> | ||
198 | - </Serials> | ||
199 | - <IncreaseSalesOrderQuantity>N</IncreaseSalesOrderQuantity> | ||
200 | - <ChangeSalesOrderStatus>N</ChangeSalesOrderStatus> | ||
201 | - <ApplyCostMultiplier>Y</ApplyCostMultiplier> | ||
202 | - <CostMultiplier/> | ||
203 | - <NonMerchandiseCost>150.00</NonMerchandiseCost> | ||
204 | - <NonMerchandiseDistribution> | ||
205 | - <NmReference>Cost Ref</NmReference> | ||
206 | - <NmLedgerCode>30-4400</NmLedgerCode> | ||
207 | - <NmSupplier/> | ||
208 | - <NmAmount>150.00</NmAmount> | ||
209 | - </NonMerchandiseDistribution> | ||
210 | - <Notation>P/O Receipt note</Notation> | ||
211 | - <LedgerCode>00-1540</LedgerCode> | ||
212 | - <PasswordForLedgerCode/> | ||
213 | - <DebitLedgerCode/> | ||
214 | - <PasswordForDebitLedgerCode/> | ||
215 | - <CountryOfOrigin/> | ||
216 | - <DeliveryTerms/> | ||
217 | - <NatureOfTransaction/> | ||
218 | - <ModeOfTransport/> | ||
219 | - <TradersReference/> | ||
220 | - <TariffCode/> | ||
221 | - <UnitMass/> | ||
222 | - <SupplementaryUnits>N</SupplementaryUnits> | ||
223 | - <SupplementaryUnitsFactor></SupplementaryUnitsFactor> | ||
224 | - </ReceiptFromInspection> | ||
225 | - </Item> | ||
226 | -</PostPurchaseOrderReceipts> | ||
227 | - | 2 | +<PostPurchaseOrderReceipts xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="portor.xsd"> |
3 | + <Parameters> | ||
4 | + <TransactionDate><%= render_xml(@transaction_date) %></TransactionDate> | ||
5 | + <IgnoreWarnings><%= render_xml(@ignore_warnings, "N") %></IgnoreWarnings> | ||
6 | + <NonStockedWhToUse><%= render_xml(@non_stocked_wh_to_use) %></NonStockedWhToUse> | ||
7 | + <GRNMatchingAction><%= render_xml(@grn_matching_action, "A") %></GRNMatchingAction> | ||
8 | + <AllowBlankSupplier><%= render_xml(@allow_blank_supplier, "N")%></AllowBlankSupplier> | ||
9 | + <ApplyIfEntireDocumentValid><%= render_xml(@apply_if_entire_document_valid, "N")%></ApplyIfEntireDocumentValid> | ||
10 | + <ValidateOnly><%= render_xml(@validate_only, "N")%></ValidateOnly> | ||
11 | + <ManualSerialTransfersAllowed><%= render_xml(@manual_serial_transfers_allowed, "N")%></ManualSerialTransfersAllowed> | ||
12 | + <IgnoreAnalysis><%= render_xml(@ignore_analysis, "N")%></IgnoreAnalysis> | ||
13 | + </Parameters> | ||
14 | +</PostPurchaseOrderReceipts> | ||
228 | \ No newline at end of file | 15 | \ No newline at end of file |
lib/syspro/business_objects/schemas/portor_doc.xml.erb
1 | <?xml version="1.0" encoding="Windows-1252"?> | 1 | <?xml version="1.0" encoding="Windows-1252"?> |
2 | -<PostPurchaseOrderReceipts xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="portor.xsd"> | ||
3 | - <Parameters> | ||
4 | - <TransactionDate><%= @transaction_date %></TransactionDate> | ||
5 | - <IgnoreWarnings><%= @ignore_warnings ? "N" : "Y"%></IgnoreWarnings> | ||
6 | - <NonStockedWhToUse><%= @non_stocked_wh_to_use %></NonStockedWhToUse> | ||
7 | - <GRNMatchingAction><%= @grn_matching_action %></GRNMatchingAction> | ||
8 | - <AllowBlankSupplier><%= @allow_blank_supplier ? "N" : "Y" %></AllowBlankSupplier> | ||
9 | - <ApplyIfEntireDocumentValid><%= @apply_if_entire_document_valid ? "N" : "Y" %></ApplyIfEntireDocumentValid> | ||
10 | - <ValidateOnly><%= @validate_only ? "N" : "Y" %></ValidateOnly> | ||
11 | - <ManualSerialTransfersAllowed><%= @manual_serial_transfers_allowed ? "N" : "Y" %></ManualSerialTransfersAllowed> | ||
12 | - <IgnoreAnalysis><%= @ignore_analysis ? "N" : "Y" %></IgnoreAnalysis> | ||
13 | - </Parameters> | ||
14 | -</PostPurchaseOrderReceipts> | ||
15 | - | 2 | +<PostPurchaseOrderReceipts xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="portordoc.xsd"> |
3 | + <% | ||
4 | + if receipt_interospections | ||
5 | + @receipt_interospections.each do |interospection_item| | ||
6 | + %> | ||
7 | + <Item> | ||
8 | + <ReceiptIntoInspection> | ||
9 | + <PurchaseOrder><%= render_xml(interospection_item.purchase_order)%></PurchaseOrder> | ||
10 | + <Warehouse><%= render_xml(interospection_item.warehouse)%></Warehouse> | ||
11 | + <StockCode><%= render_xml(interospection_item.stock_code)%></StockCode> | ||
12 | + <Quantity><%= render_xml(interospection_item.quantity)%></Quantity> | ||
13 | + <CountedQuantityComplete><%= render_xml(interospection_item.counted_quantity_complete, "Y")%></CountedQuantityComplete> | ||
14 | + <DeliveryNote><%= render_xml(interospection_item.delivery_note)%></DeliveryNote> | ||
15 | + <Certificate><%= render_xml(interospection_item.certificate)%></Certificate> | ||
16 | + <Lot><%= render_xml(interospection_item.lot)%></Lot> | ||
17 | + </ReceiptIntoInspection> | ||
18 | + </Item> | ||
19 | + <% | ||
20 | + end | ||
21 | + end | ||
22 | + %> | ||
23 | +</PostPurchaseOrderReceipts> | ||
16 | \ No newline at end of file | 24 | \ No newline at end of file |
test/invsws_test.rb
@@ -13,7 +13,7 @@ class ComsFmTest < Minitest::Test | @@ -13,7 +13,7 @@ class ComsFmTest < Minitest::Test | ||
13 | Syspro::Logon.logon(username, password, company, company_password) | 13 | Syspro::Logon.logon(username, password, company, company_password) |
14 | end | 14 | end |
15 | 15 | ||
16 | - def test_comsfm | 16 | + def test_invsws |
17 | invsws_item = Syspro::BusinessObjects::Models::InvSwsItem.new | 17 | invsws_item = Syspro::BusinessObjects::Models::InvSwsItem.new |
18 | invsws_item.key_stock_code = "1003" | 18 | invsws_item.key_stock_code = "1003" |
19 | invsws_item.key_warehouse = "P0" | 19 | invsws_item.key_warehouse = "P0" |
1 | +# frozen_string_literal: true | ||
2 | + | ||
3 | +require 'test_helper' | ||
4 | + | ||
5 | +class PorTorTest < Minitest::Test | ||
6 | + extend Minitest::Spec::DSL | ||
7 | + | ||
8 | + let(:username) { ENV['SYSPRO_USERNAME'] } | ||
9 | + let(:password) { ENV['SYSPRO_PASSWORD'] } | ||
10 | + let(:company) { ENV['SYSPRO_COMPANY'] } | ||
11 | + let(:company_password) { '' } | ||
12 | + let(:user_id) do | ||
13 | + Syspro::Logon.logon(username, password, company, company_password) | ||
14 | + end | ||
15 | + | ||
16 | + def test_portor | ||
17 | + receipt_intero = Syspro::BusinessObjects::Models::ReceiptInterospection.new | ||
18 | + receipt_intero.purchase_order = "Z01310" | ||
19 | + receipt_intero.warehouse = "P0" | ||
20 | + receipt_intero.stock_code = "8801" | ||
21 | + receipt_intero.quantity = 10.21 | ||
22 | + receipt_intero.delivery_note = "DELIVER NOTE HERE-WL" | ||
23 | + receipt_intero.certificate = "8/45-3" | ||
24 | + receipt_intero.lot = "7097505" | ||
25 | + | ||
26 | + req = Syspro::BusinessObjects::PorTor.new | ||
27 | + req.transaction_date = Time.now.strftime("%Y-%m-%d") | ||
28 | + req.ignore_warnings = "N" | ||
29 | + | ||
30 | + req.receipt_interospections = [receipt_intero] | ||
31 | + resp = req.call(user_id.guid) | ||
32 | + | ||
33 | + assert_equal resp[:error_numbers].length, 0 | ||
34 | + end | ||
35 | +end | ||
0 | \ No newline at end of file | 36 | \ No newline at end of file |