mercator_mesonic 0.0.1 → 0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +14 -4
- data/app/controllers/users_controller_extensions.rb +14 -0
- data/app/models/inventory_extensions.rb +23 -0
- data/app/models/mercator_mesonic/artikelstamm.rb +82 -0
- data/app/models/mercator_mesonic/kontakte_stamm.rb +10 -2
- data/app/models/mercator_mesonic/kontenstamm.rb +8 -1
- data/app/models/mercator_mesonic/kontenstamm_adresse.rb +12 -5
- data/app/models/mercator_mesonic/kontenstamm_fakt.rb +15 -4
- data/app/models/mercator_mesonic/kontenstamm_fibu.rb +12 -3
- data/app/models/mercator_mesonic/order.rb +32 -28
- data/app/models/mercator_mesonic/order_item.rb +25 -22
- data/app/models/mercator_mesonic/price.rb +4 -4
- data/app/models/mercator_mesonic/webartikel.rb +99 -21
- data/app/models/order_extensions.rb +45 -0
- data/app/models/user_extensions.rb +89 -0
- data/app/views/users/invoices_shipments_payments.dryml +144 -0
- data/db/migrate/20140327130259_add_vatline_articlegroup_provisioncode_characteristic_to_inventories.rb +15 -0
- data/lib/mercator_mesonic/engine.rb +2 -0
- data/lib/mercator_mesonic/version.rb +2 -2
- data/lib/tasks/user.rake +75 -0
- data/lib/tasks/webartikel.rake +49 -0
- metadata +55 -34
- data/app/helpers/mercator_mesonic/application_helper.rb +0 -4
- data/lib/tasks/mercator_mesonic_tasks.rake +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd3987f478155f5658a70670dbd33188e998e953
|
4
|
+
data.tar.gz: a3a1ce7517edc6bf5dccb97a17670328e2a495e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6d1446e3e5494b47d6efd1149fcfce3f456f348bd26a239ee97c250ff95ca0132d3523fc715e08166d70ba26d7bcafd3f39f43b4ba12200857d7f497a676e18
|
7
|
+
data.tar.gz: b58e76b67fbba828985e50e053ee1b3564983b13b76ac6c1491d1c5b2889743fcd6b1d1970bcd8afdaa752e08deb5d0f6b6a153c904c7d190f24c03a5b205077
|
data/README.rdoc
CHANGED
@@ -1,16 +1,26 @@
|
|
1
|
-
|
1
|
+
# MercatorMesonic
|
2
2
|
|
3
3
|
Mercator_Mesonic provides Mesonic ERP integration for the Mercator Guided Selling Application.
|
4
4
|
|
5
5
|
This project uses the GPL V3 license. See file LICENSE in the same directory for details about the GPL V3.
|
6
6
|
|
7
|
-
|
7
|
+
## Installation instructions
|
8
8
|
|
9
9
|
1. Put in your Gemfile
|
10
10
|
'''ruby
|
11
11
|
gem "mercator_mesonic"
|
12
12
|
'''
|
13
|
-
2
|
13
|
+
2. Instell gem by running
|
14
|
+
'''ruby
|
15
|
+
bundle install
|
16
|
+
'''
|
17
|
+
3.2 Get all migrations into your app by running in your ipp directory
|
14
18
|
'''ruby
|
15
19
|
rake mercator_mesonic:install:migrations
|
16
|
-
'''
|
20
|
+
'''
|
21
|
+
4. Run Migrations added
|
22
|
+
'''ruby
|
23
|
+
rake db:migrate
|
24
|
+
'''
|
25
|
+
5. Mount the Engine in your routes.rb
|
26
|
+
mount MercatorMesonic::Engine => "/mercator_mesonic"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module UsersControllerExtensions
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
index_action :invoices_shipments_payments do
|
6
|
+
@invoices = MercatorMesonic::Artikelstamm.invoices_by_account_number(account_number: current_user.mesonic_account_number)
|
7
|
+
.group_by { |line| line.Rechnungsnummer }
|
8
|
+
@open_shipments = MercatorMesonic::Artikelstamm.open_shipments_by_account_number(account_number: current_user.mesonic_account_number)
|
9
|
+
.group_by { |line| line.Lieferscheinnummer }
|
10
|
+
@open_payments = MercatorMesonic::Artikelstamm.open_payments_by_account_number(account_number: current_user.mesonic_account_number)
|
11
|
+
.group_by { |line| line.Rechnungsnummer }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module InventoryExtensions
|
2
|
+
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
has_many :mesonic_prices, :class_name => "MercatorMesonic::Price",
|
7
|
+
:foreign_key => "c000", :primary_key => "number"
|
8
|
+
end
|
9
|
+
|
10
|
+
# --- Instance Methods --- #
|
11
|
+
|
12
|
+
def mesonic_price(customer_id: nil )
|
13
|
+
customer = User.find(customer_id)
|
14
|
+
return nil unless customer && customer.erp_account_nr
|
15
|
+
|
16
|
+
customer_prices = self.mesonic_prices.by_customer(customer.erp_account_nr)
|
17
|
+
return customer_prices.first.price if customer_prices.any?
|
18
|
+
|
19
|
+
# HAS 20140407 Was not active in Opensteam!
|
20
|
+
# group_prices = self.mesonic_prices.by_group_through_customer(customer.erp_account_nr)
|
21
|
+
# return group_prices.first.price if customer_prices.any?
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module MercatorMesonic
|
2
|
+
class Artikelstamm < Base
|
3
|
+
|
4
|
+
self.table_name = "t024"
|
5
|
+
self.primary_key = "mesoprim"
|
6
|
+
|
7
|
+
# --- Class Methods --- #
|
8
|
+
def self.invoices_by_account_number(account_number: nil)
|
9
|
+
find_by_sql(
|
10
|
+
"SELECT t025.C030 AS Konto,
|
11
|
+
t025.C032 AS Rechnungsdatum,
|
12
|
+
t025.C055 AS Rechnungsnummer,
|
13
|
+
t025.C063 AS Bestelltext,
|
14
|
+
t026.C003 AS ArtNr,
|
15
|
+
t026.C004 AS Bezeichnung,
|
16
|
+
t026.C006 AS Menge,
|
17
|
+
t026.C007 AS Einzelpreis,
|
18
|
+
t026.C031 AS Gesamtpreis
|
19
|
+
FROM t024 INNER JOIN (t025 INNER JOIN t026 ON (t025.C021 = t026.C044) AND (t025.C022 = t026.C045))
|
20
|
+
ON (t024.C002 = t026.C003) AND (t025.mesoyear = t024.mesoyear) AND (t024.mesocomp = t025.mesocomp)
|
21
|
+
WHERE (((t025.C030)='#{account_number}') AND ((t025.C032) Is Not Null) AND ( (t025.C055) Is Not Null) AND ((t025.C026)='D' Or (t025.C026)='*')
|
22
|
+
AND ((t025.C137)=2) AND ((t025.mesocomp)='2004') AND ((t026.mesocomp)='2004')
|
23
|
+
AND ((Year(t025.C032))>(Year(GetDate())-10)) AND ((t024.C002)=t024.C011))
|
24
|
+
ORDER BY t025.C032 DESC, t025.C055;"
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.open_shipments_by_account_number(account_number: nil)
|
29
|
+
find_by_sql(
|
30
|
+
"SELECT dbo.t025.c030 AS Konto,
|
31
|
+
dbo.t025.c029 AS Lieferscheindatum,
|
32
|
+
dbo.t025.c045 AS Lieferscheinnummer,
|
33
|
+
dbo.t025.c029 AS Rechnungsdatum,
|
34
|
+
dbo.t025.c045 AS Rechnungsnummer,
|
35
|
+
dbo.t025.c063 AS Bestelltext,
|
36
|
+
dbo.t026.c003 AS ArtNr,
|
37
|
+
dbo.t026.c004 AS Bezeichnung,
|
38
|
+
dbo.t026.c006 AS Menge,
|
39
|
+
dbo.t026.c007 AS Einzelpreis,
|
40
|
+
dbo.t026.c031 AS Gesamtpreis,
|
41
|
+
dbo.t024.c002,
|
42
|
+
dbo.t024.c003
|
43
|
+
FROM dbo.t024 INNER JOIN (dbo.t025 INNER JOIN dbo.t026 ON (dbo.t025.c022 = dbo.t026.c045) AND (dbo.t025.c021 = dbo.t026.c044))
|
44
|
+
ON (dbo.t026.c003 = dbo.t024.c002) AND (dbo.t025.mesoyear = dbo.t024.mesoyear) AND (dbo.t024.mesocomp = dbo.t025.mesocomp)
|
45
|
+
|
46
|
+
WHERE (((dbo.t025.c030)='#{account_number}') AND ((dbo.t025.c025)='D' Or (dbo.t025.c025)='*')
|
47
|
+
AND ((dbo.t025.c029) Is Not Null) AND ((dbo.t025.c045) Is Not Null) AND ((dbo.t025.c137)=2) AND ((dbo.t025.mesocomp)='2004')
|
48
|
+
AND ((dbo.t026.mesocomp)='2004') AND ((Year(dbo.T025.c029))>(Year(GetDate())-3)) AND ((dbo.t025.c055) Is Null)
|
49
|
+
AND ((dbo.t024.c002)=dbo.T024.c011))
|
50
|
+
|
51
|
+
ORDER BY dbo.t025.c029 DESC, dbo.t025.c045;"
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.open_payments_by_account_number(account_number: nil)
|
56
|
+
find_by_sql(
|
57
|
+
"SELECT dbo.t025.c030 AS Konto,
|
58
|
+
dbo.t025.c028 AS Auftragsdatum,
|
59
|
+
dbo.t025.c044 AS Auftragsnummer,
|
60
|
+
dbo.t025.c028 AS Rechnungsdatum,
|
61
|
+
dbo.t025.c044 AS Rechnungsnummer,
|
62
|
+
dbo.t025.c063 AS Bestelltext,
|
63
|
+
dbo.t026.c003 AS ArtNr,
|
64
|
+
dbo.t026.c004 AS Bezeichnung,
|
65
|
+
dbo.t026.c006 AS Menge,
|
66
|
+
dbo.t026.c007 AS Einzelpreis,
|
67
|
+
dbo.t026.c031 AS Gesamtpreis
|
68
|
+
FROM dbo.t025 INNER JOIN dbo.t026 ON (dbo.t025.c022 = dbo.t026.c045) AND (dbo.t025.c021 = dbo.t026.c044)
|
69
|
+
WHERE (((dbo.t025.c030)='#{account_number}') AND ((dbo.t025.c024)='D' Or (dbo.t025.c024)='*') AND ((dbo.t025.c028) Is Not Null)
|
70
|
+
AND ((dbo.t025.c044) Is Not Null) AND ((dbo.t025.c137)=2) AND ((dbo.t025.mesocomp)='2004') AND ((dbo.t026.mesocomp)='2004')
|
71
|
+
AND ((Year(dbo.T025.c028))>(Year(GetDate())-3)) AND ((dbo.t025.c055) Is Null) AND ((dbo.t025.c045) Is Null))
|
72
|
+
ORDER BY dbo.t025.c028 DESC, dbo.t025.c044;"
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
# --- Instance Methods --- #
|
77
|
+
|
78
|
+
def readonly? # prevents unintentional changes
|
79
|
+
true
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -5,7 +5,7 @@ module MercatorMesonic
|
|
5
5
|
self.primary_key = "mesoprim"
|
6
6
|
|
7
7
|
attr_accessible :c039, :id, :c000, :c025, :c033, :c035, :c040, :c042, :c043, :c054,
|
8
|
-
:c059, :c060, :C061, :mesocomp, :mesoyear, :mesoprim
|
8
|
+
:c059, :c060, :C061, :C069, :mesocomp, :mesoyear, :mesoprim
|
9
9
|
|
10
10
|
scope :mesoyear, -> { where(mesoyear: AktMandant.mesoyear) }
|
11
11
|
scope :mesocomp, -> { where(mesocomp: AktMandant.mesocomp) }
|
@@ -27,6 +27,9 @@ module MercatorMesonic
|
|
27
27
|
delegate :telephone, :fax, :uid_number, to: :kontenstamm_adresse
|
28
28
|
|
29
29
|
# --- Class Methods --- #
|
30
|
+
def self.default_order
|
31
|
+
:mesoprim
|
32
|
+
end
|
30
33
|
|
31
34
|
def self.next_kontaktenummer
|
32
35
|
last_kontaktenummer = self.select(:c000).order(c000: :desc).limit(1).first.c000.to_i
|
@@ -47,6 +50,7 @@ module MercatorMesonic
|
|
47
50
|
c000: kontaktenummer,
|
48
51
|
c025: user.email_address.to_s,
|
49
52
|
C061: kontaktenummer,
|
53
|
+
C069: 4,
|
50
54
|
mesocomp: AktMandant.mesocomp,
|
51
55
|
mesoyear: AktMandant.mesoyear,
|
52
56
|
mesoprim: kontaktenummer.to_s + "-" + AktMandant.mesocomp + "-" + AktMandant.mesoyear.to_s)
|
@@ -54,7 +58,11 @@ module MercatorMesonic
|
|
54
58
|
|
55
59
|
# --- Instance Methods --- #
|
56
60
|
def full_name
|
57
|
-
self.c001 + "-" + self.c002
|
61
|
+
(self.c001 or "---") + " - " + (self.c002 or "---")
|
62
|
+
end
|
63
|
+
|
64
|
+
def to_s
|
65
|
+
self.kontonummer + self.full_name
|
58
66
|
end
|
59
67
|
end
|
60
68
|
end
|
@@ -21,6 +21,9 @@ module MercatorMesonic
|
|
21
21
|
has_one :kontenstamm_adresse, :class_name => "KontenstammAdresse", :foreign_key => "C001", :primary_key => "c002"
|
22
22
|
|
23
23
|
# --- Class Methods --- #
|
24
|
+
def self.default_order
|
25
|
+
:mesoprim
|
26
|
+
end
|
24
27
|
|
25
28
|
def self.next_kontonummer
|
26
29
|
last_kontonummer = self.interessenten.first.c002.split("I").last.to_i
|
@@ -44,7 +47,7 @@ module MercatorMesonic
|
|
44
47
|
c102: kontonummer,
|
45
48
|
c103: kontonummer,
|
46
49
|
c127: "050-",
|
47
|
-
c069: 2,
|
50
|
+
c069: 2,
|
48
51
|
mesocomp: AktMandant.mesocomp,
|
49
52
|
mesoyear: AktMandant.mesoyear,
|
50
53
|
mesoprim: kontonummer.to_s + "-" + AktMandant.mesocomp + "-" + AktMandant.mesoyear.to_s)
|
@@ -59,5 +62,9 @@ module MercatorMesonic
|
|
59
62
|
def interessent?
|
60
63
|
!self.kunde?
|
61
64
|
end
|
65
|
+
|
66
|
+
def to_s
|
67
|
+
self.name
|
68
|
+
end
|
62
69
|
end
|
63
70
|
end
|
@@ -4,7 +4,7 @@ module MercatorMesonic
|
|
4
4
|
self.table_name = "T051"
|
5
5
|
self.primary_key = "mesoprim"
|
6
6
|
|
7
|
-
attr_accessible :firstname, :lastname, :c001, :c116, :c157, :c180, :c181, :c182, :C241, :c050,
|
7
|
+
attr_accessible :firstname, :lastname, :c001, :c053, :c116, :c157, :c180, :c181, :c182, :C241, :c050,
|
8
8
|
:c051, :c052, :c123, :mesocomp, :mesoyear, :mesoprim
|
9
9
|
|
10
10
|
scope :mesoyear, -> { where(mesoyear: AktMandant.mesoyear) }
|
@@ -25,9 +25,7 @@ module MercatorMesonic
|
|
25
25
|
alias_attribute :email, :c116
|
26
26
|
alias_attribute :web , :c128
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
validates_presence_of :name, :on => :create
|
28
|
+
validates_presence_of :lastname, :on => :create
|
31
29
|
validates_presence_of :street
|
32
30
|
validates_presence_of :city
|
33
31
|
validates_presence_of :postal
|
@@ -46,13 +44,22 @@ module MercatorMesonic
|
|
46
44
|
[ self.tel_land, self.tel_city, self.fax ].join(" ")
|
47
45
|
end
|
48
46
|
|
47
|
+
def to_s
|
48
|
+
(self.postal or "") + (self.city or "") + "," + (self.street or "")
|
49
|
+
end
|
50
|
+
|
49
51
|
#--- Class Methods --- #
|
50
52
|
|
53
|
+
def self.default_order
|
54
|
+
:mesoprim
|
55
|
+
end
|
56
|
+
|
51
57
|
def self.initialize_mesonic(billing_address: nil, kontonummer: nil)
|
52
58
|
self.new(c157: 0, c182: 0, C241: 0,
|
53
59
|
c050: billing_address.street,
|
54
60
|
c051: billing_address.postalcode,
|
55
61
|
c052: billing_address.city,
|
62
|
+
c053: billing_address.c_o,
|
56
63
|
c123: billing_address.country,
|
57
64
|
c180: billing_address.name.split(/\s/).first,
|
58
65
|
c181: billing_address.name.split(/\s/).last,
|
@@ -60,7 +67,7 @@ module MercatorMesonic
|
|
60
67
|
c116: billing_address.email_address.to_s,
|
61
68
|
mesocomp: AktMandant.mesocomp,
|
62
69
|
mesoyear: AktMandant.mesoyear,
|
63
|
-
mesoprim: kontonummer.to_s
|
70
|
+
mesoprim: [kontonummer.to_s, AktMandant.mesocomp, AktMandant.mesoyear.to_s].join("-") )
|
64
71
|
end
|
65
72
|
end
|
66
73
|
end
|
@@ -17,19 +17,30 @@ module MercatorMesonic
|
|
17
17
|
has_many :zahlungsarten, :class_name => "Zahlungsart", :foreign_key => "c000", :primary_key => "c077"
|
18
18
|
|
19
19
|
# --- Class Methods --- #
|
20
|
+
def self.default_order
|
21
|
+
:mesoprim
|
22
|
+
end
|
20
23
|
|
21
|
-
def self.initialize_mesonic(kontonummer: nil)
|
24
|
+
def self.initialize_mesonic(kontonummer: nil, email: nil)
|
22
25
|
self.new(c060: 0, c062: 0, c068: 0, c070: 0, c071: 0, c072: 0, c108: 0, c109: 0, c110: 0, c111: 0,
|
23
|
-
c113: 0, c120: "0", c132: 0, c133: 0, c134: 0, c148: 0, c149: 0, c150: 0, c171: 0,
|
24
|
-
C184: 0,
|
26
|
+
c113: 0, c120: "0", c132: 0, c133: 0, c134: 0, c148: 0, c149: 0, c150: 0, c171: 0, C184: 0,
|
25
27
|
c065: 99,
|
26
28
|
c066: 3,
|
27
29
|
c077: "21",
|
28
30
|
c107: "017",
|
29
31
|
c112: kontonummer,
|
32
|
+
c121: 1,
|
33
|
+
c183: 3, # E-Mail Fakkturen
|
34
|
+
C187: email,
|
30
35
|
mesocomp: AktMandant.mesocomp,
|
31
36
|
mesoyear: AktMandant.mesoyear,
|
32
|
-
mesoprim: kontonummer.to_s
|
37
|
+
mesoprim: [kontonummer.to_s, AktMandant.mesocomp, AktMandant.mesoyear.to_s].join("-"))
|
38
|
+
end
|
39
|
+
|
40
|
+
# --- Instance Methods --- #
|
41
|
+
|
42
|
+
def to_s
|
43
|
+
self.c112
|
33
44
|
end
|
34
45
|
end
|
35
46
|
end
|
@@ -6,7 +6,7 @@ module MercatorMesonic
|
|
6
6
|
|
7
7
|
attr_accessible :c005, :c012, :c007, :c008, :c100, :c104, :c009, :c163, :c174, :C185, :c153, :c164, :c175,
|
8
8
|
:c176, :C186, :c067, :C189, :c058, :c124, :c135, :C190, :c057, :c059, :c114, :c136, :c115,
|
9
|
-
:c137, :c006, :c061, :c063, :c151, :c173, :
|
9
|
+
:c117, :c137, :c006, :c061, :c063, :c151, :c173, :mesocomp, :mesoyear, :mesoprim
|
10
10
|
|
11
11
|
scope :mesoyear, -> { where(mesoyear: AktMandant.mesoyear) }
|
12
12
|
scope :mesocomp, -> { where(mesocomp: AktMandant.mesocomp) }
|
@@ -18,6 +18,10 @@ module MercatorMesonic
|
|
18
18
|
alias_attribute :kontonummer, :c104
|
19
19
|
|
20
20
|
# --- Class Methods --- #
|
21
|
+
def self.default_order
|
22
|
+
:mesoprim
|
23
|
+
end
|
24
|
+
|
21
25
|
|
22
26
|
def self.initialize_mesonic(kontonummer: nil)
|
23
27
|
self.new(c005: 0, c006: 0, c009: 0, c012: 0, c057: 0, c058: 0, c059: 0, c061: 0, c063: 0, c067: 0,
|
@@ -27,11 +31,16 @@ module MercatorMesonic
|
|
27
31
|
c008: "1300",
|
28
32
|
c100: "017",
|
29
33
|
c104: kontonummer,
|
30
|
-
|
34
|
+
c117: kontonummer,
|
31
35
|
c163: -1,
|
32
36
|
mesocomp: AktMandant.mesocomp,
|
33
37
|
mesoyear: AktMandant.mesoyear,
|
34
|
-
mesoprim: kontonummer.to_s
|
38
|
+
mesoprim: [kontonummer.to_s, AktMandant.mesocomp, AktMandant.mesoyear.to_s].join("-") )
|
39
|
+
end
|
40
|
+
|
41
|
+
# --- Instance Methods --- #
|
42
|
+
def to_s
|
43
|
+
self.kontonummer
|
35
44
|
end
|
36
45
|
end
|
37
46
|
end
|
@@ -1,9 +1,18 @@
|
|
1
1
|
module MercatorMesonic
|
2
2
|
class Order < Base
|
3
3
|
|
4
|
-
self.table_name = "
|
4
|
+
self.table_name = "T025"
|
5
5
|
self.primary_key = "C000"
|
6
6
|
|
7
|
+
attr_accessible :c000, :c004, :c005, :c006, :c007, :c008, :c010, :c011, :c012, :c013, :c014, :c017, :c019,
|
8
|
+
:c020, :c021, :c022, :c023, :c024, :c025, :c026, :c027, :c030, :c034, :c035, :c036, :c037,
|
9
|
+
:c038, :c039, :c040, :c041, :c047, :c049, :c050, :c051, :c053, :c054, :c056, :c057, :c059,
|
10
|
+
:c074, :c075, :c076, :c077, :c078, :c080, :c081, :c082, :c086, :c088, :c089, :c090, :c091,
|
11
|
+
:c092, :c093, :c094, :c095, :c096, :c097, :c098, :c099, :c100, :c102, :c103, :c104, :c105,
|
12
|
+
:c106, :c109, :c111, :c113, :c114, :c115, :c116, :c117, :c118, :c120, :c121, :c123, :c126,
|
13
|
+
:c127, :c137, :c139, :c140, :c141, :c142, :c143, :C151, :C152, :C153, :C154, :C155, :C156,
|
14
|
+
:C157, :C158, :C159, :C160, :mesocomp, :mesoyear, :mesoprim
|
15
|
+
|
7
16
|
scope :mesoyear, -> { where(mesoyear: AktMandant.mesoyear) }
|
8
17
|
scope :mesocomp, -> { where(mesocomp: AktMandant.mesocomp) }
|
9
18
|
default_scope { mesocomp.mesoyear }
|
@@ -12,28 +21,30 @@ module MercatorMesonic
|
|
12
21
|
|
13
22
|
def self.initialize_mesonic(order: nil, custom_order_number: nil)
|
14
23
|
|
15
|
-
customer = order.
|
24
|
+
customer = order.user
|
16
25
|
timestamp = Time.now
|
17
26
|
mesonic_kontenstamm_fakt = customer.mesonic_kontenstamm_fakt
|
18
|
-
custom_order_number
|
19
|
-
kontonummer =
|
27
|
+
custom_order_number ||= timestamp.strftime('%y%m%d%H%M%S') + timestamp.usec.to_s # timestamp, if custom order number not provided
|
28
|
+
kontonummer = customer.mesonic_kontenstamm.try(:kunde?) ? customer.mesonic_kontenstamm.kontonummer : "09WEB"
|
20
29
|
usernummer = customer.erp_contact_nr ? customer.erp_contact_nr : customer.id
|
21
|
-
billing_method = order.
|
22
|
-
|
30
|
+
billing_method = order.mesonic_payment_id == 1004 ? mesonic_kontenstamm_fakt.c107 : order.mesonic_payment_id2 #HAS 20140325 FIXME
|
31
|
+
|
32
|
+
billing_state_code = Country.where{(name_de == order.billing_country) | (name_en == order.billing_country)}.first.code
|
33
|
+
shipping_state_code = Country.where{(name_de == order.shipping_country) | (name_en == order.shipping_country)}.first.code
|
23
34
|
|
24
35
|
self.new(c000: kontonummer + "-" + custom_order_number,
|
25
36
|
c004: order.billing_name,
|
26
|
-
c005: order.
|
37
|
+
c005: order.billing_c_o,
|
27
38
|
c006: order.billing_street,
|
28
39
|
c007: order.billing_postalcode,
|
29
40
|
c008: order.billing_city,
|
30
41
|
c010: order.shipping_name,
|
31
|
-
c011: order.
|
42
|
+
c011: order.shipping_c_o,
|
32
43
|
c012: order.shipping_street,
|
33
|
-
c013: order.
|
34
|
-
c014: order.
|
35
|
-
c017:
|
36
|
-
c019:
|
44
|
+
c013: order.shipping_postalcode,
|
45
|
+
c014: order.shipping_city,
|
46
|
+
c017: billing_state_code,
|
47
|
+
c019: shipping_state_code,
|
37
48
|
c020: usernummer,
|
38
49
|
c021: kontonummer,
|
39
50
|
c022: custom_order_number,
|
@@ -42,8 +53,8 @@ module MercatorMesonic
|
|
42
53
|
c025: "N", # durckstatus lieferschein
|
43
54
|
c026: "N", # druckstatus faktura
|
44
55
|
c027: timestamp, # datum angebot
|
45
|
-
c030: customer.
|
46
|
-
c034: mesonic_kontenstamm_fakt.belegart.c014, #
|
56
|
+
c030: customer.mesonic_account_number, #### konto-lieferadresse
|
57
|
+
c034: mesonic_kontenstamm_fakt.belegart.c014, # belegart
|
47
58
|
c035: mesonic_kontenstamm_fakt.c077, # belegart
|
48
59
|
c036: mesonic_kontenstamm_fakt.c065, # vertreternummer
|
49
60
|
c037: 0, # nettotage
|
@@ -54,7 +65,7 @@ module MercatorMesonic
|
|
54
65
|
c047: mesonic_kontenstamm_fakt.c066, # preisliste
|
55
66
|
c049: 0, # fw einheit
|
56
67
|
c050: 0, # fw-faktor
|
57
|
-
c051: billing_method
|
68
|
+
c051: billing_method, # ...derived above
|
58
69
|
c053: mesonic_kontenstamm_fakt.c122, # kostentraeger
|
59
70
|
c054: 400, # kostenstelle
|
60
71
|
c056: 0, # skonto%2
|
@@ -66,11 +77,11 @@ module MercatorMesonic
|
|
66
77
|
c077: 0, # FW-Notierungsflag
|
67
78
|
c078: 0, # xml-erweiterung
|
68
79
|
c080: 0, # filler
|
69
|
-
c081:
|
70
|
-
c082:
|
80
|
+
c081: order.billing_detail,
|
81
|
+
c082: order.shipping_detail,
|
71
82
|
c086: 0, # teilliefersperre
|
72
83
|
c088: 0, # priorität
|
73
|
-
c089: order.
|
84
|
+
c089: order.mesonic_shipping_id,
|
74
85
|
c090: 0, # freier text 2
|
75
86
|
c091: 0, # freier text 3
|
76
87
|
c092: 0, # freier text 4
|
@@ -78,7 +89,7 @@ module MercatorMesonic
|
|
78
89
|
c094: 0, # methode
|
79
90
|
c095: 0, # ausprägung 1
|
80
91
|
c096: 0, # ausprägung 2
|
81
|
-
c097: order.
|
92
|
+
c097: order.mesonic_payment_id, # Zahlungsart
|
82
93
|
c098: 101, # freigabekontrolle angebot
|
83
94
|
c099: order.sum_incl_vat, # kumulierter zahlungsbetrag
|
84
95
|
c100: order.sum_incl_vat, # endbetrag
|
@@ -89,7 +100,7 @@ module MercatorMesonic
|
|
89
100
|
c106: 0, # fremdwährungskurs
|
90
101
|
c109: -1, # kontrakttyp
|
91
102
|
c111: 2, # exim durchgeführte änderungen
|
92
|
-
c113:
|
103
|
+
c113: kontonummer, # konto rechnungsadresse
|
93
104
|
c114: 0, # anzahlungsbetrag
|
94
105
|
c115: 101, # freigabekontrolle auftrag
|
95
106
|
c116: 101, # freigabekontrolle lieferschein
|
@@ -118,14 +129,7 @@ module MercatorMesonic
|
|
118
129
|
C160: 0,
|
119
130
|
mesocomp: AktMandant.mesocomp,
|
120
131
|
mesoyear: AktMandant.mesoyear,
|
121
|
-
mesoprim:
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
# --- Instance Methods --- #
|
126
|
-
|
127
|
-
def readonly? # prevents unintentional changes
|
128
|
-
true
|
132
|
+
mesoprim: [kontonummer, custom_order_number, AktMandant.mesocomp, AktMandant.mesoyear].join("-") )
|
129
133
|
end
|
130
134
|
end
|
131
135
|
end
|