xmlconv 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/History.txt +6 -0
- data/LICENSE +339 -0
- data/README.txt +29 -0
- data/Rakefile +37 -0
- data/bin/admin +68 -0
- data/bin/xmlconvd +38 -0
- data/data/grammar/i2.grammar +73 -0
- data/lib/xmlconv/config.rb +61 -0
- data/lib/xmlconv/custom/lookandfeel.rb +50 -0
- data/lib/xmlconv/i2/address.rb +35 -0
- data/lib/xmlconv/i2/date.rb +41 -0
- data/lib/xmlconv/i2/document.rb +27 -0
- data/lib/xmlconv/i2/header.rb +32 -0
- data/lib/xmlconv/i2/order.rb +61 -0
- data/lib/xmlconv/i2/parser.rb +23 -0
- data/lib/xmlconv/i2/position.rb +45 -0
- data/lib/xmlconv/i2/record.rb +11 -0
- data/lib/xmlconv/model/address.rb +20 -0
- data/lib/xmlconv/model/agreement.rb +10 -0
- data/lib/xmlconv/model/bdd.rb +37 -0
- data/lib/xmlconv/model/bsr.rb +16 -0
- data/lib/xmlconv/model/delivery.rb +15 -0
- data/lib/xmlconv/model/delivery_item.rb +24 -0
- data/lib/xmlconv/model/document.rb +25 -0
- data/lib/xmlconv/model/freetext_container.rb +26 -0
- data/lib/xmlconv/model/id_container.rb +22 -0
- data/lib/xmlconv/model/invoice.rb +18 -0
- data/lib/xmlconv/model/invoice_item.rb +11 -0
- data/lib/xmlconv/model/item.rb +19 -0
- data/lib/xmlconv/model/item_container.rb +15 -0
- data/lib/xmlconv/model/name.rb +27 -0
- data/lib/xmlconv/model/part_info.rb +10 -0
- data/lib/xmlconv/model/part_info_container.rb +15 -0
- data/lib/xmlconv/model/party.rb +20 -0
- data/lib/xmlconv/model/party_container.rb +20 -0
- data/lib/xmlconv/model/price.rb +10 -0
- data/lib/xmlconv/model/price_container.rb +18 -0
- data/lib/xmlconv/model/transaction.rb +28 -0
- data/lib/xmlconv/state/global.rb +28 -0
- data/lib/xmlconv/state/global_predefine.rb +11 -0
- data/lib/xmlconv/state/login.rb +39 -0
- data/lib/xmlconv/state/transaction.rb +13 -0
- data/lib/xmlconv/state/transactions.rb +130 -0
- data/lib/xmlconv/util/application.rb +142 -0
- data/lib/xmlconv/util/autoload.rb +35 -0
- data/lib/xmlconv/util/destination.rb +249 -0
- data/lib/xmlconv/util/invoicer.rb +71 -0
- data/lib/xmlconv/util/known_user.rb +16 -0
- data/lib/xmlconv/util/mail.rb +31 -0
- data/lib/xmlconv/util/polling_manager.rb +198 -0
- data/lib/xmlconv/util/session.rb +23 -0
- data/lib/xmlconv/util/transaction.rb +133 -0
- data/lib/xmlconv/util/validator.rb +20 -0
- data/lib/xmlconv/view/foot.rb +27 -0
- data/lib/xmlconv/view/head.rb +13 -0
- data/lib/xmlconv/view/login.rb +36 -0
- data/lib/xmlconv/view/navigation.rb +30 -0
- data/lib/xmlconv/view/navigationlink.rb +21 -0
- data/lib/xmlconv/view/pager.rb +73 -0
- data/lib/xmlconv/view/preformatted.rb +54 -0
- data/lib/xmlconv/view/template.rb +17 -0
- data/lib/xmlconv/view/transaction.rb +42 -0
- data/lib/xmlconv/view/transactions.rb +90 -0
- data/lib/xmlconv.rb +3 -0
- data/test/config.rb +12 -0
- data/test/mock.rb +149 -0
- data/test/suite.rb +16 -0
- data/test/test_i2/address.rb +88 -0
- data/test/test_i2/date.rb +50 -0
- data/test/test_i2/document.rb +62 -0
- data/test/test_i2/header.rb +39 -0
- data/test/test_i2/order.rb +94 -0
- data/test/test_i2/parser.rb +312 -0
- data/test/test_i2/position.rb +65 -0
- data/test/test_model/address.rb +35 -0
- data/test/test_model/agreement.rb +22 -0
- data/test/test_model/bdd.rb +55 -0
- data/test/test_model/bsr.rb +38 -0
- data/test/test_model/delivery.rb +79 -0
- data/test/test_model/delivery_item.rb +52 -0
- data/test/test_model/freetext_container.rb +45 -0
- data/test/test_model/invoice.rb +65 -0
- data/test/test_model/invoice_item.rb +41 -0
- data/test/test_model/name.rb +57 -0
- data/test/test_model/part_info.rb +24 -0
- data/test/test_model/party.rb +96 -0
- data/test/test_model/price.rb +24 -0
- data/test/test_util/application.rb +168 -0
- data/test/test_util/destination.rb +415 -0
- data/test/test_util/invoicer.rb +42 -0
- data/test/test_util/polling_manager.rb +299 -0
- data/test/test_util/transaction.rb +130 -0
- metadata +178 -0
@@ -0,0 +1,50 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Custom::Lookandfeel -- xmlconv2 -- 09.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'sbsm/lookandfeel'
|
5
|
+
|
6
|
+
module XmlConv
|
7
|
+
module Custom
|
8
|
+
class Lookandfeel < SBSM::Lookandfeel
|
9
|
+
DICTIONARIES = {
|
10
|
+
'de' => {
|
11
|
+
:copyright0 => '©ywesee.com ',
|
12
|
+
:copyright1 => '',
|
13
|
+
:home => 'Home',
|
14
|
+
:login => 'Anmelden',
|
15
|
+
:login_welcome => 'Willkommen bei XmlConv',
|
16
|
+
:logout => 'Abmelden',
|
17
|
+
:navigation_divider => '|',
|
18
|
+
:page_back => "<<",
|
19
|
+
:page_fwd => ">>",
|
20
|
+
:page_number0 => "Seite ",
|
21
|
+
:page_number1 => " von ",
|
22
|
+
:page_number2 => "",
|
23
|
+
:pass => 'Passwort',
|
24
|
+
:status_bbmb_ok => 'Bestellung via BBMB erfolgreich',
|
25
|
+
:status_empty => 'Leer',
|
26
|
+
:status_error => 'Fehler',
|
27
|
+
:status_http_ok => 'Übertragung erfolgreich',
|
28
|
+
:status_http_not_found => 'URI nicht gefunden',
|
29
|
+
:status_http_unauthorized => 'Keine Berechtigung',
|
30
|
+
:status_mail_ok => 'Mailübertragung erfolgreich',
|
31
|
+
:status_open => 'Offen',
|
32
|
+
:status_pending_pickup => 'Bereit zum Abholen',
|
33
|
+
:status_picked_up => 'Abgeholt',
|
34
|
+
:th_commit_time => 'Zeit',
|
35
|
+
:th_error => 'Fehler',
|
36
|
+
:th_input => 'Input',
|
37
|
+
:th_uri_comparable => 'Empf�nger',
|
38
|
+
:th_filename => 'Filename',
|
39
|
+
:th_transaction_id => 'ID',
|
40
|
+
:th_origin => 'Absender',
|
41
|
+
:th_output => 'Output',
|
42
|
+
:th_status_comparable => 'Status',
|
43
|
+
}
|
44
|
+
}
|
45
|
+
RESOURCES = {
|
46
|
+
:css => 'xmlconv.css'
|
47
|
+
}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# I2::Address -- xmlconv2 -- 02.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
module XmlConv
|
5
|
+
module I2
|
6
|
+
class Address
|
7
|
+
attr_accessor :code, :party_id
|
8
|
+
attr_accessor :name1, :name2, :street1, :city, :zip_code, :street2,
|
9
|
+
:country
|
10
|
+
I2_ADDR_CODES = {
|
11
|
+
:buyer => 'BY',
|
12
|
+
:delivery => 'DP',
|
13
|
+
:employee => 'EP',
|
14
|
+
:customer => 'CU',
|
15
|
+
}
|
16
|
+
def initialize
|
17
|
+
@code = :buyer
|
18
|
+
end
|
19
|
+
def to_s
|
20
|
+
output = []
|
21
|
+
numerals = [ 201, 202, 220, 221, 222, 223, 224, 225, 226 ]
|
22
|
+
[
|
23
|
+
I2_ADDR_CODES[@code],
|
24
|
+
@party_id, @name1, @name2, @street1,
|
25
|
+
@city, @country, @zip_code, @street2,
|
26
|
+
].each_with_index { |value, idx|
|
27
|
+
unless(value.nil?)
|
28
|
+
output << "#{numerals[idx]}:#{value}"
|
29
|
+
end
|
30
|
+
}
|
31
|
+
output.join("\n") << "\n"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# I2::Date -- xmlconv2 -- 02.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'date'
|
5
|
+
|
6
|
+
module XmlConv
|
7
|
+
module I2
|
8
|
+
class Date < ::Date
|
9
|
+
attr_accessor :code, :level
|
10
|
+
class << self
|
11
|
+
def from_date(date, level=nil, code=nil)
|
12
|
+
instance = self.new(date.year, date.month, date.day)
|
13
|
+
instance.code = code
|
14
|
+
instance.level = level
|
15
|
+
instance
|
16
|
+
end
|
17
|
+
end
|
18
|
+
def to_s
|
19
|
+
fmtd = strftime("%Y%m%d")
|
20
|
+
datecd = case @code
|
21
|
+
when :delivery
|
22
|
+
'2'
|
23
|
+
else
|
24
|
+
'4'
|
25
|
+
end
|
26
|
+
case @level
|
27
|
+
when :order
|
28
|
+
<<-EOS
|
29
|
+
300:#{datecd}
|
30
|
+
301:#{fmtd}
|
31
|
+
EOS
|
32
|
+
else
|
33
|
+
<<-EOS
|
34
|
+
540:#{datecd}
|
35
|
+
541:#{fmtd}
|
36
|
+
EOS
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# I2::Document -- xmlconv2 -- 02.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'xmlconv/i2/header'
|
5
|
+
require 'xmlconv/i2/order'
|
6
|
+
|
7
|
+
module XmlConv
|
8
|
+
module I2
|
9
|
+
class Document
|
10
|
+
attr_accessor :header
|
11
|
+
attr_reader :orders
|
12
|
+
def initialize
|
13
|
+
@header = Header.new
|
14
|
+
@orders = []
|
15
|
+
end
|
16
|
+
def add_order(order)
|
17
|
+
@orders.push(order)
|
18
|
+
end
|
19
|
+
def filename
|
20
|
+
@header.filename
|
21
|
+
end
|
22
|
+
def to_s
|
23
|
+
([@header] + @orders).join
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# I2::Header -- xmlconv2 -- 02.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
module XmlConv
|
5
|
+
module I2
|
6
|
+
class Header
|
7
|
+
attr_accessor :recipient_id, :filename, :prefix, :transaction_id
|
8
|
+
attr_reader :suffix
|
9
|
+
def initialize(recipient_id = 'EPIN_PL')
|
10
|
+
@recipient_id = recipient_id
|
11
|
+
@prefix = @recipient_id
|
12
|
+
time = Time.now
|
13
|
+
msec = sprintf('%03i', (time.to_f * 1000).to_i % 100)
|
14
|
+
@transaction_id = time.strftime("%Y%m%d%H%M%S#{msec}")
|
15
|
+
end
|
16
|
+
def suffix=(suffix)
|
17
|
+
@suffix = "_" << suffix.to_s
|
18
|
+
end
|
19
|
+
def filename
|
20
|
+
@filename || sprintf("%s%s_%s.dat", @prefix, @suffix, @transaction_id)
|
21
|
+
end
|
22
|
+
def to_s
|
23
|
+
<<-EOS
|
24
|
+
001:#{@recipient_id}
|
25
|
+
002:ORDERX
|
26
|
+
003:220
|
27
|
+
010:#{filename}
|
28
|
+
EOS
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# I2::Order -- xmlconv2 -- 02.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
module XmlConv
|
5
|
+
module I2
|
6
|
+
class Order
|
7
|
+
I2_DELIVERY_CODES = {
|
8
|
+
## janico
|
9
|
+
:pickup => '070',
|
10
|
+
:delivery => '060',
|
11
|
+
:camion => '010',
|
12
|
+
## globopharm
|
13
|
+
:default => '1',
|
14
|
+
:before_9 => '3',
|
15
|
+
:before_21 => '4',
|
16
|
+
:before_16 => '5',
|
17
|
+
:extracted => '13',
|
18
|
+
}
|
19
|
+
attr_accessor :sender_id, :delivery_id, :terms_cond, :agent, :free_text,
|
20
|
+
:interface, :transport_cost, :ade_id
|
21
|
+
attr_reader :addresses, :dates, :positions
|
22
|
+
def initialize
|
23
|
+
@addresses = []
|
24
|
+
@dates = []
|
25
|
+
@positions = []
|
26
|
+
@interface = "61"
|
27
|
+
end
|
28
|
+
def add_address(address)
|
29
|
+
@addresses.push(address)
|
30
|
+
end
|
31
|
+
def add_date(date)
|
32
|
+
@dates.push(date)
|
33
|
+
end
|
34
|
+
def add_position(position)
|
35
|
+
@positions.push(position)
|
36
|
+
end
|
37
|
+
def to_s
|
38
|
+
output = <<-EOS
|
39
|
+
100:#{@sender_id}
|
40
|
+
101:#{@delivery_id}
|
41
|
+
EOS
|
42
|
+
@addresses.each { |addr| output << addr.to_s }
|
43
|
+
numerals = [ 231, 236, 237, 238, 242 ]
|
44
|
+
[
|
45
|
+
@agent, @free_text, @interface, I2_DELIVERY_CODES[@terms_cond],
|
46
|
+
@transport_cost,
|
47
|
+
].each_with_index { |value, idx|
|
48
|
+
unless(value.nil?)
|
49
|
+
output << sprintf("%s:%s\n", numerals[idx], value)
|
50
|
+
end
|
51
|
+
}
|
52
|
+
if(@ade_id)
|
53
|
+
output << sprintf("250:ADE\n251:%s\n", @ade_id)
|
54
|
+
end
|
55
|
+
@dates.each { |date| output << date.to_s }
|
56
|
+
@positions.each { |pos| output << pos.to_s }
|
57
|
+
output
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# I2::Parser -- xmlconv2 -- 28.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'rockit/rockit'
|
5
|
+
|
6
|
+
module XmlConv
|
7
|
+
module I2
|
8
|
+
def cached_parser
|
9
|
+
grammar_path = File.expand_path('i2.grammar', CONFIG.grammar_dir)
|
10
|
+
parser_path = File.expand_path('i2_parser.rb', CONFIG.grammar_dir)
|
11
|
+
old_path = File.expand_path('i2.grammar.old', CONFIG.grammar_dir)
|
12
|
+
src = File.read(grammar_path)
|
13
|
+
unless(File.exists?(old_path) && File.read(old_path) == src)
|
14
|
+
File.delete(old_path) if File.exists?(old_path)
|
15
|
+
Parse.generate_parser_from_file_to_file(grammar_path, parser_path, "make_i2_parser", 'XmlConv')
|
16
|
+
File.open(old_path, 'w') { |f| f << src }
|
17
|
+
end
|
18
|
+
require parser_path
|
19
|
+
XmlConv.make_i2_parser
|
20
|
+
end
|
21
|
+
module_function :cached_parser
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# I2::Position -- xmlconv2 -- 02.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'xmlconv/i2/date'
|
5
|
+
|
6
|
+
module XmlConv
|
7
|
+
module I2
|
8
|
+
class Position
|
9
|
+
attr_accessor :number, :article_ean, :qty, :customer_id, :price, :unit,
|
10
|
+
:pharmacode, :free_text
|
11
|
+
attr_reader :delivery_date
|
12
|
+
def delivery_date=(date)
|
13
|
+
date.code = :delivery
|
14
|
+
@delivery_date = date
|
15
|
+
end
|
16
|
+
def to_s
|
17
|
+
output = <<-EOS
|
18
|
+
500:#{@number}
|
19
|
+
501:#{@article_ean}
|
20
|
+
EOS
|
21
|
+
[@customer_id, @pharmacode].compact.each { |id|
|
22
|
+
output << sprintf("502:%s\n", id)
|
23
|
+
}
|
24
|
+
output << sprintf("520:%s\n", @qty)
|
25
|
+
if(@unit)
|
26
|
+
output << sprintf("521:%s\n", @unit)
|
27
|
+
end
|
28
|
+
if(@delivery_date.is_a?(I2::Date))
|
29
|
+
output << @delivery_date.to_s
|
30
|
+
end
|
31
|
+
if(@price)
|
32
|
+
output << sprintf("604:%s\n", @price)
|
33
|
+
end
|
34
|
+
if(@free_text)
|
35
|
+
output << "605:RS\n"
|
36
|
+
txt = @free_text[0,280] ## upper limit: 40 lines of 70 chars
|
37
|
+
while(!txt.empty?)
|
38
|
+
output << sprintf("606:%s\n", txt.slice!(0,70))
|
39
|
+
end
|
40
|
+
end
|
41
|
+
output
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# AddressLine -- xmlconv2 -- 01.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
module XmlConv
|
5
|
+
module Model
|
6
|
+
class Address
|
7
|
+
attr_accessor :city, :zip_code, :country
|
8
|
+
attr_reader :lines
|
9
|
+
def initialize
|
10
|
+
@lines = []
|
11
|
+
end
|
12
|
+
def add_line(line)
|
13
|
+
lines.push(line)
|
14
|
+
end
|
15
|
+
def size
|
16
|
+
@lines.size
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Bdd -- xmlconv2 -- 01.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'odba'
|
5
|
+
|
6
|
+
module XmlConv
|
7
|
+
module Model
|
8
|
+
class Bdd
|
9
|
+
include ODBA::Persistable
|
10
|
+
ODBA_SERIALIZABLE = ['@deliveries', '@invoices', '@processing_logs']
|
11
|
+
attr_accessor :bsr
|
12
|
+
attr_reader :deliveries, :invoices, :processing_logs
|
13
|
+
def initialize
|
14
|
+
@deliveries = []
|
15
|
+
@invoices = []
|
16
|
+
@processing_logs = []
|
17
|
+
end
|
18
|
+
def add_delivery(delivery)
|
19
|
+
@deliveries.push(delivery)
|
20
|
+
end
|
21
|
+
def add_invoice(invoice)
|
22
|
+
@invoices.push(invoice)
|
23
|
+
end
|
24
|
+
def add_processing_log(log)
|
25
|
+
@processing_logs.push(log)
|
26
|
+
end
|
27
|
+
def empty?
|
28
|
+
@deliveries.empty? && @invoices.empty? && @processing_logs.empty?
|
29
|
+
end
|
30
|
+
def invoiced_amount
|
31
|
+
@invoices.inject(0) { |memo, invoice|
|
32
|
+
memo + invoice.get_price('SummePositionen').amount.to_f
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Bsr -- xmlconv2 -- 01.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'xmlconv/model/party_container'
|
5
|
+
|
6
|
+
module XmlConv
|
7
|
+
module Model
|
8
|
+
class Bsr
|
9
|
+
include PartyContainer
|
10
|
+
attr_accessor :timestamp, :noun, :verb, :interface
|
11
|
+
def bsr_id
|
12
|
+
@customer.party_id unless(@customer.nil?)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Delivery -- xmlconv -- 01.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'xmlconv/model/transaction'
|
5
|
+
|
6
|
+
module XmlConv
|
7
|
+
module Model
|
8
|
+
class Delivery < Transaction
|
9
|
+
attr_accessor :bsr, :delivery_date
|
10
|
+
def bsr_id
|
11
|
+
@bsr.bsr_id unless(@bsr.nil?)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# DeliveryItem -- xmlconv2 -- 01.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'xmlconv/model/item'
|
5
|
+
|
6
|
+
module XmlConv
|
7
|
+
module Model
|
8
|
+
class DeliveryItem < Item
|
9
|
+
attr_accessor :delivery_date
|
10
|
+
def customer_id
|
11
|
+
self.id_table['lieferantenartikel']
|
12
|
+
end
|
13
|
+
def ean13_id
|
14
|
+
self.id_table['ean13']
|
15
|
+
end
|
16
|
+
def et_nummer_id
|
17
|
+
self.id_table['et-nummer']
|
18
|
+
end
|
19
|
+
def pharmacode_id
|
20
|
+
self.id_table['pharmacode']
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Model::Document -- xmlconv -- 03.12.2007 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
module XmlConv
|
5
|
+
module Model
|
6
|
+
class Document < String
|
7
|
+
attr_accessor :recipient_id, :filename, :prefix, :transaction_id
|
8
|
+
def initialize(*args)
|
9
|
+
super
|
10
|
+
@recipient_id = recipient_id
|
11
|
+
@prefix = @recipient_id
|
12
|
+
time = Time.now
|
13
|
+
msec = sprintf('%03i', (time.to_f * 1000).to_i % 100)
|
14
|
+
@transaction_id = time.strftime("%Y%m%d%H%M%S#{msec}")
|
15
|
+
end
|
16
|
+
def filename
|
17
|
+
@filename || sprintf(XmlConv::CONFIG.default_filename,
|
18
|
+
@prefix, @suffix, @transaction_id)
|
19
|
+
end
|
20
|
+
def to_s
|
21
|
+
"" << self
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# FreeTextContainer -- xmlconv2 -- 22.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
module XmlConv
|
5
|
+
module Model
|
6
|
+
class FreeText < String
|
7
|
+
attr_accessor :type
|
8
|
+
def <<(other)
|
9
|
+
if(empty? || other.empty?)
|
10
|
+
super
|
11
|
+
else
|
12
|
+
super("\n" << other)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
module FreeTextContainer
|
17
|
+
attr_accessor :free_text
|
18
|
+
def add_free_text(type, text)
|
19
|
+
@free_text ||= FreeText.new
|
20
|
+
@free_text.type = type
|
21
|
+
@free_text << text.to_s
|
22
|
+
@free_text
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# IdContainer -- xmlconv2 -- 01.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
module XmlConv
|
5
|
+
module Model
|
6
|
+
module IdContainer
|
7
|
+
def acc_id
|
8
|
+
self.id_table['acc']
|
9
|
+
end
|
10
|
+
def add_id(domain, value)
|
11
|
+
self.id_table.store(domain.to_s.downcase, value)
|
12
|
+
self.ids.store(domain, value)
|
13
|
+
end
|
14
|
+
def ids
|
15
|
+
@ids ||= {}
|
16
|
+
end
|
17
|
+
def id_table
|
18
|
+
@id_table ||= {}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Model::Invoice -- xmlconv2 -- 22.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'xmlconv/model/transaction'
|
5
|
+
|
6
|
+
module XmlConv
|
7
|
+
module Model
|
8
|
+
class Invoice < Transaction
|
9
|
+
attr_reader :delivery_id, :invoice_id
|
10
|
+
def add_delivery_id(domain, idstr)
|
11
|
+
@delivery_id = [domain, idstr]
|
12
|
+
end
|
13
|
+
def add_invoice_id(domain, idstr)
|
14
|
+
@invoice_id = [domain, idstr]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Model::Item -- xmlconv2 -- 23.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'xmlconv/model/id_container'
|
5
|
+
require 'xmlconv/model/freetext_container'
|
6
|
+
require 'xmlconv/model/part_info_container'
|
7
|
+
require 'xmlconv/model/price_container'
|
8
|
+
|
9
|
+
module XmlConv
|
10
|
+
module Model
|
11
|
+
class Item
|
12
|
+
attr_accessor :line_no, :qty, :unit
|
13
|
+
include IdContainer
|
14
|
+
include FreeTextContainer
|
15
|
+
include PartInfoContainer
|
16
|
+
include PriceContainer
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Model::ItemContainer -- xmlconv2 -- 22.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
module XmlConv
|
5
|
+
module Model
|
6
|
+
module ItemContainer
|
7
|
+
def add_item(item)
|
8
|
+
self.items.push(item)
|
9
|
+
end
|
10
|
+
def items
|
11
|
+
@items ||= []
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Name -- xmlconv2 -- 01.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
module XmlConv
|
5
|
+
module Model
|
6
|
+
class Name
|
7
|
+
attr_reader :first, :last, :text
|
8
|
+
def first=(arg)
|
9
|
+
set_attr('@first', arg && arg.strip)
|
10
|
+
end
|
11
|
+
def last=(arg)
|
12
|
+
set_attr('@last', arg && arg.strip)
|
13
|
+
end
|
14
|
+
def text=(arg)
|
15
|
+
set_attr('@text', arg && arg.strip)
|
16
|
+
end
|
17
|
+
def to_s
|
18
|
+
[@first, @text, @last].compact.join(' ')
|
19
|
+
end
|
20
|
+
private
|
21
|
+
def set_attr(attr, arg)
|
22
|
+
str = arg.to_s
|
23
|
+
instance_variable_set(attr, str.empty? ? nil : str)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Model::PartInfoContainer -- xmlconv2 -- 23.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
module XmlConv
|
5
|
+
module Model
|
6
|
+
module PartInfoContainer
|
7
|
+
def add_part_info(info)
|
8
|
+
self.part_infos.push(info)
|
9
|
+
end
|
10
|
+
def part_infos
|
11
|
+
@part_infos ||= []
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Party -- xmlconv2 -- 01.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'xmlconv/model/party_container'
|
5
|
+
require 'xmlconv/model/id_container'
|
6
|
+
|
7
|
+
module XmlConv
|
8
|
+
module Model
|
9
|
+
class Party
|
10
|
+
attr_accessor :role, :address, :name
|
11
|
+
include PartyContainer
|
12
|
+
include IdContainer
|
13
|
+
def party_id
|
14
|
+
sorted = self.ids.sort
|
15
|
+
domain, value = sorted.first
|
16
|
+
value
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|