Revision 82515b2d
Von Sven Schöling vor etwa 14 Jahren hinzugefügt
SL/DB.pm | ||
---|---|---|
1 |
package SL::DB; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use Carp; |
|
6 |
use Data::Dumper; |
|
7 |
use English qw(-no_match_vars); |
|
8 |
use Rose::DB; |
|
9 |
|
|
10 |
use base qw(Rose::DB); |
|
11 |
|
|
12 |
__PACKAGE__->use_private_registry; |
|
13 |
|
|
14 |
my (%_db_registered, %_initial_sql_executed); |
|
15 |
|
|
16 |
sub create { |
|
17 |
my $domain = shift || SL::DB->default_domain; |
|
18 |
my $type = shift || SL::DB->default_type; |
|
19 |
|
|
20 |
if ($type eq 'LXOFFICE') { |
|
21 |
$domain = 'LXEMPTY' unless %::myconfig && $::myconfig{dbname}; |
|
22 |
$type = join $SUBSCRIPT_SEPARATOR, map { $::myconfig{$_} } qw(dbdriver dbname dbhost dbport dbuser dbpasswd) if %::myconfig; |
|
23 |
} |
|
24 |
|
|
25 |
_register_db($domain, $type); |
|
26 |
|
|
27 |
my $db = __PACKAGE__->new_or_cached(domain => $domain, type => $type); |
|
28 |
|
|
29 |
return $db; |
|
30 |
} |
|
31 |
|
|
32 |
sub _register_db { |
|
33 |
my $domain = shift; |
|
34 |
my $type = shift; |
|
35 |
|
|
36 |
my $idx = "${domain}::${type}"; |
|
37 |
return if $_db_registered{$idx}; |
|
38 |
|
|
39 |
$_db_registered{$idx} = 1; |
|
40 |
|
|
41 |
__PACKAGE__->register_db(domain => $domain, |
|
42 |
type => $type, |
|
43 |
driver => $::myconfig{dbdriver} || 'Pg', |
|
44 |
database => $::myconfig{dbname}, |
|
45 |
host => $::myconfig{dbhost}, |
|
46 |
port => $::myconfig{dbport} || 5432, |
|
47 |
username => $::myconfig{dbuser}, |
|
48 |
password => $::myconfig{dbpasswd}, |
|
49 |
connect_options => { pg_enable_utf8 => $::locale && $::locale->is_utf8, |
|
50 |
}, |
|
51 |
); |
|
52 |
} |
|
53 |
|
|
54 |
1; |
SL/DB/Assembly.pm | ||
---|---|---|
1 |
# This file has been auto-generated only because it didn't exist. |
|
2 |
# Feel free to modify it at will; it will not be overwritten automatically. |
|
3 |
|
|
4 |
package SL::DB::Assembly; |
|
5 |
|
|
6 |
use strict; |
|
7 |
|
|
8 |
use SL::DB::MetaSetup::Assembly; |
|
9 |
|
|
10 |
__PACKAGE__->meta->add_relationships( |
|
11 |
part => { |
|
12 |
type => 'one to one', |
|
13 |
class => 'SL::DB::Part', |
|
14 |
column_map => { parts_id => 'id' }, |
|
15 |
}, |
|
16 |
); |
|
17 |
|
|
18 |
# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. |
|
19 |
__PACKAGE__->meta->make_manager_class; |
|
20 |
|
|
21 |
__PACKAGE__->meta->initialize; |
|
22 |
|
|
23 |
1; |
SL/DB/Bin.pm | ||
---|---|---|
1 |
# This file has been auto-generated only because it didn't exist. |
|
2 |
# Feel free to modify it at will; it will not be overwritten automatically. |
|
3 |
|
|
4 |
package SL::DB::Bin; |
|
5 |
|
|
6 |
use strict; |
|
7 |
|
|
8 |
use SL::DB::MetaSetup::Bin; |
|
9 |
|
|
10 |
# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. |
|
11 |
__PACKAGE__->meta->make_manager_class; |
|
12 |
|
|
13 |
1; |
SL/DB/Business.pm | ||
---|---|---|
1 |
# This file has been auto-generated only because it didn't exist. |
|
2 |
# Feel free to modify it at will; it will not be overwritten automatically. |
|
3 |
|
|
4 |
package SL::DB::Business; |
|
5 |
|
|
6 |
use strict; |
|
7 |
|
|
8 |
use SL::DB::MetaSetup::Business; |
|
9 |
|
|
10 |
__PACKAGE__->attr_percent('discount', places => -2); |
|
11 |
|
|
12 |
# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. |
|
13 |
__PACKAGE__->meta->make_manager_class; |
|
14 |
|
|
15 |
1; |
SL/DB/Chart.pm | ||
---|---|---|
1 |
package SL::DB::Chart; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use SL::DB::MetaSetup::Chart; |
|
6 |
|
|
7 |
__PACKAGE__->meta->make_manager_class; |
|
8 |
|
|
9 |
1; |
SL/DB/Customer.pm | ||
---|---|---|
1 |
package SL::DB::Customer; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use SL::DB::MetaSetup::Customer; |
|
6 |
|
|
7 |
use SL::DB::VC; |
|
8 |
|
|
9 |
__PACKAGE__->meta->add_relationship( |
|
10 |
shipto => { |
|
11 |
type => 'one to many', |
|
12 |
class => 'SL::DB::Shipto', |
|
13 |
column_map => { id => 'trans_id' }, |
|
14 |
manager_args => { sort_by => 'lower(shipto.shiptoname)' }, |
|
15 |
query_args => [ 'shipto.module' => 'CT' ], |
|
16 |
}, |
|
17 |
business => { |
|
18 |
type => 'one to one', |
|
19 |
class => 'SL::DB::Business', |
|
20 |
column_map => { business_id => 'id' }, |
|
21 |
}, |
|
22 |
); |
|
23 |
|
|
24 |
__PACKAGE__->meta->make_manager_class; |
|
25 |
__PACKAGE__->meta->initialize; |
|
26 |
|
|
27 |
1; |
SL/DB/DeliveryOrder.pm | ||
---|---|---|
1 |
package SL::DB::DeliveryOrder; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use SL::DB::MetaSetup::DeliveryOrder; |
|
6 |
use SL::DB::Manager::DeliveryOrder; |
|
7 |
use SL::DB::Order; |
|
8 |
|
|
9 |
use List::Util qw(first); |
|
10 |
|
|
11 |
for my $field (qw(transdate reqdate)) { |
|
12 |
__PACKAGE__->attr_date($field); |
|
13 |
} |
|
14 |
|
|
15 |
__PACKAGE__->meta->add_relationship(orderitems => { type => 'one to many', |
|
16 |
class => 'SL::DB::DeliveryOrderItem', |
|
17 |
column_map => { id => 'trans_id' }, |
|
18 |
manager_args => { with_objects => [ 'part' ] } |
|
19 |
}, |
|
20 |
); |
|
21 |
|
|
22 |
__PACKAGE__->meta->initialize; |
|
23 |
|
|
24 |
# methods |
|
25 |
|
|
26 |
sub sales_order { |
|
27 |
my $self = shift; |
|
28 |
my %params = @_; |
|
29 |
|
|
30 |
my $orders = SL::DB::Manager::Order->get_all( |
|
31 |
query => [ |
|
32 |
ordnumber => $self->ordnumber, |
|
33 |
@{ $params{query} || [] }, |
|
34 |
], |
|
35 |
); |
|
36 |
|
|
37 |
return first { $_->is_type('sales_order') } @{ $orders }; |
|
38 |
} |
|
39 |
|
|
40 |
1; |
SL/DB/DeliveryOrderItem.pm | ||
---|---|---|
1 |
package SL::DB::DeliveryOrderItem; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use SL::DB::MetaSetup::DeliveryOrderItem; |
|
6 |
|
|
7 |
for my $field (qw(qty sellprice discount base_qty lastcost price_factor marge_price_factor)) { |
|
8 |
__PACKAGE__->attr_number($field, places => -2); |
|
9 |
} |
|
10 |
|
|
11 |
__PACKAGE__->meta->make_manager_class; |
|
12 |
|
|
13 |
# methods |
|
14 |
|
|
15 |
sub part { |
|
16 |
# canonial alias for parts. |
|
17 |
return shift->parts; |
|
18 |
} |
|
19 |
|
|
20 |
1; |
SL/DB/DeliveryOrderItemsStock.pm | ||
---|---|---|
1 |
# This file has been auto-generated only because it didn't exist. |
|
2 |
# Feel free to modify it at will; it will not be overwritten automatically. |
|
3 |
|
|
4 |
package SL::DB::DeliveryOrderItemsStock; |
|
5 |
|
|
6 |
use strict; |
|
7 |
|
|
8 |
use SL::DB::MetaSetup::DeliveryOrderItemsStock; |
|
9 |
|
|
10 |
for my $field (qw(qty)) { |
|
11 |
__PACKAGE__->attr_number($field, places => -2); |
|
12 |
} |
|
13 |
|
|
14 |
# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. |
|
15 |
__PACKAGE__->meta->make_manager_class; |
|
16 |
|
|
17 |
1; |
SL/DB/GLTransaction.pm | ||
---|---|---|
1 |
package SL::DB::GLTransaction; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use SL::DB::MetaSetup::GLTransaction; |
|
6 |
|
|
7 |
for my $field (qw(transdate gldate)) { |
|
8 |
__PACKAGE__->attr_date($field); |
|
9 |
} |
|
10 |
|
|
11 |
# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. |
|
12 |
__PACKAGE__->meta->make_manager_class; |
|
13 |
|
|
14 |
1; |
SL/DB/Helpers/ALL.pm | ||
---|---|---|
1 |
package SL::DB::Helpers::ALL; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use SL::DB::Assembly; |
|
6 |
use SL::DB::Bin; |
|
7 |
use SL::DB::Business; |
|
8 |
use SL::DB::Chart; |
|
9 |
use SL::DB::Customer; |
|
10 |
use SL::DB::DeliveryOrder; |
|
11 |
use SL::DB::DeliveryOrderItem; |
|
12 |
use SL::DB::DeliveryOrderItemsStock; |
|
13 |
use SL::DB::GLTransaction; |
|
14 |
use SL::DB::Invoice; |
|
15 |
use SL::DB::InvoiceItem; |
|
16 |
use SL::DB::Order; |
|
17 |
use SL::DB::OrderItem; |
|
18 |
use SL::DB::Part; |
|
19 |
use SL::DB::PriceFactor; |
|
20 |
use SL::DB::Printer; |
|
21 |
use SL::DB::Project; |
|
22 |
use SL::DB::PurchaseInvoice; |
|
23 |
use SL::DB::Shipto; |
|
24 |
use SL::DB::TransferType; |
|
25 |
use SL::DB::Unit; |
|
26 |
use SL::DB::Vendor; |
|
27 |
use SL::DB::Warehouse; |
|
28 |
|
|
29 |
1; |
|
30 |
|
|
31 |
__END__ |
|
32 |
|
|
33 |
=pod |
|
34 |
|
|
35 |
=head1 NAME |
|
36 |
|
|
37 |
SL::DB::Helpers::ALL: Dependency-only package for all SL::DB::* modules |
|
38 |
|
|
39 |
=head1 SYNOPSIS |
|
40 |
|
|
41 |
use SL::DB::Helpers::ALL; |
|
42 |
|
|
43 |
=head1 DESCRIPTION |
|
44 |
|
|
45 |
This module depends on all modules in SL/DB/*.pm for the convenience |
|
46 |
of being able to write a simple \C<use SL::DB::Helpers::ALL> and |
|
47 |
having everything loaded. This is supposed to be used only in the |
|
48 |
Lx-Office console. Normal modules should C<use> only the modules they |
|
49 |
actually need. |
|
50 |
|
|
51 |
=head1 AUTHOR |
|
52 |
|
|
53 |
Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt> |
|
54 |
|
|
55 |
=cut |
SL/DB/Helpers/AttrDate.pm | ||
---|---|---|
1 |
package SL::DB::Helpers::AttrDate; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use Carp; |
|
6 |
use English; |
|
7 |
|
|
8 |
sub define { |
|
9 |
my $package = shift; |
|
10 |
my $attribute = shift; |
|
11 |
my %params = @_; |
|
12 |
|
|
13 |
$params{places} = 2 if !defined($params{places}); |
|
14 |
|
|
15 |
my $code = <<CODE; |
|
16 |
package ${package}; |
|
17 |
|
|
18 |
sub ${attribute}_as_date { |
|
19 |
my \$self = shift; |
|
20 |
|
|
21 |
if (scalar \@_) { |
|
22 |
if (\$_[0]) { |
|
23 |
my (\$yy, \$mm, \$dd) = \$::locale->parse_date(\\\%::myconfig, \@_); |
|
24 |
\$self->${attribute}(DateTime->new(year => \$yy, month => \$mm, day => \$dd)); |
|
25 |
} else { |
|
26 |
\$self->${attribute}(undef); |
|
27 |
} |
|
28 |
} |
|
29 |
|
|
30 |
return \$self->${attribute} ? \$::locale->reformat_date({ dateformat => 'yy-mm-dd' }, \$self->${attribute}->ymd, \$::myconfig{dateformat}) : undef; |
|
31 |
} |
|
32 |
|
|
33 |
1; |
|
34 |
CODE |
|
35 |
|
|
36 |
eval $code; |
|
37 |
croak "Defining '${attribute}_as_number' failed: $EVAL_ERROR" if $EVAL_ERROR; |
|
38 |
|
|
39 |
return 1; |
|
40 |
} |
|
41 |
|
|
42 |
1; |
SL/DB/Helpers/AttrNumber.pm | ||
---|---|---|
1 |
package SL::DB::Helpers::AttrNumber; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use Carp; |
|
6 |
use English; |
|
7 |
|
|
8 |
sub define { |
|
9 |
my $package = shift; |
|
10 |
my $attribute = shift; |
|
11 |
my %params = @_; |
|
12 |
|
|
13 |
$params{places} = 2 if !defined($params{places}); |
|
14 |
|
|
15 |
my $code = <<CODE; |
|
16 |
package ${package}; |
|
17 |
|
|
18 |
sub ${attribute}_as_number { |
|
19 |
my \$self = shift; |
|
20 |
|
|
21 |
if (scalar \@_) { |
|
22 |
\$self->${attribute}(\$::form->parse_amount(\\\%::myconfig, \$_[0])); |
|
23 |
} |
|
24 |
|
|
25 |
return \$::form->format_amount(\\\%::myconfig, \$self->${attribute}, $params{places}); |
|
26 |
} |
|
27 |
|
|
28 |
1; |
|
29 |
CODE |
|
30 |
|
|
31 |
eval $code; |
|
32 |
croak "Defining '${attribute}_as_number' failed: $EVAL_ERROR" if $EVAL_ERROR; |
|
33 |
|
|
34 |
return 1; |
|
35 |
} |
|
36 |
|
|
37 |
1; |
SL/DB/Helpers/AttrPercent.pm | ||
---|---|---|
1 |
package SL::DB::Helpers::AttrPercent; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use Carp; |
|
6 |
use English; |
|
7 |
|
|
8 |
sub define { |
|
9 |
my $package = shift; |
|
10 |
my $attribute = shift; |
|
11 |
my %params = @_; |
|
12 |
|
|
13 |
$params{places} = 2 if !defined($params{places}); |
|
14 |
|
|
15 |
my $code = <<CODE; |
|
16 |
package ${package}; |
|
17 |
|
|
18 |
sub ${attribute}_as_percent { |
|
19 |
my \$self = shift; |
|
20 |
|
|
21 |
if (scalar \@_) { |
|
22 |
\$self->${attribute}(\$::form->parse_amount(\\\%::myconfig, \$_[0]) / 100); |
|
23 |
} |
|
24 |
|
|
25 |
return \$::form->format_amount(\\\%::myconfig, 100 * \$self->${attribute}, $params{places}); |
|
26 |
} |
|
27 |
|
|
28 |
1; |
|
29 |
CODE |
|
30 |
|
|
31 |
eval $code; |
|
32 |
croak "Defining '${attribute}_as_number' failed: $EVAL_ERROR" if $EVAL_ERROR; |
|
33 |
|
|
34 |
return 1; |
|
35 |
} |
|
36 |
|
|
37 |
1; |
SL/DB/Helpers/ConventionManager.pm | ||
---|---|---|
1 |
package SL::DB::Helpers::ConventionManager; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use Rose::DB::Object::ConventionManager; |
|
6 |
|
|
7 |
use base qw(Rose::DB::Object::ConventionManager); |
|
8 |
|
|
9 |
sub auto_manager_class_name { |
|
10 |
my $self = shift; |
|
11 |
my $object_class = shift || $self->meta->class; |
|
12 |
|
|
13 |
my @parts = split m/::/, $object_class; |
|
14 |
my $last = pop @parts; |
|
15 |
|
|
16 |
return join('::', @parts, 'Manager', $last); |
|
17 |
} |
|
18 |
|
|
19 |
# Base name used for 'make_manager_class', e.g. 'get_all', |
|
20 |
# 'update_all' |
|
21 |
sub auto_manager_base_name { |
|
22 |
return 'all'; |
|
23 |
} |
|
24 |
|
|
25 |
sub auto_manager_base_class { |
|
26 |
return 'SL::DB::Helpers::Manager'; |
|
27 |
} |
|
28 |
|
|
29 |
1; |
SL/DB/Helpers/Manager.pm | ||
---|---|---|
1 |
package SL::DB::Helpers::Manager; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use Rose::DB::Object::Manager; |
|
6 |
use base qw(Rose::DB::Object::Manager); |
|
7 |
|
|
8 |
sub make_manager_methods { |
|
9 |
my $class = shift; |
|
10 |
my @params = scalar(@_) ? @_ : qw(all); |
|
11 |
return $class->SUPER::make_manager_methods(@params); |
|
12 |
} |
|
13 |
|
|
14 |
sub find_by { |
|
15 |
my $class = shift; |
|
16 |
|
|
17 |
return if !@_; |
|
18 |
return $class->get_all(query => [ @_ ], limit => 1)->[0]; |
|
19 |
} |
|
20 |
|
|
21 |
sub get_first { |
|
22 |
shift->get_all( |
|
23 |
limit => 1, |
|
24 |
)->[0]; |
|
25 |
} |
|
26 |
|
|
27 |
1; |
SL/DB/Helpers/Mappings.pm | ||
---|---|---|
1 |
package SL::DB::Helpers::Mappings; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
# threse will not be managed as Rose::DB models, because they are not normalized |
|
6 |
# significant changes are needed to get them done. |
|
7 |
my @lxoffice_blacklist_permanent = qw( |
|
8 |
acc_trans audittrail customertax datev defaults department dpt_trans |
|
9 |
exchangerate finanzamt follow_up_access gifi inventory leads licenseinvoice |
|
10 |
makemodel partsgroup partstax prices record_links rmaitems status tax_zones |
|
11 |
todo_user_config translation translation_payment_terms units_language |
|
12 |
vendortax); |
|
13 |
|
|
14 |
# these are not managed _yet_, but will hopefully at some point. |
|
15 |
# if you are confident that one of these works, remove it here. |
|
16 |
my @lxoffice_blacklist_temp = qw( |
|
17 |
bank_accounts buchungsgruppen contacts custom_variable_configs |
|
18 |
custom_variables custom_variables_validity drafts dunning dunning_config |
|
19 |
employee follow_up_links follow_ups generic_translations history_erp language |
|
20 |
license notes payment_terms pricegroup rma schema_info sepa_export |
|
21 |
sepa_export_items tax taxkeys |
|
22 |
); |
|
23 |
|
|
24 |
my @lxoffice_blacklist = (@lxoffice_blacklist_permanent, @lxoffice_blacklist_temp); |
|
25 |
|
|
26 |
# map table names to their models. |
|
27 |
# unlike rails we have no singular<->plural magic. |
|
28 |
# remeber: tables should be named as the plural of the model name. |
|
29 |
my %lxoffice_package_names = ( |
|
30 |
ar => 'invoice', |
|
31 |
ap => 'purchase_invoice', |
|
32 |
delivery_orders => 'delivery_order', |
|
33 |
delivery_order_items => 'delivery_order_item', |
|
34 |
gl => 'GLTransaction', |
|
35 |
invoice => 'invoice_item', |
|
36 |
orderitems => 'order_item', |
|
37 |
oe => 'order', |
|
38 |
parts => 'part', |
|
39 |
price_factors => 'price_factor', |
|
40 |
printers => 'Printer', |
|
41 |
units => 'unit', |
|
42 |
); |
|
43 |
|
|
44 |
sub get_blacklist { |
|
45 |
return LXOFFICE => \@lxoffice_blacklist; |
|
46 |
} |
|
47 |
|
|
48 |
sub get_package_names { |
|
49 |
return LXOFFICE => \%lxoffice_package_names; |
|
50 |
} |
|
51 |
|
|
52 |
1; |
|
53 |
|
|
54 |
__END__ |
|
55 |
|
|
56 |
=head1 NAME |
|
57 |
|
|
58 |
SL::DB::Helpers::Mappings - Rose Table <-> Model mapping information |
|
59 |
|
|
60 |
=head1 SYNOPSIS |
|
61 |
|
|
62 |
use SL::DB::Helpers::Mappings qw(@blacklist %table2model); |
|
63 |
|
|
64 |
=head1 DESCRIPTION |
|
65 |
|
|
66 |
This modul stores table <-> model mappings used by the |
|
67 |
L<scripts/rose_auto_create_model.pl> script. If you add a new table that has |
|
68 |
custom mappings, add it here. |
|
69 |
|
|
70 |
=head1 BUGS |
|
71 |
|
|
72 |
nothing yet |
|
73 |
|
|
74 |
=head1 SEE ALSO |
|
75 |
|
|
76 |
L<scripts/rose_auto_create_model.pl> |
|
77 |
|
|
78 |
=head1 AUTHOR |
|
79 |
|
|
80 |
Sven Sch?ling <s.schoeling@linet-services.de> |
|
81 |
|
|
82 |
=cut |
SL/DB/Helpers/Metadata.pm | ||
---|---|---|
1 |
package SL::DB::Helpers::Metadata; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use Rose::DB::Object::Metadata; |
|
6 |
use SL::DB::Helpers::ConventionManager; |
|
7 |
|
|
8 |
use base qw(Rose::DB::Object::Metadata); |
|
9 |
|
|
10 |
sub convention_manager_class { |
|
11 |
return 'SL::DB::Helpers::ConventionManager'; |
|
12 |
} |
|
13 |
|
|
14 |
sub default_manager_base_class { |
|
15 |
return 'SL::DB::Helpers::Manager'; |
|
16 |
} |
|
17 |
|
|
18 |
1; |
SL/DB/Invoice.pm | ||
---|---|---|
1 |
# This file has been auto-generated only because it didn't exist. |
|
2 |
# Feel free to modify it at will; it will not be overwritten automatically. |
|
3 |
|
|
4 |
package SL::DB::Invoice; |
|
5 |
|
|
6 |
use strict; |
|
7 |
|
|
8 |
use List::Util qw(first); |
|
9 |
|
|
10 |
use SL::DB::MetaSetup::Invoice; |
|
11 |
use SL::DB::Manager::Invoice; |
|
12 |
|
|
13 |
__PACKAGE__->attr_number($_, places => -2) for qw(amount netamount paid marge_total marge_percent taxamount); |
|
14 |
__PACKAGE__->attr_date($_) for qw(transdate gldate datepaid duedate deliverydate orddate quodate); |
|
15 |
__PACKAGE__->attr_percent($_) for qw(abschlag_percentage); |
|
16 |
|
|
17 |
__PACKAGE__->meta->add_relationship( |
|
18 |
invoiceitems => { |
|
19 |
type => 'one to many', |
|
20 |
class => 'SL::DB::InvoiceItem', |
|
21 |
column_map => { id => 'trans_id' }, |
|
22 |
manager_args => { |
|
23 |
with_objects => [ 'part' ] |
|
24 |
} |
|
25 |
}, |
|
26 |
); |
|
27 |
|
|
28 |
__PACKAGE__->meta->initialize; |
|
29 |
|
|
30 |
# methods |
|
31 |
|
|
32 |
# it is assumed, that ordnumbers are unique here. |
|
33 |
sub first_order_by_ordnumber { |
|
34 |
my $self = shift; |
|
35 |
|
|
36 |
my $orders = SL::DB::Manager::Order->get_all( |
|
37 |
query => [ |
|
38 |
ordnumber => $self->ordnumber, |
|
39 |
|
|
40 |
], |
|
41 |
); |
|
42 |
|
|
43 |
return first { $_->is_type('sales_order') } @{ $orders }; |
|
44 |
} |
|
45 |
|
|
46 |
sub abschlag_percentage { |
|
47 |
my $self = shift; |
|
48 |
my $order = $self->first_order_by_ordnumber or return; |
|
49 |
my $order_amount = $order->netamount or return; |
|
50 |
return $self->abschlag |
|
51 |
? $self->netamount / $order_amount |
|
52 |
: undef; |
|
53 |
} |
|
54 |
|
|
55 |
sub taxamount { |
|
56 |
my $self = shift; |
|
57 |
die 'not a setter method' if @_; |
|
58 |
|
|
59 |
return $self->amount - $self->netamount; |
|
60 |
} |
|
61 |
|
|
62 |
1; |
SL/DB/InvoiceItem.pm | ||
---|---|---|
1 |
package SL::DB::InvoiceItem; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use SL::DB::MetaSetup::InvoiceItem; |
|
6 |
|
|
7 |
for my $field (qw( |
|
8 |
qty allocated sellprice fxsellprice discount base_qty marge_total |
|
9 |
marge_percent lastcost price_factor marge_price_factor |
|
10 |
)) { |
|
11 |
__PACKAGE__->attr_number($field, places => -2); |
|
12 |
} |
|
13 |
|
|
14 |
__PACKAGE__->meta->add_relationship( |
|
15 |
part => { |
|
16 |
type => 'one to one', |
|
17 |
class => 'SL::DB::Part', |
|
18 |
column_map => { parts_id => 'id' }, |
|
19 |
} |
|
20 |
); |
|
21 |
|
|
22 |
# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. |
|
23 |
__PACKAGE__->meta->make_manager_class; |
|
24 |
|
|
25 |
__PACKAGE__->meta->initialize; |
|
26 |
|
|
27 |
1; |
SL/DB/Manager/DeliveryOrder.pm | ||
---|---|---|
1 |
package SL::DB::Manager::DeliveryOrder; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use SL::DB::Helpers::Manager; |
|
6 |
use base qw(SL::DB::Helpers::Manager); |
|
7 |
|
|
8 |
sub object_class { 'SL::DB::DeliveryOrder' } |
|
9 |
|
|
10 |
__PACKAGE__->make_manager_methods; |
|
11 |
|
|
12 |
sub type_filter { |
|
13 |
my $class = shift; |
|
14 |
my $type = lc(shift || ''); |
|
15 |
|
|
16 |
return ('!customer_id' => undef) if $type eq 'sales_delivery_order'; |
|
17 |
return ('!vendor_id' => undef) if $type eq 'purchase_delivery_order'; |
|
18 |
|
|
19 |
die "Unknown type $type"; |
|
20 |
} |
|
21 |
|
|
22 |
1; |
SL/DB/Manager/Invoice.pm | ||
---|---|---|
1 |
package SL::DB::Manager::Invoice; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use base qw(SL::DB::Helpers::Manager); |
|
6 |
|
|
7 |
sub object_class { 'SL::DB::Invoice' } |
|
8 |
|
|
9 |
__PACKAGE__->make_manager_methods; |
|
10 |
|
|
11 |
sub type_filter { |
|
12 |
my $class = shift; |
|
13 |
my $type = lc(shift || ''); |
|
14 |
|
|
15 |
return (or => [ invoice => 0, invoice => undef ]) if $type eq 'ar_transaction'; |
|
16 |
return (and => [ invoice => 1, amount => { ge => 0 }, or => [ storno => 0, storno => undef ] ]) if $type eq 'invoice'; |
|
17 |
return (and => [ invoice => 1, amount => { lt => 0 }, or => [ storno => 0, storno => undef ] ]) if $type eq 'credit_note'; |
|
18 |
return (and => [ invoice => 1, amount => { lt => 0 }, storno => 1 ]) if $type =~ m/(?:invoice_)?storno/; |
|
19 |
return (and => [ invoice => 1, amount => { ge => 0 }, storno => 1 ]) if $type eq 'credit_note_storno'; |
|
20 |
|
|
21 |
die "Unknown type $type"; |
|
22 |
} |
|
23 |
|
|
24 |
1; |
SL/DB/Manager/Order.pm | ||
---|---|---|
1 |
package SL::DB::Manager::Order; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use SL::DB::Helpers::Manager; |
|
6 |
use base qw(SL::DB::Helpers::Manager); |
|
7 |
|
|
8 |
sub object_class { 'SL::DB::Order' } |
|
9 |
|
|
10 |
__PACKAGE__->make_manager_methods; |
|
11 |
|
|
12 |
sub type_filter { |
|
13 |
my $class = shift; |
|
14 |
my $type = lc(shift || ''); |
|
15 |
|
|
16 |
return (and => [ '!customer_id' => undef, quotation => 1 ]) if $type eq 'sales_quotation'; |
|
17 |
return (and => [ '!vendor_id' => undef, quotation => 1 ]) if $type eq 'request_quotation'; |
|
18 |
return (and => [ '!customer_id' => undef, or => [ quotation => 0, quotation => undef ] ]) if $type eq 'sales_order'; |
|
19 |
return (and => [ '!vendor_id' => undef, or => [ quotation => 0, quotation => undef ] ]) if $type eq 'purchase_order'; |
|
20 |
|
|
21 |
die "Unknown type $type"; |
|
22 |
} |
|
23 |
|
|
24 |
1; |
SL/DB/Manager/Part.pm | ||
---|---|---|
1 |
package SL::DB::Manager::Part; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use SL::DB::Helpers::Manager; |
|
6 |
use base qw(SL::DB::Helpers::Manager); |
|
7 |
|
|
8 |
use Carp; |
|
9 |
use SL::DBUtils; |
|
10 |
|
|
11 |
sub object_class { 'SL::DB::Part' } |
|
12 |
|
|
13 |
__PACKAGE__->make_manager_methods; |
|
14 |
|
|
15 |
sub type_filter { |
|
16 |
my $class = shift; |
|
17 |
my $type = lc(shift || ''); |
|
18 |
|
|
19 |
if ($type =~ m/^part/) { |
|
20 |
return (and => [ or => [ assembly => 0, assembly => undef ], |
|
21 |
'!inventory_accno_id' => 0, |
|
22 |
'!inventory_accno_id' => undef, |
|
23 |
]); |
|
24 |
|
|
25 |
} elsif ($type =~ m/^service/) { |
|
26 |
return (and => [ or => [ assembly => 0, assembly => undef ], |
|
27 |
or => [ inventory_accno_id => 0, inventory_accno_id => undef ], |
|
28 |
]); |
|
29 |
|
|
30 |
} elsif ($type =~ m/^assembl/) { |
|
31 |
return (assembly => 1); |
|
32 |
|
|
33 |
} |
|
34 |
|
|
35 |
return (); |
|
36 |
} |
|
37 |
|
|
38 |
sub get_ordered_qty { |
|
39 |
my $class = shift; |
|
40 |
my @part_ids = @_; |
|
41 |
|
|
42 |
return () unless @part_ids; |
|
43 |
|
|
44 |
my $placeholders = join ',', ('?') x @part_ids; |
|
45 |
my $query = <<SQL; |
|
46 |
SELECT oi.parts_id, SUM(oi.base_qty) AS qty |
|
47 |
FROM orderitems oi |
|
48 |
LEFT JOIN oe ON (oi.trans_id = oe.id) |
|
49 |
WHERE (oi.parts_id IN ($placeholders)) |
|
50 |
AND (NOT COALESCE(oe.quotation, FALSE)) |
|
51 |
AND (NOT COALESCE(oe.closed, FALSE)) |
|
52 |
AND (NOT COALESCE(oe.delivered, FALSE)) |
|
53 |
AND (COALESCE(oe.vendor_id, 0) <> 0) |
|
54 |
GROUP BY oi.parts_id |
|
55 |
SQL |
|
56 |
|
|
57 |
my %qty_by_id = map { $_->{parts_id} => $_->{qty} * 1 } @{ selectall_hashref_query($::form, $class->object_class->init_db->dbh, $query, @part_ids) }; |
|
58 |
map { $qty_by_id{$_} ||= 0 } @part_ids; |
|
59 |
|
|
60 |
return %qty_by_id; |
|
61 |
} |
|
62 |
|
|
63 |
1; |
SL/DB/Manager/PurchaseInvoice.pm | ||
---|---|---|
1 |
package SL::DB::Manager::PurchaseInvoice; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use SL::DB::Helpers::Manager; |
|
6 |
use base qw(SL::DB::Helpers::Manager); |
|
7 |
|
|
8 |
sub object_class { 'SL::DB::PurchaseInvoice' } |
|
9 |
|
|
10 |
__PACKAGE__->make_manager_methods; |
|
11 |
|
|
12 |
sub type_filter { |
|
13 |
my $class = shift; |
|
14 |
my $type = lc(shift || ''); |
|
15 |
|
|
16 |
return (or => [ invoice => 0, invoice => undef ]) if $type eq 'ap_transaction'; |
|
17 |
return (and => [ invoice => 1, or => [ storno => 0, storno => undef ] ]) if $type eq 'invoice'; |
|
18 |
return (and => [ invoice => 1, storno => 1 ]) if $type =~ m/(?:invoice_)?storno/; |
|
19 |
|
|
20 |
die "Unknown type $type"; |
|
21 |
} |
|
22 |
|
|
23 |
1; |
SL/DB/Manager/TransferType.pm | ||
---|---|---|
1 |
package SL::DB::Manager::TransferType; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use base qw(SL::DB::Helpers::Manager); |
|
6 |
|
|
7 |
use Carp; |
|
8 |
|
|
9 |
sub object_class { 'SL::DB::TransferType' } |
|
10 |
|
|
11 |
__PACKAGE__->make_manager_methods; |
|
12 |
|
|
13 |
# class functions |
|
14 |
|
|
15 |
sub get_all_in { |
|
16 |
return shift()->get_all( query => [ direction => 'in', ] ); |
|
17 |
} |
|
18 |
|
|
19 |
sub get_all_out { |
|
20 |
return shift()->get_all( query => [ direction => 'out', ] ); |
|
21 |
} |
|
22 |
|
|
23 |
sub get_all_transfer { |
|
24 |
return shift()->get_all( query => [ direction => 'transfer', ] ); |
|
25 |
} |
|
26 |
|
|
27 |
1; |
SL/DB/MetaSetup/Assembly.pm | ||
---|---|---|
1 |
# This file has been auto-generated. Do not modify it; it will be overwritten |
|
2 |
# by rose_auto_create_model.pl automatically. |
|
3 |
package SL::DB::Assembly; |
|
4 |
|
|
5 |
use strict; |
|
6 |
|
|
7 |
use base qw(SL::DB::Object); |
|
8 |
|
|
9 |
__PACKAGE__->meta->setup( |
|
10 |
table => 'assembly', |
|
11 |
|
|
12 |
columns => [ |
|
13 |
id => { type => 'integer' }, |
|
14 |
parts_id => { type => 'integer' }, |
|
15 |
qty => { type => 'float', precision => 4 }, |
|
16 |
bom => { type => 'boolean' }, |
|
17 |
itime => { type => 'timestamp', default => 'now()' }, |
|
18 |
mtime => { type => 'timestamp' }, |
|
19 |
variable => { type => 'boolean', default => 'false', not_null => 1, remarks => 'true if this part of the assembly is variable, and can be modified' }, |
|
20 |
item_id => { type => 'integer', remarks => 'used to group parts in an assembly for exclusive options' }, |
|
21 |
assembly_id => { type => 'serial', not_null => 1 }, |
|
22 |
], |
|
23 |
|
|
24 |
primary_key_columns => [ 'assembly_id' ], |
|
25 |
|
|
26 |
allow_inline_column_values => 1, |
|
27 |
); |
|
28 |
|
|
29 |
1; |
|
30 |
; |
SL/DB/MetaSetup/Bin.pm | ||
---|---|---|
1 |
# This file has been auto-generated. Do not modify it; it will be overwritten |
|
2 |
# by rose_auto_create_model.pl automatically. |
|
3 |
package SL::DB::Bin; |
|
4 |
|
|
5 |
use strict; |
|
6 |
|
|
7 |
use base qw(SL::DB::Object); |
|
8 |
|
|
9 |
__PACKAGE__->meta->setup( |
|
10 |
table => 'bin', |
|
11 |
|
|
12 |
columns => [ |
|
13 |
id => { type => 'integer', not_null => 1, sequence => 'id' }, |
|
14 |
warehouse_id => { type => 'integer', not_null => 1 }, |
|
15 |
description => { type => 'text' }, |
|
16 |
itime => { type => 'timestamp', default => 'now()' }, |
|
17 |
mtime => { type => 'timestamp' }, |
|
18 |
], |
|
19 |
|
|
20 |
primary_key_columns => [ 'id' ], |
|
21 |
|
|
22 |
allow_inline_column_values => 1, |
|
23 |
|
|
24 |
foreign_keys => [ |
|
25 |
warehouse => { |
|
26 |
class => 'SL::DB::Warehouse', |
|
27 |
key_columns => { warehouse_id => 'id' }, |
|
28 |
}, |
|
29 |
], |
|
30 |
); |
|
31 |
|
|
32 |
1; |
|
33 |
; |
SL/DB/MetaSetup/Business.pm | ||
---|---|---|
1 |
# This file has been auto-generated. Do not modify it; it will be overwritten |
|
2 |
# by rose_auto_create_model.pl automatically. |
|
3 |
package SL::DB::Business; |
|
4 |
|
|
5 |
use strict; |
|
6 |
|
|
7 |
use base qw(SL::DB::Object); |
|
8 |
|
|
9 |
__PACKAGE__->meta->setup( |
|
10 |
table => 'business', |
|
11 |
|
|
12 |
columns => [ |
|
13 |
id => { type => 'integer', not_null => 1, sequence => 'id' }, |
|
14 |
description => { type => 'text' }, |
|
15 |
discount => { type => 'float', precision => 4 }, |
|
16 |
customernumberinit => { type => 'text' }, |
|
17 |
salesman => { type => 'boolean', default => 'false' }, |
|
18 |
itime => { type => 'timestamp', default => 'now()' }, |
|
19 |
mtime => { type => 'timestamp' }, |
|
20 |
], |
|
21 |
|
|
22 |
primary_key_columns => [ 'id' ], |
|
23 |
|
|
24 |
allow_inline_column_values => 1, |
|
25 |
); |
|
26 |
|
|
27 |
1; |
|
28 |
; |
SL/DB/MetaSetup/Chart.pm | ||
---|---|---|
1 |
# This file has been auto-generated. Do not modify it; it will be overwritten |
|
2 |
# by rose_auto_create_model.pl automatically. |
|
3 |
package SL::DB::Chart; |
|
4 |
|
|
5 |
use strict; |
|
6 |
|
|
7 |
use base qw(SL::DB::Object); |
|
8 |
|
|
9 |
__PACKAGE__->meta->setup( |
|
10 |
table => 'chart', |
|
11 |
|
|
12 |
columns => [ |
|
13 |
id => { type => 'integer', not_null => 1, sequence => 'id' }, |
|
14 |
accno => { type => 'text', not_null => 1 }, |
|
15 |
description => { type => 'text' }, |
|
16 |
charttype => { type => 'character', default => 'A', length => 1 }, |
|
17 |
category => { type => 'character', length => 1 }, |
|
18 |
link => { type => 'text' }, |
|
19 |
gifi_accno => { type => 'text' }, |
|
20 |
taxkey_id => { type => 'integer' }, |
|
21 |
pos_ustva => { type => 'integer' }, |
|
22 |
pos_bwa => { type => 'integer' }, |
|
23 |
pos_bilanz => { type => 'integer' }, |
|
24 |
pos_eur => { type => 'integer' }, |
|
25 |
datevautomatik => { type => 'boolean', default => 'false' }, |
|
26 |
itime => { type => 'timestamp', default => 'now()' }, |
|
27 |
mtime => { type => 'timestamp' }, |
|
28 |
new_chart_id => { type => 'integer' }, |
|
29 |
valid_from => { type => 'date' }, |
|
30 |
], |
|
31 |
|
|
32 |
primary_key_columns => [ 'id' ], |
|
33 |
|
|
34 |
unique_key => [ 'accno' ], |
|
35 |
|
|
36 |
allow_inline_column_values => 1, |
|
37 |
); |
|
38 |
|
|
39 |
1; |
|
40 |
; |
SL/DB/MetaSetup/Customer.pm | ||
---|---|---|
1 |
# This file has been auto-generated. Do not modify it; it will be overwritten |
|
2 |
# by rose_auto_create_model.pl automatically. |
|
3 |
package SL::DB::Customer; |
|
4 |
|
|
5 |
use strict; |
|
6 |
|
|
7 |
use base qw(SL::DB::Object); |
|
8 |
|
|
9 |
__PACKAGE__->meta->setup( |
|
10 |
table => 'customer', |
|
11 |
|
|
12 |
columns => [ |
|
13 |
id => { type => 'integer', not_null => 1, sequence => 'id' }, |
|
14 |
name => { type => 'varchar', length => 75, not_null => 1 }, |
|
15 |
department_1 => { type => 'varchar', length => 75 }, |
|
16 |
department_2 => { type => 'varchar', length => 75 }, |
|
17 |
street => { type => 'varchar', length => 75 }, |
|
18 |
zipcode => { type => 'varchar', length => 10 }, |
|
19 |
city => { type => 'varchar', length => 75 }, |
|
20 |
country => { type => 'varchar', length => 75 }, |
|
21 |
contact => { type => 'varchar', length => 75 }, |
|
22 |
phone => { type => 'varchar', length => 30 }, |
|
23 |
fax => { type => 'varchar', length => 30 }, |
|
24 |
homepage => { type => 'text' }, |
|
25 |
email => { type => 'text' }, |
|
26 |
notes => { type => 'text' }, |
|
27 |
discount => { type => 'float', precision => 4 }, |
|
28 |
taxincluded => { type => 'boolean' }, |
|
29 |
creditlimit => { type => 'numeric', default => '0', precision => 5, scale => 15 }, |
|
30 |
terms => { type => 'integer', default => '0' }, |
|
31 |
customernumber => { type => 'text' }, |
|
32 |
cc => { type => 'text' }, |
|
33 |
bcc => { type => 'text' }, |
|
34 |
business_id => { type => 'integer' }, |
|
35 |
taxnumber => { type => 'text' }, |
|
36 |
account_number => { type => 'varchar', length => 15 }, |
|
37 |
bank_code => { type => 'varchar', length => 10 }, |
|
38 |
bank => { type => 'text' }, |
|
39 |
language => { type => 'varchar', length => 5 }, |
|
40 |
datevexport => { type => 'integer' }, |
|
41 |
itime => { type => 'timestamp', default => 'now()' }, |
|
42 |
mtime => { type => 'timestamp' }, |
|
43 |
obsolete => { type => 'boolean', default => 'false' }, |
|
44 |
username => { type => 'varchar', length => 50 }, |
|
45 |
user_password => { type => 'text' }, |
|
46 |
salesman_id => { type => 'integer' }, |
|
47 |
c_vendor_id => { type => 'text' }, |
|
48 |
klass => { type => 'integer', default => '0' }, |
|
49 |
language_id => { type => 'integer' }, |
|
50 |
payment_id => { type => 'integer' }, |
|
51 |
taxzone_id => { type => 'integer', default => '0', not_null => 1 }, |
|
52 |
greeting => { type => 'text' }, |
|
53 |
ustid => { type => 'varchar', length => 14 }, |
|
54 |
direct_debit => { type => 'boolean', default => 'false' }, |
|
55 |
iban => { type => 'varchar', length => 100 }, |
|
56 |
bic => { type => 'varchar', length => 100 }, |
|
57 |
], |
|
58 |
|
|
59 |
primary_key_columns => [ 'id' ], |
|
60 |
|
|
61 |
allow_inline_column_values => 1, |
|
62 |
); |
|
63 |
|
|
64 |
1; |
|
65 |
; |
SL/DB/MetaSetup/DeliveryOrder.pm | ||
---|---|---|
1 |
# This file has been auto-generated. Do not modify it; it will be overwritten |
|
2 |
# by rose_auto_create_model.pl automatically. |
|
3 |
package SL::DB::DeliveryOrder; |
|
4 |
|
|
5 |
use strict; |
|
6 |
|
|
7 |
use base qw(SL::DB::Object); |
|
8 |
|
|
9 |
__PACKAGE__->meta->setup( |
|
10 |
table => 'delivery_orders', |
|
11 |
|
|
12 |
columns => [ |
|
13 |
id => { type => 'integer', not_null => 1, sequence => 'id' }, |
|
14 |
donumber => { type => 'text', not_null => 1 }, |
|
15 |
ordnumber => { type => 'text' }, |
|
16 |
transdate => { type => 'date', default => 'now()' }, |
|
17 |
vendor_id => { type => 'integer' }, |
|
18 |
customer_id => { type => 'integer' }, |
|
19 |
reqdate => { type => 'date' }, |
|
20 |
shippingpoint => { type => 'text' }, |
|
21 |
notes => { type => 'text' }, |
|
22 |
intnotes => { type => 'text' }, |
|
23 |
employee_id => { type => 'integer' }, |
|
24 |
closed => { type => 'boolean', default => 'false' }, |
|
25 |
delivered => { type => 'boolean', default => 'false' }, |
|
26 |
cusordnumber => { type => 'text' }, |
|
27 |
oreqnumber => { type => 'text' }, |
|
28 |
department_id => { type => 'integer' }, |
|
29 |
shipvia => { type => 'text' }, |
|
30 |
cp_id => { type => 'integer' }, |
|
31 |
language_id => { type => 'integer' }, |
|
32 |
shipto_id => { type => 'integer' }, |
|
33 |
globalproject_id => { type => 'integer' }, |
|
34 |
salesman_id => { type => 'integer' }, |
|
35 |
transaction_description => { type => 'text' }, |
|
36 |
is_sales => { type => 'boolean' }, |
|
37 |
itime => { type => 'timestamp', default => 'now()' }, |
|
38 |
mtime => { type => 'timestamp' }, |
|
39 |
notes_bottom => { type => 'text' }, |
|
40 |
taxzone_id => { type => 'integer' }, |
|
41 |
taxincluded => { type => 'boolean' }, |
|
42 |
terms => { type => 'integer' }, |
|
43 |
curr => { type => 'character', length => 3 }, |
|
44 |
], |
|
45 |
|
|
46 |
primary_key_columns => [ 'id' ], |
|
47 |
|
|
48 |
allow_inline_column_values => 1, |
|
49 |
|
|
50 |
foreign_keys => [ |
|
51 |
customer => { |
|
52 |
class => 'SL::DB::Customer', |
|
53 |
key_columns => { customer_id => 'id' }, |
|
54 |
}, |
|
55 |
|
|
56 |
globalproject => { |
|
57 |
class => 'SL::DB::Project', |
|
58 |
key_columns => { globalproject_id => 'id' }, |
|
59 |
}, |
|
60 |
|
|
61 |
vendor => { |
|
62 |
class => 'SL::DB::Vendor', |
|
63 |
key_columns => { vendor_id => 'id' }, |
|
64 |
}, |
|
65 |
], |
|
66 |
); |
|
67 |
|
|
68 |
1; |
|
69 |
; |
SL/DB/MetaSetup/DeliveryOrderItem.pm | ||
---|---|---|
1 |
# This file has been auto-generated. Do not modify it; it will be overwritten |
|
2 |
# by rose_auto_create_model.pl automatically. |
|
3 |
package SL::DB::DeliveryOrderItem; |
|
4 |
|
|
5 |
use strict; |
|
6 |
|
|
7 |
use base qw(SL::DB::Object); |
|
8 |
|
|
9 |
__PACKAGE__->meta->setup( |
|
10 |
table => 'delivery_order_items', |
|
11 |
|
|
12 |
columns => [ |
|
13 |
id => { type => 'integer', not_null => 1, sequence => 'delivery_order_items_id' }, |
|
14 |
delivery_order_id => { type => 'integer', not_null => 1 }, |
|
15 |
parts_id => { type => 'integer', not_null => 1 }, |
|
16 |
description => { type => 'text' }, |
|
17 |
qty => { type => 'numeric', precision => 5, scale => 25 }, |
|
18 |
sellprice => { type => 'numeric', precision => 5, scale => 15 }, |
|
19 |
discount => { type => 'float', precision => 4 }, |
|
20 |
project_id => { type => 'integer' }, |
|
21 |
reqdate => { type => 'date' }, |
|
22 |
serialnumber => { type => 'text' }, |
|
23 |
ordnumber => { type => 'text' }, |
|
24 |
transdate => { type => 'text' }, |
|
25 |
cusordnumber => { type => 'text' }, |
|
26 |
unit => { type => 'varchar', length => 20 }, |
|
27 |
base_qty => { type => 'float', precision => 4 }, |
|
28 |
longdescription => { type => 'text' }, |
|
29 |
lastcost => { type => 'numeric', precision => 5, scale => 15 }, |
|
30 |
price_factor_id => { type => 'integer' }, |
|
31 |
price_factor => { type => 'numeric', default => 1, precision => 5, scale => 15 }, |
|
32 |
marge_price_factor => { type => 'numeric', default => 1, precision => 5, scale => 15 }, |
|
33 |
itime => { type => 'timestamp', default => 'now()' }, |
|
34 |
mtime => { type => 'timestamp' }, |
|
35 |
], |
|
36 |
|
|
37 |
primary_key_columns => [ 'id' ], |
|
38 |
|
|
39 |
allow_inline_column_values => 1, |
|
40 |
|
|
41 |
foreign_keys => [ |
|
42 |
delivery_order => { |
|
43 |
class => 'SL::DB::DeliveryOrder', |
|
44 |
key_columns => { delivery_order_id => 'id' }, |
|
45 |
}, |
|
46 |
|
|
47 |
parts => { |
|
48 |
class => 'SL::DB::Part', |
|
49 |
key_columns => { parts_id => 'id' }, |
|
50 |
}, |
|
51 |
|
|
52 |
price_factor_obj => { |
|
53 |
class => 'SL::DB::PriceFactor', |
|
54 |
key_columns => { price_factor_id => 'id' }, |
|
55 |
}, |
|
56 |
|
|
57 |
project => { |
|
58 |
class => 'SL::DB::Project', |
|
59 |
key_columns => { project_id => 'id' }, |
|
60 |
}, |
|
61 |
], |
|
62 |
); |
|
63 |
|
|
64 |
1; |
|
65 |
; |
SL/DB/MetaSetup/DeliveryOrderItemsStock.pm | ||
---|---|---|
1 |
# This file has been auto-generated. Do not modify it; it will be overwritten |
|
2 |
# by rose_auto_create_model.pl automatically. |
|
3 |
package SL::DB::DeliveryOrderItemsStock; |
|
4 |
|
|
5 |
use strict; |
|
6 |
|
|
7 |
use base qw(SL::DB::Object); |
|
8 |
|
|
9 |
__PACKAGE__->meta->setup( |
|
10 |
table => 'delivery_order_items_stock', |
|
11 |
|
|
12 |
columns => [ |
|
13 |
id => { type => 'integer', not_null => 1, sequence => 'id' }, |
|
14 |
delivery_order_item_id => { type => 'integer', not_null => 1 }, |
|
15 |
qty => { type => 'numeric', not_null => 1, precision => 5, scale => 15 }, |
|
16 |
unit => { type => 'varchar', length => 20, not_null => 1 }, |
|
17 |
warehouse_id => { type => 'integer', not_null => 1 }, |
|
18 |
bin_id => { type => 'integer', not_null => 1 }, |
|
19 |
chargenumber => { type => 'text' }, |
|
20 |
itime => { type => 'timestamp', default => 'now()' }, |
|
21 |
mtime => { type => 'timestamp' }, |
|
22 |
bestbefore => { type => 'date' }, |
|
23 |
], |
|
24 |
|
|
25 |
primary_key_columns => [ 'id' ], |
|
26 |
|
|
27 |
allow_inline_column_values => 1, |
|
28 |
|
|
29 |
foreign_keys => [ |
|
30 |
bin => { |
|
31 |
class => 'SL::DB::Bin', |
|
32 |
key_columns => { bin_id => 'id' }, |
|
33 |
}, |
|
34 |
|
|
35 |
delivery_order_item => { |
|
36 |
class => 'SL::DB::DeliveryOrderItem', |
|
37 |
key_columns => { delivery_order_item_id => 'id' }, |
|
38 |
}, |
|
39 |
|
|
40 |
warehouse => { |
|
41 |
class => 'SL::DB::Warehouse', |
|
42 |
key_columns => { warehouse_id => 'id' }, |
|
43 |
}, |
|
44 |
], |
|
45 |
); |
|
46 |
|
|
47 |
1; |
|
48 |
; |
SL/DB/MetaSetup/GLTransaction.pm | ||
---|---|---|
1 |
# This file has been auto-generated. Do not modify it; it will be overwritten |
|
2 |
# by rose_auto_create_model.pl automatically. |
|
3 |
package SL::DB::GLTransaction; |
|
4 |
|
|
5 |
use strict; |
|
6 |
|
|
7 |
use base qw(SL::DB::Object); |
|
8 |
|
|
9 |
__PACKAGE__->meta->setup( |
|
10 |
table => 'gl', |
|
11 |
|
|
12 |
columns => [ |
|
13 |
id => { type => 'integer', not_null => 1, sequence => 'glid' }, |
|
14 |
reference => { type => 'text' }, |
|
15 |
description => { type => 'text' }, |
|
16 |
transdate => { type => 'date', default => 'now' }, |
|
17 |
gldate => { type => 'date', default => 'now' }, |
|
18 |
employee_id => { type => 'integer' }, |
|
19 |
notes => { type => 'text' }, |
|
20 |
department_id => { type => 'integer', default => '0' }, |
|
21 |
taxincluded => { type => 'boolean' }, |
|
22 |
itime => { type => 'timestamp', default => 'now()' }, |
|
23 |
mtime => { type => 'timestamp' }, |
|
24 |
type => { type => 'text' }, |
|
25 |
storno => { type => 'boolean', default => 'false' }, |
|
26 |
storno_id => { type => 'integer' }, |
|
27 |
ob_transaction => { type => 'boolean' }, |
|
28 |
cb_transaction => { type => 'boolean' }, |
|
29 |
], |
|
30 |
|
|
31 |
primary_key_columns => [ 'id' ], |
|
32 |
|
|
33 |
allow_inline_column_values => 1, |
|
34 |
|
|
35 |
foreign_keys => [ |
|
36 |
storno_obj => { |
|
37 |
class => 'SL::DB::GLTransaction', |
|
38 |
key_columns => { storno_id => 'id' }, |
|
39 |
}, |
|
40 |
], |
|
41 |
); |
|
42 |
|
|
43 |
1; |
|
44 |
; |
SL/DB/MetaSetup/Invoice.pm | ||
---|---|---|
1 |
# This file has been auto-generated. Do not modify it; it will be overwritten |
|
2 |
# by rose_auto_create_model.pl automatically. |
|
3 |
package SL::DB::Invoice; |
|
4 |
|
|
5 |
use strict; |
|
6 |
|
|
7 |
use base qw(SL::DB::Object); |
|
8 |
|
|
9 |
__PACKAGE__->meta->setup( |
|
10 |
table => 'ar', |
|
11 |
|
|
12 |
columns => [ |
|
13 |
id => { type => 'integer', not_null => 1, sequence => 'glid' }, |
|
14 |
invnumber => { type => 'text', not_null => 1 }, |
|
15 |
transdate => { type => 'date', default => 'now' }, |
|
16 |
gldate => { type => 'date', default => 'now' }, |
|
17 |
customer_id => { type => 'integer' }, |
|
18 |
taxincluded => { type => 'boolean' }, |
|
19 |
amount => { type => 'numeric', precision => 5, scale => 15 }, |
|
20 |
netamount => { type => 'numeric', precision => 5, scale => 15 }, |
|
21 |
paid => { type => 'numeric', precision => 5, scale => 15 }, |
|
22 |
datepaid => { type => 'date' }, |
Auch abrufbar als: Unified diff
RDBO Support.
Script, Models und Manager übernommen und angeglichen.
Ein SQL Schema Update, dass die meisten vorausgesetzten Normalisierungen
enthält mit eingefügt.