Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 14dca9b8

Von Bernd Bleßmann vor mehr als 9 Jahren hinzugefügt

  • ID 14dca9b876d3cf70ba04c163ce595efa15c6b85d
  • Vorgänger 33298084
  • Nachfolger f63af42d

Kosmetik: Einrückung korrigiert.

Unterschiede anzeigen:

bin/mozilla/io.pl
579 579

  
580 580
    delete $form->{item_list};
581 581

  
582
  if ($mode eq 'IS') {
583
    IS->retrieve_item(\%myconfig, \%$form);
584
  } elsif ($mode eq 'IR') {
585
    IR->retrieve_item(\%myconfig, \%$form);
586
  } elsif ($mode eq 'IC') {
587
    IC->assembly_item(\%myconfig, \%$form);
588
  } else {
589
    croak "Invalid item selection mode '${mode}'";
590
  }
582
    if ($mode eq 'IS') {
583
      IS->retrieve_item(\%myconfig, \%$form);
584
    } elsif ($mode eq 'IR') {
585
      IR->retrieve_item(\%myconfig, \%$form);
586
    } elsif ($mode eq 'IC') {
587
      IC->assembly_item(\%myconfig, \%$form);
588
    } else {
589
      croak "Invalid item selection mode '${mode}'";
590
    }
591 591

  
592
  my $new_item = $form->{item_list}->[0] || croak "No item found for mode '${mode}' and ID '${id}'";
592
    my $new_item = $form->{item_list}->[0] || croak "No item found for mode '${mode}' and ID '${id}'";
593 593

  
594
  # if there was a price entered, override it
595
  my $sellprice;
596
  unless ( $mode eq 'IC' ) {
597
    $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
598
  };
594
    # if there was a price entered, override it
595
    my $sellprice;
596
    unless ( $mode eq 'IC' ) {
597
      $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
598
    };
599 599

  
600
  my @new_fields =
601
    qw(id partnumber description sellprice listprice inventory_accno
602
       income_accno expense_accno bin unit weight assembly taxaccounts
603
       partsgroup formel longdescription not_discountable partnotes lastcost
604
       price_factor_id price_factor);
600
    my @new_fields =
601
        qw(id partnumber description sellprice listprice inventory_accno
602
           income_accno expense_accno bin unit weight assembly taxaccounts
603
           partsgroup formel longdescription not_discountable partnotes lastcost
604
           price_factor_id price_factor);
605 605

  
606
  my $ic_cvar_configs = CVar->get_configs(module => 'IC');
607
  push @new_fields, map { "ic_cvar_$_->{name}" } @{ $ic_cvar_configs };
606
    my $ic_cvar_configs = CVar->get_configs(module => 'IC');
607
    push @new_fields, map { "ic_cvar_$_->{name}" } @{ $ic_cvar_configs };
608 608

  
609
  map { $form->{"${_}_$i"} = $new_item->{$_} } @new_fields;
609
    map { $form->{"${_}_$i"} = $new_item->{$_} } @new_fields;
