Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 43f9b1c5

Von G. Richardson vor etwa 13 Jahren hinzugefügt

  • ID 43f9b1c512be9bc2199369c2f5accea32b8bd423
  • Vorgänger 45de0008
  • Nachfolger 306fad80

Umstellung von eur zu 3 Variablen in defaults

accounting_method inventory_system profit_determination

Details siehe doc/umstellung_eur.txt

Unterschiede anzeigen:

SL/IS.pm
1256 1256
  my $allocated = 0;
1257 1257
  my $qty;
1258 1258

  
1259
# all invoice entries of an example part:
1260

  
1261
# id | trans_id | base_qty | allocated | sellprice | inventory_accno | income_accno | expense_accno 
1262
# ---+----------+----------+-----------+-----------+-----------------+--------------+---------------
1263
#  4 |        4 |       -5 |         5 |  20.00000 | 1140            | 4400         | 5400     bought 5 for 20
1264
#  5 |        5 |        4 |        -4 |  50.00000 | 1140            | 4400         | 5400     sold   4 for 50
1265
#  6 |        6 |        1 |        -1 |  50.00000 | 1140            | 4400         | 5400     sold   1 for 50
1266
#  7 |        7 |       -5 |         1 |  20.00000 | 1140            | 4400         | 5400     bought 5 for 20
1267
#  8 |        8 |        1 |        -1 |  50.00000 | 1140            | 4400         | 5400     sold   1 for 50
1268

  
1269
# AND ((i.base_qty + i.allocated) < 0) filters out all but line with id=7, elsewhere i.base_qty + i.allocated has already reached 0
1270
# and all parts have been allocated
1271

  
1272
# so transaction 8 only sees transaction 7 with unallocated parts and adjusts allocated for that transaction, before allocated was 0
1273
#  7 |        7 |       -5 |         1 |  20.00000 | 1140            | 4400         | 5400     bought 5 for 20
1274

  
1275
# in this example there are still 4 unsold articles
1276

  
1277

  
1278
  # search all invoice entries for the part in question, adjusting "allocated"
1279
  # until the total number of sold parts has been reached
1280

  
1281
  # ORDER BY trans_id ensures FIFO
1282

  
1283

  
1259 1284
  while (my $ref = $sth->fetchrow_hashref('NAME_lc')) {
1260 1285
    if (($qty = (($ref->{base_qty} * -1) - $ref->{allocated})) > $totalqty) {
1261 1286
      $qty = $totalqty;
1262 1287
    }
1263 1288

  
1289
    # update allocated in invoice
1264 1290
    $form->update_balance($dbh, "invoice", "allocated", qq|id = $ref->{id}|, $qty);
1265 1291

  
1266 1292
    # total expenses and inventory
1267 1293
    # sellprice is the cost of the item
1268 1294
    my $linetotal = $form->round_amount(($ref->{sellprice} * $qty) / ( ($ref->{price_factor} || 1) * ( $basefactor || 1 )), 2);
1269 1295

  
1270
    if (!$::lx_office_conf{system}->{eur}) {
1296
    if ( $::instance_conf->get_inventory_system eq 'perpetual' ) {
1297
      # Bestandsmethode: when selling parts, deduct their purchase value from the inventory account
1271 1298
      $ref->{expense_accno} = ($form->{"expense_accno_$row"}) ? $form->{"expense_accno_$row"} : $ref->{expense_accno};
1272 1299
      # add to expense
1273 1300
      $form->{amount_cogs}{ $form->{id} }{ $ref->{expense_accno} } += -$linetotal;

Auch abrufbar als: Unified diff