nexus_link 0.0.3
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.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README +1 -0
- data/Rakefile +2 -0
- data/lib/nexus_link/models/articulo.rb +8 -0
- data/lib/nexus_link/models/cliente.rb +8 -0
- data/lib/nexus_link/models/linea_pedido.rb +13 -0
- data/lib/nexus_link/models/pedido_venta.rb +20 -0
- data/lib/nexus_link/models.rb +6 -0
- data/lib/nexus_link/nax/enlace.rb +18 -0
- data/lib/nexus_link/nax/pedido_venta.rb +88 -0
- data/lib/nexus_link/nax.rb +58 -0
- data/lib/nexus_link/version.rb +3 -0
- data/lib/nexus_link.rb +6 -0
- data/nexus_link.gemspec +18 -0
- metadata +79 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
A Ruby gem to interopoerate with Nexus ERP (http://www.websie.com/)
|
data/Rakefile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module NexusLink
|
|
2
|
+
module Models
|
|
3
|
+
class LineaPedidoVenta < ActiveRecord::Base
|
|
4
|
+
self.table_name = "LINEALBA"
|
|
5
|
+
self.primary_key = "IDLIN"
|
|
6
|
+
belongs_to :documento, :class_name => PedidoVenta, :foreign_key => 'IDALBV', :autosave => true
|
|
7
|
+
|
|
8
|
+
def create
|
|
9
|
+
self.documento.nax_save_line(self)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module NexusLink
|
|
2
|
+
module Models
|
|
3
|
+
class PedidoVenta < ActiveRecord::Base
|
|
4
|
+
self.table_name = "CABEALBV" #"CABEPEDV"
|
|
5
|
+
self.primary_key = "IDALBV"
|
|
6
|
+
has_many :lineas, :class_name => 'LineaPedidoVenta', :foreign_key => 'IDALBV', :autosave => true
|
|
7
|
+
|
|
8
|
+
def create
|
|
9
|
+
@nax_obj = Nexus::NAX::PedidoVenta.create(self.attributes)
|
|
10
|
+
self.lineas.each {|l| nax_save_line(l) }
|
|
11
|
+
@nax_obj.save
|
|
12
|
+
@nax_obj = nil
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def nax_save_line(line)
|
|
16
|
+
@nax_obj.add_line(line.attributes)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
module NexusLink
|
|
2
|
+
module NAX
|
|
3
|
+
class PedidoVenta < WIN32OLE
|
|
4
|
+
attr_accessor :attributes
|
|
5
|
+
|
|
6
|
+
def self.circuit
|
|
7
|
+
@circuit
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.circuit=(value)
|
|
11
|
+
@circuit = value
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
self.circuit = :venta
|
|
15
|
+
|
|
16
|
+
def self.create(attrs)
|
|
17
|
+
attrs.reject! { |k, v| v.nil? }
|
|
18
|
+
NAX.open
|
|
19
|
+
fecha = attrs['FCHA'] || Time.now.strftime('%d/%m/%Y')
|
|
20
|
+
codcli = attrs['CODCLI']
|
|
21
|
+
result = NAX::PedidoVenta.new
|
|
22
|
+
result.attributes = attrs.clone
|
|
23
|
+
result.Iniciar
|
|
24
|
+
NAX.check
|
|
25
|
+
result.Nuevo(fecha, codcli , self.circuit == :compra)
|
|
26
|
+
NAX.check
|
|
27
|
+
attrs['IDALBV'] = result.AsStringCab['IDALBV']
|
|
28
|
+
result.refresh_attrs(attrs)
|
|
29
|
+
result
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def save
|
|
33
|
+
attributes.each do |key, val|
|
|
34
|
+
old_val = self.AsStringCab[key.to_s]
|
|
35
|
+
unless val == old_val
|
|
36
|
+
val = '' if val.nil?
|
|
37
|
+
self.AsStringCab[key.to_s] = val
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
self.Anade
|
|
41
|
+
self.Acabar
|
|
42
|
+
NAX.check
|
|
43
|
+
refresh_attrs
|
|
44
|
+
self
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def refresh_attrs(delta={})
|
|
48
|
+
attributes.keys.each { |key| attributes[key] = self.AsStringCab[key.to_s] }
|
|
49
|
+
attributes.merge! delta
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def add_line(line)
|
|
53
|
+
self.NuevaLinea
|
|
54
|
+
NAX.check
|
|
55
|
+
save_line(line)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def update_line(rec_id, delta)
|
|
59
|
+
self.EditarLinea(rec_id)
|
|
60
|
+
NAX.check
|
|
61
|
+
save_line(delta)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def save_line(attrs)
|
|
65
|
+
attrs.each{|key, val|
|
|
66
|
+
val = val.to_f if val.is_a? BigDecimal
|
|
67
|
+
self.AsStringLin[key.to_s] = val if val
|
|
68
|
+
}
|
|
69
|
+
self.AnadirLinea;
|
|
70
|
+
NAX.check
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def initialize
|
|
74
|
+
@progid = "NAX.Albaran"
|
|
75
|
+
super @progid
|
|
76
|
+
@attributes = {}
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def AsStringCab
|
|
80
|
+
OLEProperty.new(self, 15, [VT_BSTR], [VT_BSTR, VT_BSTR])
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def AsStringLin
|
|
84
|
+
OLEProperty.new(self, 19, [VT_BSTR], [VT_BSTR, VT_BSTR])
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require 'win32ole'
|
|
2
|
+
require 'win32ole/property'
|
|
3
|
+
require 'nexus_link/nax/enlace'
|
|
4
|
+
require 'nexus_link/nax/pedido_venta'
|
|
5
|
+
|
|
6
|
+
include WIN32OLE::VARIANT
|
|
7
|
+
|
|
8
|
+
module NexusLink
|
|
9
|
+
module NAX
|
|
10
|
+
|
|
11
|
+
def self.check
|
|
12
|
+
@enlace.check
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.enlace
|
|
16
|
+
@enlace ||= open
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.enlace=(value)
|
|
20
|
+
@enlace = value
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.open?
|
|
24
|
+
@enlace
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.closed?
|
|
28
|
+
!open?
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.open
|
|
32
|
+
return if open?
|
|
33
|
+
@enlace = create_enlace
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.close
|
|
37
|
+
return if closed?
|
|
38
|
+
nax = enlace
|
|
39
|
+
enlace = nil
|
|
40
|
+
nax.close
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def self.establish_connection(conn)
|
|
44
|
+
@conn = conn.dup
|
|
45
|
+
@conn['nax_empresa'] ||= @conn['database']
|
|
46
|
+
self
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def self.create_enlace
|
|
50
|
+
nax_enl = Nexus::NAX::Enlace.new
|
|
51
|
+
nax_enl.RaiseOnException = false
|
|
52
|
+
nax_enl.LoginUsuario(@conn['username'], @conn['password'])
|
|
53
|
+
nax_enl.Iniciar(@conn['nax_empresa'])
|
|
54
|
+
nax_enl.check
|
|
55
|
+
nax_enl
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
data/lib/nexus_link.rb
ADDED
data/nexus_link.gemspec
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "nexus_link/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = "nexus_link"
|
|
7
|
+
s.version = NexusLink::VERSION
|
|
8
|
+
s.platform = Gem::Platform::RUBY
|
|
9
|
+
s.authors = ["Jorge L. Cangas"]
|
|
10
|
+
s.email = ["jorge.cangas@gmail.com"]
|
|
11
|
+
s.homepage = "http://github.com/jcangas/nexus_link"
|
|
12
|
+
s.summary = %q{A Ruby gem to interopoerate with Nexus ERP (http://www.websie.com/)}
|
|
13
|
+
|
|
14
|
+
s.files = `git ls-files`.split("\n")
|
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
17
|
+
s.require_paths = ["lib"]
|
|
18
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: nexus_link
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
prerelease: false
|
|
5
|
+
segments:
|
|
6
|
+
- 0
|
|
7
|
+
- 0
|
|
8
|
+
- 3
|
|
9
|
+
version: 0.0.3
|
|
10
|
+
platform: ruby
|
|
11
|
+
authors:
|
|
12
|
+
- Jorge L. Cangas
|
|
13
|
+
autorequire:
|
|
14
|
+
bindir: bin
|
|
15
|
+
cert_chain: []
|
|
16
|
+
|
|
17
|
+
date: 2011-03-18 00:00:00 +01:00
|
|
18
|
+
default_executable:
|
|
19
|
+
dependencies: []
|
|
20
|
+
|
|
21
|
+
description:
|
|
22
|
+
email:
|
|
23
|
+
- jorge.cangas@gmail.com
|
|
24
|
+
executables: []
|
|
25
|
+
|
|
26
|
+
extensions: []
|
|
27
|
+
|
|
28
|
+
extra_rdoc_files: []
|
|
29
|
+
|
|
30
|
+
files:
|
|
31
|
+
- .gitignore
|
|
32
|
+
- Gemfile
|
|
33
|
+
- README
|
|
34
|
+
- Rakefile
|
|
35
|
+
- lib/nexus_link.rb
|
|
36
|
+
- lib/nexus_link/models.rb
|
|
37
|
+
- lib/nexus_link/models/articulo.rb
|
|
38
|
+
- lib/nexus_link/models/cliente.rb
|
|
39
|
+
- lib/nexus_link/models/linea_pedido.rb
|
|
40
|
+
- lib/nexus_link/models/pedido_venta.rb
|
|
41
|
+
- lib/nexus_link/nax.rb
|
|
42
|
+
- lib/nexus_link/nax/enlace.rb
|
|
43
|
+
- lib/nexus_link/nax/pedido_venta.rb
|
|
44
|
+
- lib/nexus_link/version.rb
|
|
45
|
+
- nexus_link.gemspec
|
|
46
|
+
has_rdoc: true
|
|
47
|
+
homepage: http://github.com/jcangas/nexus_link
|
|
48
|
+
licenses: []
|
|
49
|
+
|
|
50
|
+
post_install_message:
|
|
51
|
+
rdoc_options: []
|
|
52
|
+
|
|
53
|
+
require_paths:
|
|
54
|
+
- lib
|
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
56
|
+
none: false
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
segments:
|
|
61
|
+
- 0
|
|
62
|
+
version: "0"
|
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
|
+
none: false
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
segments:
|
|
69
|
+
- 0
|
|
70
|
+
version: "0"
|
|
71
|
+
requirements: []
|
|
72
|
+
|
|
73
|
+
rubyforge_project:
|
|
74
|
+
rubygems_version: 1.3.7
|
|
75
|
+
signing_key:
|
|
76
|
+
specification_version: 3
|
|
77
|
+
summary: A Ruby gem to interopoerate with Nexus ERP (http://www.websie.com/)
|
|
78
|
+
test_files: []
|
|
79
|
+
|