Revision 614c48e0
Von Moritz Bunkus vor fast 6 Jahren hinzugefügt
bin/mozilla/ar.pl | ||
---|---|---|
89 | 89 |
# $locale->text('Nov') |
90 | 90 |
# $locale->text('Dec') |
91 | 91 |
|
92 |
sub _may_view_or_edit_this_invoice { |
|
93 |
return 1 if $::auth->assert('ar_transactions', 1); # may edit all invoices |
|
94 |
return 0 if !$::form->{id}; # creating new invoices isn't allowed without invoice_edit |
|
95 |
return 0 if !$::form->{globalproject_id}; # existing records without a project ID are not allowed |
|
96 |
return SL::DB::Project->new(id => $::form->{globalproject_id})->load->may_employee_view_project_invoices(SL::DB::Manager::Employee->current); |
|
97 |
} |
|
98 |
|
|
99 |
sub _assert_access { |
|
100 |
my $cache = $::request->cache('ar.pl::_assert_access'); |
|
101 |
|
|
102 |
$cache->{_may_view_or_edit_this_invoice} = _may_view_or_edit_this_invoice() if !exists $cache->{_may_view_or_edit_this_invoice}; |
|
103 |
$::form->show_generic_error($::locale->text("You do not have the permissions to access this function.")) if ! $cache->{_may_view_or_edit_this_invoice}; |
|
104 |
} |
|
105 |
|
|
92 | 106 |
sub load_record_template { |
93 | 107 |
$::auth->assert('ar_transactions'); |
94 | 108 |
|
... | ... | |
249 | 263 |
sub edit { |
250 | 264 |
$main::lxdebug->enter_sub(); |
251 | 265 |
|
252 |
$main::auth->assert('ar_transactions'); |
|
266 |
# Delay access check to after the invoice's been loaded in |
|
267 |
# "create_links" so that project-specific invoice rights can be |
|
268 |
# evaluated. |
|
253 | 269 |
|
254 | 270 |
my $form = $main::form; |
255 | 271 |
|
... | ... | |
268 | 284 |
sub display_form { |
269 | 285 |
$main::lxdebug->enter_sub(); |
270 | 286 |
|
271 |
$main::auth->assert('ar_transactions');
|
|
287 |
_assert_access();
|
|
272 | 288 |
|
273 | 289 |
my $form = $main::form; |
274 | 290 |
|
... | ... | |
287 | 303 |
sub create_links { |
288 | 304 |
$main::lxdebug->enter_sub(); |
289 | 305 |
|
290 |
$main::auth->assert('ar_transactions'); |
|
306 |
# Delay access check to after the invoice's been loaded so that |
|
307 |
# project-specific invoice rights can be evaluated. |
|
291 | 308 |
|
292 | 309 |
my %params = @_; |
293 | 310 |
my $form = $main::form; |
... | ... | |
296 | 313 |
$form->create_links("AR", \%myconfig, "customer"); |
297 | 314 |
$form->{invoice_obj} = _retrieve_invoice_object(); |
298 | 315 |
|
316 |
_assert_access(); |
|
317 |
|
|
299 | 318 |
my %saved; |
300 | 319 |
if (!$params{dont_save}) { |
301 | 320 |
%saved = map { ($_ => $form->{$_}) } qw(direct_debit id taxincluded); |
... | ... | |
329 | 348 |
sub form_header { |
330 | 349 |
$main::lxdebug->enter_sub(); |
331 | 350 |
|
332 |
$main::auth->assert('ar_transactions');
|
|
351 |
_assert_access();
|
|
333 | 352 |
|
334 | 353 |
my $form = $main::form; |
335 | 354 |
my %myconfig = %main::myconfig; |
... | ... | |
528 | 547 |
sub form_footer { |
529 | 548 |
$main::lxdebug->enter_sub(); |
530 | 549 |
|
531 |
$main::auth->assert('ar_transactions');
|
|
550 |
_assert_access();
|
|
532 | 551 |
|
533 | 552 |
my $form = $main::form; |
534 | 553 |
my %myconfig = %main::myconfig; |
... | ... | |
885 | 904 |
} |
886 | 905 |
|
887 | 906 |
sub setup_ar_transactions_action_bar { |
888 |
my %params = @_; |
|
907 |
my %params = @_; |
|
908 |
my $may_edit_create = $::auth->assert('invoice_edit', 1); |
|
889 | 909 |
|
890 | 910 |
for my $bar ($::request->layout->get('actionbar')) { |
891 | 911 |
$bar->add( |
892 | 912 |
action => [ |
893 | 913 |
$::locale->text('Print'), |
894 | 914 |
call => [ 'kivi.MassInvoiceCreatePrint.showMassPrintOptionsOrDownloadDirectly' ], |
895 |
disabled => !$params{num_rows} ? $::locale->text('The report doesn\'t contain entries.') : undef, |
|
915 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') |
|
916 |
: !$params{num_rows} ? $::locale->text('The report doesn\'t contain entries.') |
|
917 |
: undef, |
|
896 | 918 |
], |
897 | 919 |
|
898 | 920 |
combobox => [ |
899 | 921 |
action => [ $::locale->text('Create new') ], |
900 | 922 |
action => [ |
901 | 923 |
$::locale->text('AR Transaction'), |
902 |
submit => [ '#create_new_form', { action => 'ar_transaction' } ], |
|
924 |
submit => [ '#create_new_form', { action => 'ar_transaction' } ], |
|
925 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef, |
|
903 | 926 |
], |
904 | 927 |
action => [ |
905 | 928 |
$::locale->text('Sales Invoice'), |
906 |
submit => [ '#create_new_form', { action => 'sales_invoice' } ], |
|
929 |
submit => [ '#create_new_form', { action => 'sales_invoice' } ], |
|
930 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef, |
|
907 | 931 |
], |
908 | 932 |
], # end of combobox "Create new" |
909 | 933 |
); |
... | ... | |
913 | 937 |
sub search { |
914 | 938 |
$main::lxdebug->enter_sub(); |
915 | 939 |
|
916 |
$main::auth->assert('invoice_edit'); |
|
917 |
|
|
918 | 940 |
my $form = $main::form; |
919 | 941 |
my %myconfig = %main::myconfig; |
920 | 942 |
my $locale = $main::locale; |
... | ... | |
969 | 991 |
sub ar_transactions { |
970 | 992 |
$main::lxdebug->enter_sub(); |
971 | 993 |
|
972 |
$main::auth->assert('invoice_edit'); |
|
973 |
|
|
974 | 994 |
my $form = $main::form; |
975 | 995 |
my %myconfig = %main::myconfig; |
976 | 996 |
my $locale = $main::locale; |
... | ... | |
1254 | 1274 |
|
1255 | 1275 |
my $is_storno = IS->is_storno(\%::myconfig, $::form, 'ar', $::form->{id}); |
1256 | 1276 |
my $has_storno = IS->has_storno(\%::myconfig, $::form, 'ar'); |
1277 |
my $may_edit_create = $::auth->assert('ar_transactions', 1); |
|
1257 | 1278 |
|
1258 | 1279 |
for my $bar ($::request->layout->get('actionbar')) { |
1259 | 1280 |
$bar->add( |
... | ... | |
1262 | 1283 |
submit => [ '#form', { action => "update" } ], |
1263 | 1284 |
id => 'update_button', |
1264 | 1285 |
checks => [ 'kivi.validate_form' ], |
1286 |
disabled => !$may_edit_create ? t8('You must not change this AR transaction.') : undef, |
|
1265 | 1287 |
accesskey => 'enter', |
1266 | 1288 |
], |
1267 | 1289 |
|
... | ... | |
1270 | 1292 |
t8('Post'), |
1271 | 1293 |
submit => [ '#form', { action => "post" } ], |
1272 | 1294 |
checks => [ 'kivi.validate_form', 'kivi.AR.check_fields_before_posting' ], |
1273 |
disabled => $is_closed ? t8('The billing period has already been locked.') |
|
1295 |
disabled => !$may_edit_create ? t8('You must not change this AR transaction.') |
|
1296 |
: $is_closed ? t8('The billing period has already been locked.') |
|
1274 | 1297 |
: $is_storno ? t8('A canceled invoice cannot be posted.') |
1275 | 1298 |
: ($::form->{id} && $change_never) ? t8('Changing invoices has been disabled in the configuration.') |
1276 | 1299 |
: ($::form->{id} && $change_on_same_day_only) ? t8('Invoices can only be changed on the day they are posted.') |
... | ... | |
1279 | 1302 |
action => [ |
1280 | 1303 |
t8('Post Payment'), |
1281 | 1304 |
submit => [ '#form', { action => "post_payment" } ], |
1282 |
disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') : undef, |
|
1305 |
disabled => !$may_edit_create ? t8('You must not change this AR transaction.') |
|
1306 |
: !$::form->{id} ? t8('This invoice has not been posted yet.') |
|
1307 |
: undef, |
|
1283 | 1308 |
], |
1284 | 1309 |
action => [ t8('Mark as paid'), |
1285 | 1310 |
submit => [ '#form', { action => "mark_as_paid" } ], |
1286 | 1311 |
confirm => t8('This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?'), |
1287 |
disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') : undef, |
|
1312 |
disabled => !$may_edit_create ? t8('You must not change this AR transaction.') |
|
1313 |
: !$::form->{id} ? t8('This invoice has not been posted yet.') |
|
1314 |
: undef, |
|
1288 | 1315 |
only_if => $::instance_conf->get_is_show_mark_as_paid, |
1289 | 1316 |
], |
1290 | 1317 |
], # end of combobox "Post" |
... | ... | |
1294 | 1321 |
submit => [ '#form', { action => "storno" } ], |
1295 | 1322 |
checks => [ 'kivi.validate_form', 'kivi.AR.check_fields_before_posting' ], |
1296 | 1323 |
confirm => t8('Do you really want to cancel this invoice?'), |
1297 |
disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') |
|
1298 |
: $has_storno ? t8('This invoice has been canceled already.') |
|
1299 |
: $is_storno ? t8('Reversal invoices cannot be canceled.') |
|
1300 |
: $::form->{totalpaid} ? t8('Invoices with payments cannot be canceled.') |
|
1301 |
: undef, |
|
1324 |
disabled => !$may_edit_create ? t8('You must not change this AR transaction.') |
|
1325 |
: !$::form->{id} ? t8('This invoice has not been posted yet.') |
|
1326 |
: $has_storno ? t8('This invoice has been canceled already.') |
|
1327 |
: $is_storno ? t8('Reversal invoices cannot be canceled.') |
|
1328 |
: $::form->{totalpaid} ? t8('Invoices with payments cannot be canceled.') |
|
1329 |
: undef, |
|
1302 | 1330 |
], |
1303 | 1331 |
action => [ t8('Delete'), |
1304 | 1332 |
submit => [ '#form', { action => "delete" } ], |
1305 | 1333 |
confirm => t8('Do you really want to delete this object?'), |
1306 |
disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') |
|
1334 |
disabled => !$may_edit_create ? t8('You must not change this AR transaction.') |
|
1335 |
: !$::form->{id} ? t8('This invoice has not been posted yet.') |
|
1307 | 1336 |
: $change_never ? t8('Changing invoices has been disabled in the configuration.') |
1308 | 1337 |
: $change_on_same_day_only ? t8('Invoices can only be changed on the day they are posted.') |
1309 | 1338 |
: $is_closed ? t8('The billing period has already been locked.') |
... | ... | |
1319 | 1348 |
t8('Use As New'), |
1320 | 1349 |
submit => [ '#form', { action => "use_as_new" } ], |
1321 | 1350 |
checks => [ 'kivi.validate_form' ], |
1322 |
disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') : undef, |
|
1351 |
disabled => !$may_edit_create ? t8('You must not change this AR transaction.') |
|
1352 |
: !$::form->{id} ? t8('This invoice has not been posted yet.') |
|
1353 |
: undef, |
|
1323 | 1354 |
], |
1324 | 1355 |
], # end of combobox "Workflow" |
1325 | 1356 |
|
... | ... | |
1337 | 1368 |
], |
1338 | 1369 |
action => [ |
1339 | 1370 |
t8('Record templates'), |
1340 |
call => [ 'kivi.RecordTemplate.popup', 'ar_transaction' ], |
|
1371 |
call => [ 'kivi.RecordTemplate.popup', 'ar_transaction' ], |
|
1372 |
disabled => !$may_edit_create ? t8('You must not change this AR transaction.') : undef, |
|
1341 | 1373 |
], |
1342 | 1374 |
action => [ |
1343 | 1375 |
t8('Drafts'), |
1344 | 1376 |
call => [ 'kivi.Draft.popup', 'ar', 'invoice', $::form->{draft_id}, $::form->{draft_description} ], |
1345 |
disabled => $::form->{id} ? t8('This invoice has already been posted.') |
|
1346 |
: $is_closed ? t8('The billing period has already been locked.') |
|
1347 |
: undef, |
|
1377 |
disabled => !$may_edit_create ? t8('You must not change this AR transaction.') |
|
1378 |
: $::form->{id} ? t8('This invoice has already been posted.') |
|
1379 |
: $is_closed ? t8('The billing period has already been locked.') |
|
1380 |
: undef, |
|
1348 | 1381 |
], |
1349 | 1382 |
], # end of combobox "more" |
1350 | 1383 |
); |
Auch abrufbar als: Unified diff
Berechtigung, Verkaufsrechnungen persönlich zugeordneter Projekte einzusehen
Man kann nun Mitarbeiter*innen zu Projekten zuordnen, indem man sie in
den Projektstammdaten hinzufügt.
Ist eine Mitarbeiter*in zu einem Projekt zugeordnet, so darf sie alle
Rechnungen ansehen, die über die Projektnummer der Rechnung (nicht der
Positionen) dem Projekt zugeordnet sind, auch dann, wenn sie nicht das
allgemeine Recht zum Erstellen und Ansehen von Rechnungen hat.
Verändern oder Ausdrucken der Rechnungen ist nicht gestattet.
Die Verwaltung dieser Projektberechtigungen ist über ein neues
Gruppenrecht eingeschränkt.
Betrifft Verkaufsrechnungen, Verkaufsgutschriften und Debitorenbuchungen.