1 package SL::Controller::LiquidityProjection;
5 use parent qw(SL::Controller::Base);
7 use SL::Locale::String;
8 use SL::LiquidityProjection;
9 use SL::Util qw(_hashify);
11 __PACKAGE__->run_before('check_auth');
13 use Rose::Object::MakeMethods::Generic (
14 scalar => [ qw(liquidity) ],
15 'scalar --get_set_init' => [ qw(oe_report_columns_str) ],
26 $self->liquidity(SL::LiquidityProjection->new(%{ $::form->{params} })->create) if $::form->{params};
28 $::form->{params} ||= {
35 $self->setup_show_action_bar;
36 $self->render('liquidity_projection/show', title => t8('Liquidity projection'));
43 sub check_auth { $::auth->assert('report') }
44 sub init_oe_report_columns_str { join '&', map { "$_=Y" } qw(open delivered notdelivered l_ordnumber l_transdate l_reqdate l_name l_employee l_salesman l_netamount l_amount l_transaction_description) }
50 sub link_to_old_orders {
52 my %params = _hashify(0, @_);
54 my $reqdate = $params{reqdate};
55 my $months = $params{months} * 1;
59 if ($reqdate eq 'old') {
60 $fields .= '&reqdate_unset_or_old=Y';
62 } elsif ($reqdate eq 'future') {
64 $fields .= '&reqdatefrom=' . $self->iso_to_display(SL::LiquidityProjection::_the_date($now[5] + 1900, $now[4] + 1 + $months) . '-01');
67 $reqdate =~ m/(\d+)-(\d+)/;
68 $fields .= '&reqdatefrom=' . $self->iso_to_display($reqdate . '-01');
69 $fields .= '&reqdateto=' . $self->iso_to_display($reqdate . sprintf('-%02d', DateTime->last_day_of_month(year => $1, month => $2)->day));
73 return "oe.pl?action=orders&type=sales_order&vc=customer&" . $self->oe_report_columns_str . $fields;
77 my ($self, $date) = @_;
79 $::locale->reformat_date({ dateformat => 'yyyy-mm-dd' }, $date, $::myconfig{dateformat});
82 sub setup_show_action_bar {
83 my ($self, %params) = @_;
85 for my $bar ($::request->layout->get('actionbar')) {
89 submit => [ '#filter_form', { action => 'LiquidityProjection/show' } ],