Revision 9093d62e
Von Jan Büren vor mehr als 8 Jahren hinzugefügt
bin/mozilla/oe.pl | ||
---|---|---|
1491 | 1491 |
delete @{$form}{qw(id closed)}; |
1492 | 1492 |
$form->{rowcount}--; |
1493 | 1493 |
|
1494 |
if ($form->{type} =~ /_order$/) { |
|
1495 |
$form->{exchangerate} = $exchangerate; |
|
1496 |
&create_backorder; |
|
1497 |
} |
|
1498 |
|
|
1499 | 1494 |
my ($script); |
1500 | 1495 |
if ( $form->{type} eq 'purchase_order' |
1501 | 1496 |
|| $form->{type} eq 'request_quotation') { |
... | ... | |
1584 | 1579 |
$main::lxdebug->leave_sub(); |
1585 | 1580 |
} |
1586 | 1581 |
|
1587 |
sub create_backorder { |
|
1588 |
$main::lxdebug->enter_sub(); |
|
1589 |
|
|
1590 |
my $form = $main::form; |
|
1591 |
my %myconfig = %main::myconfig; |
|
1592 |
|
|
1593 |
$form->{shipped} = 1; |
|
1594 |
|
|
1595 |
# figure out if we need to create a backorder |
|
1596 |
# items aren't saved if qty != 0 |
|
1597 |
|
|
1598 |
my ($totalqty, $totalship); |
|
1599 |
for my $i (1 .. $form->{rowcount}) { |
|
1600 |
my $qty = $form->{"qty_$i"}; |
|
1601 |
my $ship = $form->{"ship_$i"}; |
|
1602 |
$totalqty += $qty; |
|
1603 |
$totalship += $ship; |
|
1604 |
|
|
1605 |
$form->{"qty_$i"} = $qty - $ship; |
|
1606 |
} |
|
1607 |
|
|
1608 |
if ($totalship == 0) { |
|
1609 |
map { $form->{"ship_$_"} = $form->{"qty_$_"} } (1 .. $form->{rowcount}); |
|
1610 |
$form->{ordtotal} = 0; |
|
1611 |
$form->{shipped} = 0; |
|
1612 |
return; |
|
1613 |
} |
|
1614 |
|
|
1615 |
if ($totalqty == $totalship) { |
|
1616 |
map { $form->{"qty_$_"} = $form->{"ship_$_"} } (1 .. $form->{rowcount}); |
|
1617 |
$form->{ordtotal} = 0; |
|
1618 |
return; |
|
1619 |
} |
|
1620 |
|
|
1621 |
my @flds = ( |
|
1622 |
qw(partnumber description qty ship unit sellprice discount id inventory_accno bin income_accno expense_accno listprice assembly taxaccounts partsgroup) |
|
1623 |
); |
|
1624 |
|
|
1625 |
for my $i (1 .. $form->{rowcount}) { |
|
1626 |
map { |
|
1627 |
$form->{"${_}_$i"} = |
|
1628 |
$form->format_amount(\%myconfig, $form->{"${_}_$i"}) |
|
1629 |
} qw(sellprice discount); |
|
1630 |
} |
|
1631 |
|
|
1632 |
relink_accounts(); |
|
1633 |
|
|
1634 |
OE->save(\%myconfig, \%$form); |
|
1635 |
|
|
1636 |
# rebuild rows for invoice |
|
1637 |
my @a = (); |
|
1638 |
my $count = 0; |
|
1639 |
|
|
1640 |
for my $i (1 .. $form->{rowcount}) { |
|
1641 |
$form->{"qty_$i"} = $form->{"ship_$i"}; |
|
1642 |
|
|
1643 |
if ($form->{"qty_$i"}) { |
|
1644 |
push @a, {}; |
|
1645 |
my $j = $#a; |
|
1646 |
map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds; |
|
1647 |
$count++; |
|
1648 |
} |
|
1649 |
} |
|
1650 |
|
|
1651 |
$form->redo_rows(\@flds, \@a, $count, $form->{rowcount}); |
|
1652 |
$form->{rowcount} = $count; |
|
1653 |
|
|
1654 |
$main::lxdebug->leave_sub(); |
|
1655 |
} |
|
1656 |
|
|
1657 | 1582 |
sub save_as_new { |
1658 | 1583 |
$main::lxdebug->enter_sub(); |
1659 | 1584 |
|
Auch abrufbar als: Unified diff
create_backorder entfernt