Skip to content

Commit

Permalink
Workflow: E-Mail → Kreditorenbuchung hinzugefügt
Browse files Browse the repository at this point in the history
  • Loading branch information
z4m1n0 committed Oct 13, 2023
1 parent 6126830 commit 54b9328
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 2 deletions.
12 changes: 12 additions & 0 deletions SL/AP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ use SL::DB::Default;
use SL::DB::Draft;
use SL::DB::Order;
use SL::DB::PurchaseInvoice;
use SL::DB::EmailJournal;
use SL::DB::ValidityToken;
use SL::Util qw(trim);
use SL::DB;
Expand Down Expand Up @@ -1098,6 +1099,17 @@ sub _storno {

map { IO->set_datepaid(table => 'ap', id => $_, dbh => $dbh) } ($id, $new_id);

if ($form->{workflow_email_journal_id}) {
my $ap_transaction_storno = SL::DB::PurchaseInvoice->new(id => $new_id)->load;
my $email_journal = SL::DB::EmailJournal->new(
id => delete $form->{workflow_email_journal_id}
)->load;
$email_journal->link_to_record_with_attachment(
$ap_transaction_storno,
delete $::form->{email_attachment_id}
);
}

return 1;
}

Expand Down
28 changes: 28 additions & 0 deletions bin/mozilla/ap.pl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
use SL::DB::PurchaseInvoice;
use SL::DB::RecordTemplate;
use SL::DB::Tax;
use SL::DB::EmailJournal;
use SL::DB::ValidityToken;
use SL::Presenter::ItemsList;
use SL::Webdav;
Expand Down Expand Up @@ -257,8 +258,10 @@ sub add {

AP->get_transdate(\%myconfig, $form);
$form->{initial_transdate} = $form->{transdate};
$form->{initial_vendor_id} = $form->{vendor_id};
create_links(dont_save => 1);
$form->{transdate} = $form->{initial_transdate};
$form->{vendor_id} = $form->{initial_vendor_id} if $form->{initial_vendor_id};

if ($form->{vendor_id}) {
my $vendor = SL::DB::Vendor->load_cached($form->{vendor_id});
Expand Down Expand Up @@ -961,6 +964,14 @@ sub post {
}
}

if ($form->{email_journal_id}) {
my $ap_transaction = SL::DB::PurchaseInvoice->new(id => $form->{id})->load;
my $email_journal = SL::DB::EmailJournal->new(
id => delete $form->{email_journal_id}
)->load;
$email_journal->link_to_record_with_attachment($ap_transaction, delete $::form->{email_attachment_id});
}

if (!$inline) {
my $msg = $locale->text("AP transaction '#1' posted (ID: #2)", $form->{invnumber}, $form->{id});
if ($form->{callback} =~ /BankTransaction/) {
Expand Down Expand Up @@ -1008,6 +1019,9 @@ sub use_as_new {

$main::auth->assert('ap_transactions');

$form->{email_journal_id} = delete $form->{workflow_email_journal_id};
$form->{email_attachment_id} = delete $form->{workflow_email_attachment_id};

map { delete $form->{$_} } qw(printed emailed queued invnumber deliverydate id datepaid_1 gldate_1 acc_trans_id_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno convert_from_oe_id);
$form->{paidaccounts} = 1;
$form->{rowcount}--;
Expand Down Expand Up @@ -1396,6 +1410,20 @@ sub add_from_purchase_order {
);
}

sub add_from_email_journal {
die "No 'email_journal_id' was given." unless ($::form->{email_journal_id});
&add;
}

sub edit_with_email_journal_workflow {
my ($self) = @_;
die "No 'email_journal_id' was given." unless ($::form->{email_journal_id});
$::form->{workflow_email_journal_id} = delete $::form->{email_journal_id};
$::form->{workflow_email_attachment_id} = delete $::form->{email_attachment_id};

&edit;
}

sub setup_ap_search_action_bar {
my %params = @_;

Expand Down
30 changes: 29 additions & 1 deletion templates/design40_webpages/ap/form_header.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
[% USE T8 %]
[% USE LxERP %]

<h1>[% title | html %]</h1>
<h1>
[% IF workflow_email_journal_id; LxERP.t8("Email Journal Workflow") _ " - "; END; %]
[% title %]
</h1>

[% INCLUDE 'common/flash.html' %]

Expand Down Expand Up @@ -39,6 +42,10 @@ <h1>[% title | html %]</h1>
[% IF !id %]
[% L.hidden_tag('form_validity_token', form_validity_token) %]
[% END %]
[% L.hidden_tag('email_journal_id', email_journal_id) %]
[% L.hidden_tag('email_attachment_id', email_attachment_id) %]
[% L.hidden_tag('workflow_email_journal_id', workflow_email_journal_id) %]
[% L.hidden_tag('workflow_email_attachment_id', workflow_email_attachment_id) %]

[% FOREACH i IN [1..paidaccounts] %]
[% temp = "acc_trans_id_"_ i %]
Expand All @@ -56,6 +63,9 @@ <h1>[% title | html %]</h1>

<ul>
<li><a href="#ui-tabs-basic-data">[% 'Basic Data' | $T8 %]</a></li>
[% IF email_attachment_id || workflow_email_attachment_id %]
<li><a href="controller.pl?action=EmailJournal/attachment_preview&attachment_id=[% HTML.url(email_attachment_id || workflow_email_attachment_id) %]">[% 'Email Attachment Preview' | $T8 %]</a></li>
[% END %]
[% IF INSTANCE_CONF.get_webdav %]
<li><a href="#ui-tabs-webdav">[% 'WebDAV' | $T8 %]</a></li>
[% END %]
Expand All @@ -77,6 +87,24 @@ <h1>[% title | html %]</h1>

<div id="ui-tabs-basic-data">

[% IF email_attachment_id || workflow_email_attachment_id%]
<div class="wrapper" id="email_attachment_wrapper">
[%
BLOCK panel_1;
P.email_journal.attachment_preview(
email_attachment_id || workflow_email_attachment_id,
style="height:600px"
);
END;
INCLUDE 'common/toggle_panel.html'
block_name='panel_1'
button_closed = LxERP.t8('Show Attachment')
button_open = LxERP.t8('Hide Attachment')
;
%]
</div>
[% END %]

<div class="wrapper">

<table class="tbl-horizontal">
Expand Down
12 changes: 11 additions & 1 deletion templates/webpages/ap/form_header.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
[%- USE T8 %]
[%- USE LxERP %][%- USE P -%]

<h1>[% title | html %]</h1>
<h1>
[% IF workflow_email_journal_id; LxERP.t8("Email Journal Workflow") _ " - "; END; %]
[% title %]
</h1>

[%- INCLUDE 'common/flash.html' %]

Expand Down Expand Up @@ -48,6 +51,10 @@ <h1>[% title | html %]</h1>
[% IF !id %]
[% L.hidden_tag('form_validity_token', form_validity_token) %]
[% END %]
[% L.hidden_tag('email_journal_id', email_journal_id) %]
[% L.hidden_tag('email_attachment_id', email_attachment_id) %]
[% L.hidden_tag('workflow_email_journal_id', workflow_email_journal_id) %]
[% L.hidden_tag('workflow_email_attachment_id', workflow_email_attachment_id) %]

[% FOREACH i IN [1..paidaccounts] %]
[% temp = "acc_trans_id_"_ i %]
Expand All @@ -64,6 +71,9 @@ <h1>[% title | html %]</h1>
<div id="ap_tabs" class="tabwidget">
<ul>
<li><a href="#ui-tabs-basic-data">[% 'Basic Data' | $T8 %]</a></li>
[% IF email_attachment_id || workflow_email_attachment_id %]
<li><a href="controller.pl?action=EmailJournal/attachment_preview&attachment_id=[% HTML.url(email_attachment_id || workflow_email_attachment_id) %]">[% 'Email Attachment Preview' | $T8 %]</a></li>
[% END %]
[%- IF INSTANCE_CONF.get_webdav %]
<li><a href="#ui-tabs-webdav">[% 'WebDAV' | $T8 %]</a></li>
[%- END %]
Expand Down

0 comments on commit 54b9328

Please sign in to comment.