Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 004ecc3f

Von G. Richardson vor fast 13 Jahren hinzugefügt

  • ID 004ecc3f815948d90e28f01dd06357bd3d87b6fd
  • Vorgänger 9a194d6a
  • Nachfolger dab2f724

Fix für Bug 1749, Zahlungseingang kaputt

Ging kaputt wenn Kundenfeld ein Drop-Down war, da hier customer und customer_id
immer gesetzt waren. Jetzt wird für Suche nach Rechnungsnummer erst customer
und customer_id gelöscht wenn eine Rechnungsnummer eingegeben wurde.

Unterschiede anzeigen:

bin/mozilla/cp.pl
240 240
      }
241 241
    }
242 242
  }
243
  # Falls Suche über Rechnungsnummer und kein Kundenname vorhanden
244
  if ($form->{invnumber} && !($form->{$form->{vc}})){
245
  $form->{open} ='Y'; # nur die offenen rechnungen
246
  if ($form->{ARAP} eq 'AR'){
247
    AR->ar_transactions(\%myconfig, \%$form);
248

  
249
    # if you search for invoice '11' ar_transactions will also match invoices
250
    # 112, 211, ... due to the LIKE
251

  
252
    # so there is now an extra loop that tries to match the invoice number
253
    # exactly among all returned results, and then passes the customer_id instead of the name
254
    # because the name may not be unique
255

  
256
    my $found_exact_invnumber_match = 0;
257
    foreach my $i ( @{ $form->{AR} } ) {
258
      next unless $i->{invnumber} eq $form->{invnumber};
259
      # found exactly matching invnumber
260
      $form->{$form->{vc}} = $i->{name};
261
      $form->{customer_id} = $i->{customer_id};
262
      $found_exact_invnumber_match = 1;
263
    };
264

  
265
    unless ( $found_exact_invnumber_match ) {
266
      # use first returned entry, may not be the correct one if invnumber doesn't match uniquely
267
      $form->{$form->{vc}} = $form->{AR}[0]{name};
268
      $form->{customer_id} = $form->{AR}[0]{customer_id};
269
    };
270
  } else {
271
    # s.o. nur für zahlungsausgang
272
    AP->ap_transactions(\%myconfig, \%$form);
273
    $form->{$form->{vc}} = $form->{AP}[0]{name};
243

  
244
  # search by invoicenumber, 
245
  if ($form->{invnumber}) { 
246
    $form->{open} ='Y'; # nur die offenen rechnungen
247
    if ($form->{ARAP} eq 'AR'){
248

  
249
      # ar_transactions automatically searches by $form->{customer_id} or else
250
      # $form->{customer} if available, and these variables will always be set
251
      # when we have a dropdown field rather than an input field, so we have to
252
      # empty these values first
253
      $form->{customer_id} = '';
254
      $form->{customer} = '';
255
      AR->ar_transactions(\%myconfig, \%$form);
256

  
257
      # if you search for invoice '11' ar_transactions will also match invoices
258
      # 112, 211, ... due to the LIKE
259

  
260
      # so there is now an extra loop that tries to match the invoice number
261
      # exactly among all returned results, and then passes the customer_id instead of the name
262
      # because the name may not be unique
263

  
264
      my $found_exact_invnumber_match = 0;
265
      foreach my $i ( @{ $form->{AR} } ) {
266
        next unless $i->{invnumber} eq $form->{invnumber};
267
        # found exactly matching invnumber
268
        $form->{$form->{vc}} = $i->{name};
269
        $form->{customer_id} = $i->{customer_id};
270
        #$form->{"old${form->{vc}"} = $i->{customer_id};
271
        $found_exact_invnumber_match = 1;
272
      };
273

  
274
      unless ( $found_exact_invnumber_match ) {
275
        # use first returned entry, may not be the correct one if invnumber doesn't
276
        # match uniquely
277
        $form->{$form->{vc}} = $form->{AR}[0]{name};
278
        $form->{customer_id} = $form->{AR}[0]{customer_id};
279
      };
280
    } else {
281
      # s.o. nur für zahlungsausgang
282
      AP->ap_transactions(\%myconfig, \%$form);
283
      $form->{$form->{vc}} = $form->{AP}[0]{name};
274 284
    }
275 285
  }
276
  # get customer and invoices
277
  $updated = &check_name($form->{vc}) unless $form->{customer_id};
278 286

  
279
  if ( $form->{customer_id} ) {
280
    # we already know the exact customer_id, fill $form with customer data
287
  # determine customer/vendor
288
  if ( $form->{customer_id} and $form->{invnumber} ) {
289
    # we already know the exact customer_id, so fill $form with customer data
281 290
    IS->get_customer(\%myconfig, \%$form);
282 291
    $updated = 1;
292
  } else {
293
    # check_name is called with "customer" or "vendor" and otherwise uses contents of $form
294
    # check_name also runs get_customer/get_vendor
295
    $updated = &check_name($form->{vc});
283 296
  };
284 297

  
285 298
  if ($new_name_selected || $updated) {
286
    # get open invoices from ar/ap using $form->{vc} and a.${vc}_id
299
    # get open invoices from ar/ap using $form->{vc} and a.${vc}_id, i.e. customer_id
287 300
    CP->get_openinvoices(\%myconfig, \%$form);
288 301
    ($newvc) = split /--/, $form->{ $form->{vc} };
289 302
    $form->{"old$form->{vc}"} = qq|$newvc--$form->{"$form->{vc}_id"}|;

Auch abrufbar als: Unified diff