610 610

  
611
  if (my $record = _make_record()) {
612
    my $price_source = SL::PriceSource->new(record_item => $record->items->[$i-1], record => $record);
613
    my $best_price   = $price_source->best_price;
611
    if (my $record = _make_record()) {
612
      my $price_source = SL::PriceSource->new(record_item => $record->items->[$i-1], record => $record);
613
      my $best_price   = $price_source->best_price;
614 614

  
615
    if ($best_price) {
616
      $::form->{"sellprice_$i"}           = $best_price->price;
617
      $::form->{"active_price_source_$i"} = $best_price->source;
618
    }
615
      if ($best_price) {
616
        $::form->{"sellprice_$i"}           = $best_price->price;
617
        $::form->{"active_price_source_$i"} = $best_price->source;
618
      }
619 619

  
620
    my $best_discount = $price_source->best_discount;
620
      my $best_discount = $price_source->best_discount;
621 621

  
622
    if ($best_discount) {
623
      $::form->{"discount_$i"}               = $best_discount->discount;
624
      $::form->{"active_discount_source_$i"} = $best_discount->source;
622
      if ($best_discount) {
623
        $::form->{"discount_$i"}               = $best_discount->discount;
624
        $::form->{"active_discount_source_$i"} = $best_discount->source;
625
      }
625 626
    }
626
  }
627 627

  
628
  $form->{"marge_price_factor_$i"} = $new_item->{price_factor};
628
    $form->{"marge_price_factor_$i"} = $new_item->{price_factor};
629 629

  
630
  if ($form->{"part_payment_id_$i"} ne "") {
631
    $form->{payment_id} = $form->{"part_payment_id_$i"};
632
  }
630
    if ($form->{"part_payment_id_$i"} ne "") {
631
      $form->{payment_id} = $form->{"part_payment_id_$i"};
632
    }
633 633

  
634
  my ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
635
  $dec           = length $dec;
636
  my $decimalplaces = ($dec > 2) ? $dec : 2;
634
    my ($dec)         = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
635
    $dec              = length $dec;
636
    my $decimalplaces = ($dec > 2) ? $dec : 2;
637 637

  
638
  if ($sellprice) {
639
    $form->{"sellprice_$i"} = $sellprice;
640
  } else {
638
    if ($sellprice) {
639
      $form->{"sellprice_$i"} = $sellprice;
640
    } else {
641 641

  
642
    # if there is an exchange rate adjust sellprice
643
    if (($form->{exchangerate} * 1) != 0) {
644
      $form->{"sellprice_$i"} /= $form->{exchangerate};
645
      $form->{"sellprice_$i"} =
646
        $form->round_amount($form->{"sellprice_$i"}, $decimalplaces);
642
      # if there is an exchange rate adjust sellprice
643
      if (($form->{exchangerate} * 1) != 0) {
644
        $form->{"sellprice_$i"} /= $form->{exchangerate};
645
        $form->{"sellprice_$i"} =
646
            $form->round_amount($form->{"sellprice_$i"}, $decimalplaces);
647
      }
647 648
    }
648
  }
649 649

  
650
  # at this stage qty of newly added part needs to be have been parsed
651
  $form->{weight}    += ($form->{"weight_$i"} * $form->{"qty_$i"});
650
    # at this stage qty of newly added part needs to be have been parsed
651
    $form->{weight}    += ($form->{"weight_$i"} * $form->{"qty_$i"});
652 652

  
653
  if ($form->{"not_discountable_$i"}) {
654
    $form->{"discount_$i"} = 0;
655
  }
653
    if ($form->{"not_discountable_$i"}) {
654
      $form->{"discount_$i"} = 0;
655
    }
656 656

  
657
  my $amount =
658
    $form->{"sellprice_$i"} * (1 - $form->{"discount_$i"}) *
659
    $form->{"qty_$i"};
660
  map { $form->{"${_}_base"} += $amount }
661
    (split / /, $form->{"taxaccounts_$i"});
662
  map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /,
663
    $form->{"taxaccounts_$i"}
664
    if !$form->{taxincluded};
657
    my $amount =
658
        $form->{"sellprice_$i"} * (1 - $form->{"discount_$i"}) * $form->{"qty_$i"};
659
    map { $form->{"${_}_base"} += $amount }                         (split / /, $form->{"taxaccounts_$i"});
660
    map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /, $form->{"taxaccounts_$i"} if !$form->{taxincluded};
665 661

  
666
  $form->{creditremaining} -= $amount;
662
    $form->{creditremaining} -= $amount;
667 663

  
668
  $form->{"runningnumber_$i"} = $i;
664
    $form->{"runningnumber_$i"} = $i;
669 665

  
670
  # format amounts
671
  map {
672
    $form->{"${_}_$i"} =
673
      $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces)
674
  } qw(sellprice listprice lastcost qty) if $form->{item} ne 'assembly';
675
  $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100.0) if $form->{item} ne 'assembly';
666
    # format amounts
667
    map {
668
      $form->{"${_}_$i"} =
669
          $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces)
670
    } qw(sellprice listprice lastcost qty) if $form->{item} ne 'assembly';
671
    $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100.0) if $form->{item} ne 'assembly';
676 672

  
677
  delete $form->{nextsub};
673
    delete $form->{nextsub};
678 674

  
679 675
  }
680 676

  

Auch abrufbar als: Unified diff