Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision ed9b1bfb

Von Jan Büren vor mehr als 6 Jahren hinzugefügt

  • ID ed9b1bfb7ca6acf18d907a7d34ddd3a82061b8cb
  • Vorgänger a158b731
  • Nachfolger 10d9b17f

Kontoauszug verbuchen -> Dialogbuchungsentwürfe verbessert

Nette Idee aus odyn (Start des Gedankens #f09c2b407faa7 Ende des Gedankens #765a3d421e7).
Zwei Sollbruchstellen in odyn, deshalb in kivi neu formuliert:

Sollbruchstellen:
a) Ein Aufruf von BankTransaction::action_list kann Zustände im Datenmodell verändern
b) Der Benutzer kann beliebige Zahlenwerte oder neue Konten in der Dialogbuchungsmaske eingeben

Konsequenz:
-> Zustände des Datenmodells in gl.pl post_transactions ändern, Werte per Rose hierzu aus der DB (und nicht aus $form)
Möglichst viel dem Benutzer auf die Flossen hauen, wenn die Buchungsmaske unlogisch benutzt wird

Unterschiede anzeigen:

SL/Controller/BankTransaction.pm
262 262

  
263 263
  $self->transaction(SL::DB::Manager::BankTransaction->find_by(id => $::form->{bt_id}));
264 264

  
265
  # This was dead code: We compared vendor.account_name with bank_transaction.iban.
266
  # This did never match (Kontonummer != IBAN). It's kivis 09/02 (2013) day
267
  # If refactored/improved, also consider that vendor.iban should be normalized
268
  # user may like to input strings like: 'AT 3333 3333 2222 1111' -> can be checked strictly
269
  # at Vendor code because we need the correct data for all sepa exports.
270

  
271 265
  my $vendor_of_transaction = SL::DB::Manager::Vendor->find_by(iban => $self->transaction->{remote_account_number});
272 266
  my $use_vendor_filter     = $self->transaction->{remote_account_number} && $vendor_of_transaction;
273 267

  
......
299 293
    TEMPLATES_GL => $use_vendor_filter && @{ $templates_ap } ? undef : $templates_gl,
300 294
    TEMPLATES_AP => $templates_ap,
301 295
    vendor_name  => $use_vendor_filter && @{ $templates_ap } ? $vendor_of_transaction->name : undef,
296
    BT_ID        => $::form->{bt_id},
302 297
  );
303 298
}
304 299

  
......
900 895
}
901 896

  
902 897
sub load_gl_record_template_url {
903
  my ($self, $template) = @_;
898
  my ($self, $template, $bt_id) = @_;
904 899

  
905 900
  return $self->url_for(
906 901
    controller                           => 'gl.pl',
......
909 904
    'form_defaults.amount_1'             => abs($self->transaction->amount), # always positive
910 905
    'form_defaults.transdate'            => $self->transaction->transdate_as_date,
911 906
    'form_defaults.callback'             => $self->callback,
907
    'form_defaults.bt_id'                => $self->transaction->id,
912 908
  );
913 909
}
914 910

  
bin/mozilla/gl.pl
1329 1329
  }
1330 1330
  # /saving the history
1331 1331

  
1332
  if ($form->{callback} =~ /BankTransaction/) {
1332
  # called from BankTransaction - Assign RecordLink and update BankTransaction
1333
  if ($form->{callback} =~ /BankTransaction/ && $form->{bt_id}) {
1334
    # set invoice_amount - we only rely on bt_id in form, do all other stuff ui independent
1335
    # die if we have a unlogic or NYI case and (TODO) chain this transaction safe (post_transaction + history_erp + this)
1336
    my ($bt, $chart_id, $payment);
1337

  
1338
    $bt = SL::DB::Manager::BankTransaction->find_by(id => $::form->{bt_id});
1339
    die "No bank transaction found" unless $bt;
1340

  
1341
    $chart_id = SL::DB::Manager::BankAccount->find_by(id => $bt->local_bank_account_id)->chart_id;
1342
    die "no chart id:" unless $chart_id;
1343

  
1344
    $payment = SL::DB::Manager::AccTransaction->get_all(where => [ trans_id => $::form->{id},
1345
                                                                   chart_link => { like => '%AR_paid%' },
1346
                                                                   chart_id => $chart_id                  ]);
1347
    die "guru meditation error: Can only assign amount to one bank account booking" if scalar @{ $payment } > 1;
1348

  
1349
    # credit/debit * -1 matches the sign for bt.amount and bt.invoice_amount
1350
    $bt->update_attributes(invoice_amount => $bt->invoice_amount + ($payment->[0]->amount * -1));
1351

  
1352
    # create record_link
1353
    my @props = (
1354
      from_table => 'bank_transactions',
1355
      from_id    => $::form->{bt_id},
1356
      to_table   => 'gl',
1357
      to_id      => $::form->{id},
1358
    );
1359
    SL::DB::RecordLink->new(@props)->save;
1360

  
1333 1361
    print $form->redirect_header($form->{callback});
1334 1362
    $form->redirect($locale->text('GL transaction posted.') . ' ' . $locale->text('ID') . ': ' . $form->{id});
1335 1363
  }
templates/webpages/bank_transactions/_template_list.html
42 42
  <tbody>
43 43
   [% FOREACH template = TEMPLATES_GL %]
44 44
    <tr class="listrow">
45
     <td>[% P.link_tag(SELF.load_gl_record_template_url(template), template.template_name) %]</td>
45
     <td>[% P.link_tag(SELF.load_gl_record_template_url(template, BT_ID), template.template_name) %]</td>
46 46
     <td>[% HTML.escape(template.reference) %]</td>
47 47
     <td>[% HTML.escape(template.employee.name || template.employee.login) %]</td>
48 48
     <td>[% HTML.escape(template.itime_as_date) %]</td>
templates/webpages/gl/form_footer.html
20 20

  
21 21
<hr size="3" noshade>
22 22
<input name=callback type=hidden value="[% callback %]">
23
<input name=bt_id    type=hidden value="[% bt_id %]">
23 24

  
24 25
[%- IF id && follow_ups.size %]
25 26
  <p>[% LxERP.t8('There are #1 unfinished follow-ups of which #2 are due.', follow_ups.size , follow_ups_due) %]</p>

Auch abrufbar als: Unified diff