Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision aec14b51

Von Jan Büren vor etwa 2 Jahren hinzugefügt

  • ID aec14b51e185bbf0c52368d60384ac2dd0753b26
  • Vorgänger 566fcc06
  • Nachfolger 341d9fbb

ARAP _post_transaction Anlegen der id am Anfang wie bei den Rechnungsmasken

Nicht ganz sauber getrennt, ein bisschen Refactor ist im Vor-Commit

Unterschiede anzeigen:

SL/AP.pm
72 72
  $form->{defaultcurrency} = $form->get_default_currency($myconfig);
73 73
  $form->{taxincluded} = 0 unless $form->{taxincluded};
74 74

  
75
  # make sure to have a id
76
  my ($query, $sth, @values);
77
  if (!$payments_only) {
78
    # if we have an id delete old records
79
    if ($form->{id}) {
80

  
81
      # delete detail records
82
      $query = qq|DELETE FROM acc_trans WHERE trans_id = ?|;
83
      do_query($form, $dbh, $query, $form->{id});
84

  
85
    } else {
86

  
87
      ($form->{id}) = selectrow_query($form, $dbh, qq|SELECT nextval('glid')|);
88

  
89
      $query =
90
        qq|INSERT INTO ap (id, invnumber, employee_id,currency_id, taxzone_id) | .
91
        qq|VALUES (?, ?, (SELECT e.id FROM employee e WHERE e.login = ?),
92
                      (SELECT id FROM currencies WHERE name = ?), (SELECT taxzone_id FROM vendor WHERE id = ?) )|;
93
      do_query($form, $dbh, $query, $form->{id}, $form->{invnumber}, $::myconfig{login}, $form->{currency}, $form->{vendor_id});
94

  
95
    }
96
  }
97
  # check default or record exchangerate
75 98
  if ($form->{currency} eq $form->{defaultcurrency}) {
76 99
    $form->{exchangerate} = 1;
77 100
  } else {
......
91 114
                                 0, $form->{exchangerate}, $form->{id}, 'ap');
92 115
    }
93 116
  }
94

  
95 117
  # get the charts selected
96 118
  $form->{AP_amounts}{"amount_$_"} = $form->{"AP_amount_chart_id_$_"} for (1 .. $form->{rowcount});
97 119

  
......
124 146
  $form->{payables} = $form->{invtotal};
125 147

  
126 148
  if (!$payments_only) {
127
    # if we have an id delete old records
128
    if ($form->{id}) {
129

  
130
      # delete detail records
131
      $query = qq|DELETE FROM acc_trans WHERE trans_id = ?|;
132
      do_query($form, $dbh, $query, $form->{id});
133

  
134
    } else {
135

  
136
      ($form->{id}) = selectrow_query($form, $dbh, qq|SELECT nextval('glid')|);
137

  
138
      $query =
139
        qq|INSERT INTO ap (id, invnumber, employee_id,currency_id, taxzone_id) | .
140
        qq|VALUES (?, ?, (SELECT e.id FROM employee e WHERE e.login = ?),
141
                      (SELECT id FROM currencies WHERE name = ?), (SELECT taxzone_id FROM vendor WHERE id = ?) )|;
142
      do_query($form, $dbh, $query, $form->{id}, $form->{invnumber}, $::myconfig{login}, $form->{currency}, $form->{vendor_id});
143

  
144
    }
145

  
146 149
    $query = qq|UPDATE ap SET invnumber = ?,
147 150
                transdate = ?, ordnumber = ?, vendor_id = ?, taxincluded = ?,
148 151
                amount = ?, duedate = ?, deliverydate = ?, tax_point = ?, paid = ?, netamount = ?,
SL/AR.pm
71 71

  
72 72
  my $dbh = $provided_dbh || SL::DB->client->dbh;
73 73

  
74
  # if we have an id delete old records else make one
75
  if (!$payments_only) {
76
    if ($form->{id}) {
77
      # delete detail records
78
      $query = qq|DELETE FROM acc_trans WHERE trans_id = ?|;
79
      do_query($form, $dbh, $query, $form->{id});
80

  
81
    } else {
82
      $query = qq|SELECT nextval('glid')|;
83
      ($form->{id}) = selectrow_query($form, $dbh, $query);
84
      $query = qq|INSERT INTO ar (id, invnumber, employee_id, currency_id, taxzone_id) VALUES (?, 'dummy', ?, (SELECT id FROM currencies WHERE name=?), (SELECT taxzone_id FROM customer WHERE id = ?))|;
85
      do_query($form, $dbh, $query, $form->{id}, $form->{employee_id}, $form->{currency}, $form->{customer_id});
86
      if (!$form->{invnumber}) {
87
        my $trans_number   = SL::TransNumber->new(type => 'invoice', dbh => $dbh, number => $form->{partnumber}, id => $form->{id});
88
        $form->{invnumber} = $trans_number->create_unique;
89
      }
90
    }
91
  }
92

  
74 93
  $form->{defaultcurrency} = $form->get_default_currency($myconfig);
75 94
  # check default or record exchangerate
76 95
  if ($form->{currency} eq $form->{defaultcurrency}) {

Auch abrufbar als: Unified diff