|
#=====================================================================
|
|
# LX-Office ERP
|
|
# Copyright (C) 2004
|
|
# Based on SQL-Ledger Version 2.1.9
|
|
# Web http://www.lx-office.org
|
|
#
|
|
#=====================================================================
|
|
# SQL-Ledger Accounting
|
|
# Copyright (c) 2001
|
|
#
|
|
# Author: Dieter Simader
|
|
# Email: dsimader@sql-ledger.org
|
|
# Web: http://www.sql-ledger.org
|
|
#
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, write to the Free Software
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
# MA 02110-1335, USA.
|
|
#======================================================================
|
|
#
|
|
# Accounts Payables
|
|
#
|
|
#======================================================================
|
|
|
|
use POSIX qw(strftime);
|
|
use List::Util qw(first max sum);
|
|
use List::UtilsBy qw(sort_by);
|
|
|
|
use SL::AP;
|
|
use SL::FU;
|
|
use SL::GL;
|
|
use SL::Helper::Flash qw(flash flash_later);
|
|
use SL::IR;
|
|
use SL::IS;
|
|
use SL::ReportGenerator;
|
|
use SL::DB::BankTransactionAccTrans;
|
|
use SL::DB::Chart;
|
|
use SL::DB::Currency;
|
|
use SL::DB::Default;
|
|
use SL::DB::InvoiceItem;
|
|
use SL::DB::Order;
|
|
use SL::DB::PaymentTerm;
|
|
use SL::DB::PurchaseInvoice;
|
|
use SL::DB::RecordTemplate;
|
|
use SL::DB::Tax;
|
|
use SL::Presenter::ItemsList;
|
|
use SL::Webdav;
|
|
use SL::Locale::String qw(t8);
|
|
|
|
require "bin/mozilla/common.pl";
|
|
require "bin/mozilla/reportgenerator.pl";
|
|
|
|
use strict;
|
|
|
|
1;
|
|
|
|
# end of main
|
|
|
|
# this is for our long dates
|
|
# $locale->text('January')
|
|
# $locale->text('February')
|
|
# $locale->text('March')
|
|
# $locale->text('April')
|
|
# $locale->text('May ')
|
|
# $locale->text('June')
|
|
# $locale->text('July')
|
|
# $locale->text('August')
|
|
# $locale->text('September')
|
|
# $locale->text('October')
|
|
# $locale->text('November')
|
|
# $locale->text('December')
|
|
|
|
# this is for our short month
|
|
# $locale->text('Jan')
|
|
# $locale->text('Feb')
|
|
# $locale->text('Mar')
|
|
# $locale->text('Apr')
|
|
# $locale->text('May')
|
|
# $locale->text('Jun')
|
|
# $locale->text('Jul')
|
|
# $locale->text('Aug')
|
|
# $locale->text('Sep')
|
|
# $locale->text('Oct')
|
|
# $locale->text('Nov')
|
|
# $locale->text('Dec')
|
|
|
|
sub _may_view_or_edit_this_invoice {
|
|
return 1 if $::auth->assert('ap_transactions', 1); # may edit all invoices
|
|
return 0 if !$::form->{id}; # creating new invoices isn't allowed without invoice_edit
|
|
return 0 if !$::form->{globalproject_id}; # existing records without a project ID are not allowed
|
|
return SL::DB::Project->new(id => $::form->{globalproject_id})->load->may_employee_view_project_invoices(SL::DB::Manager::Employee->current);
|
|
}
|
|
|
|
sub _assert_access {
|
|
my $cache = $::request->cache('ap.pl::_assert_access');
|
|
|
|
$cache->{_may_view_or_edit_this_invoice} = _may_view_or_edit_this_invoice() if !exists $cache->{_may_view_or_edit_this_invoice};
|
|
$::form->show_generic_error($::locale->text("You do not have the permissions to access this function.")) if ! $cache->{_may_view_or_edit_this_invoice};
|
|
}
|
|
|
|
sub load_record_template {
|
|
$::auth->assert('ap |