Revision 566fcc06
Von Jan Büren vor fast 2 Jahren hinzugefügt
SL/AP.pm | ||
---|---|---|
76 | 76 |
$form->{exchangerate} = 1; |
77 | 77 |
} else { |
78 | 78 |
$exchangerate = $form->check_exchangerate($myconfig, $form->{currency}, $form->{transdate}, 'sell'); |
79 |
$form->{exchangerate} = $exchangerate || $form->parse_amount($myconfig, $form->{exchangerate}); |
|
79 |
$form->{exchangerate} = $form->parse_amount($myconfig, $form->{exchangerate}, 5); |
|
80 |
|
|
81 |
# if default exchangerate is not defined, define one |
|
82 |
unless ($exchangerate) { |
|
83 |
$form->update_exchangerate($dbh, $form->{currency}, $form->{transdate}, 0, $form->{exchangerate}); |
|
84 |
# delete records exchangerate -> if user sets new invdate for record |
|
85 |
$query = qq|UPDATE ap set exchangerate = NULL where id = ?|; |
|
86 |
do_query($form, $dbh, $query, $form->{"id"}); |
|
87 |
} |
|
88 |
# update record exchangerate, if the default is set and differs from current |
|
89 |
if ($exchangerate && ($form->{exchangerate} != $exchangerate)) { |
|
90 |
$form->update_exchangerate($dbh, $form->{currency}, $form->{transdate}, |
|
91 |
0, $form->{exchangerate}, $form->{id}, 'ap'); |
|
92 |
} |
|
80 | 93 |
} |
81 | 94 |
|
82 | 95 |
# get the charts selected |
... | ... | |
110 | 123 |
# amount for total AP |
111 | 124 |
$form->{payables} = $form->{invtotal}; |
112 | 125 |
|
113 |
# update exchangerate |
|
114 |
if (($form->{currency} ne $form->{defaultcurrency}) && !$exchangerate) { |
|
115 |
$form->update_exchangerate($dbh, $form->{currency}, $form->{transdate}, 0, |
|
116 |
$form->{exchangerate}); |
|
117 |
} |
|
118 |
|
|
119 |
my ($query, $sth, @values); |
|
120 |
|
|
121 | 126 |
if (!$payments_only) { |
122 | 127 |
# if we have an id delete old records |
123 | 128 |
if ($form->{id}) { |
SL/AR.pm | ||
---|---|---|
70 | 70 |
my @values; |
71 | 71 |
|
72 | 72 |
my $dbh = $provided_dbh || SL::DB->client->dbh; |
73 |
$form->{defaultcurrency} = $form->get_default_currency($myconfig); |
|
74 | 73 |
|
75 |
# set exchangerate |
|
76 |
$form->{exchangerate} = ($form->{currency} eq $form->{defaultcurrency}) ? 1 : |
|
77 |
( $form->check_exchangerate($myconfig, $form->{currency}, $form->{transdate}, 'buy') || |
|
78 |
$form->parse_amount($myconfig, $form->{exchangerate}) ); |
|
74 |
$form->{defaultcurrency} = $form->get_default_currency($myconfig); |
|
75 |
# check default or record exchangerate |
|
76 |
if ($form->{currency} eq $form->{defaultcurrency}) { |
|
77 |
$form->{exchangerate} = 1; |
|
78 |
} else { |
|
79 |
$exchangerate = $form->check_exchangerate($myconfig, $form->{currency}, $form->{transdate}, 'buy'); |
|
80 |
$form->{exchangerate} = $form->parse_amount($myconfig, $form->{exchangerate}, 5); |
|
81 |
|
|
82 |
# if default exchangerate is not defined, define one |
|
83 |
unless ($exchangerate) { |
|
84 |
$form->update_exchangerate($dbh, $form->{currency}, $form->{transdate}, $form->{exchangerate}, 0); |
|
85 |
# delete records exchangerate -> if user sets new invdate for record |
|
86 |
$query = qq|UPDATE ar set exchangerate = NULL where id = ?|; |
|
87 |
do_query($form, $dbh, $query, $form->{"id"}); |
|
88 |
} |
|
89 |
# update record exchangerate, if the default is set and differs from current |
|
90 |
if ($exchangerate && ($form->{exchangerate} != $exchangerate)) { |
|
91 |
$form->update_exchangerate($dbh, $form->{currency}, $form->{transdate}, |
|
92 |
$form->{exchangerate}, 0, $form->{id}, 'ar'); |
|
93 |
} |
|
94 |
} |
|
79 | 95 |
|
80 | 96 |
# get the charts selected |
81 | 97 |
$form->{AR_amounts}{"amount_$_"} = $form->{"AR_amount_chart_id_$_"} for (1 .. $form->{rowcount}); |
... | ... | |
104 | 120 |
|
105 | 121 |
$form->get_employee($dbh) unless $form->{employee_id}; |
106 | 122 |
|
107 |
# if we have an id delete old records else make one |
|
108 |
if (!$payments_only) { |
|
109 |
if ($form->{id}) { |
|
110 |
# delete detail records |
|
111 |
$query = qq|DELETE FROM acc_trans WHERE trans_id = ?|; |
|
112 |
do_query($form, $dbh, $query, $form->{id}); |
|
113 | 123 |
|
114 |
} else { |
|
115 |
$query = qq|SELECT nextval('glid')|; |
|
116 |
($form->{id}) = selectrow_query($form, $dbh, $query); |
|
117 |
$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 = ?))|; |
|
118 |
do_query($form, $dbh, $query, $form->{id}, $form->{employee_id}, $form->{currency}, $form->{customer_id}); |
|
119 |
if (!$form->{invnumber}) { |
|
120 |
my $trans_number = SL::TransNumber->new(type => 'invoice', dbh => $dbh, number => $form->{partnumber}, id => $form->{id}); |
|
121 |
$form->{invnumber} = $trans_number->create_unique; |
|
122 |
} |
|
123 |
} |
|
124 |
} |
|
125 | 124 |
|
126 | 125 |
# amount for AR account |
127 | 126 |
$form->{receivables} = $form->round_amount($form->{amount}, 2) * -1; |
128 | 127 |
|
129 |
# update exchangerate |
|
130 |
$form->update_exchangerate($dbh, $form->{currency}, $form->{transdate}, $form->{exchangerate}, 0) |
|
131 |
if ($form->{currency} ne $form->{defaultcurrency}) && !$form->check_exchangerate($myconfig, $form->{currency}, $form->{transdate}, 'buy'); |
|
132 |
|
|
133 | 128 |
if (!$payments_only) { |
134 | 129 |
$query = |
135 | 130 |
qq|UPDATE ar set |
SL/IR.pm | ||
---|---|---|
100 | 100 |
do_query($form, $dbh, qq|INSERT INTO ap (id, invnumber, currency_id, taxzone_id) VALUES (?, '', (SELECT id FROM currencies WHERE name=?), ?)|, $form->{id}, $form->{currency}, $form->{taxzone_id}); |
101 | 101 |
} |
102 | 102 |
} |
103 |
|
|
104 | 103 |
if ($form->{currency} eq $defaultcurrency) { |
105 | 104 |
$form->{exchangerate} = 1; |
106 | 105 |
} else { |
107 |
$exchangerate = $form->check_exchangerate($myconfig, $form->{currency}, $form->{invdate}, 'sell'); |
|
106 |
$exchangerate = $form->check_exchangerate($myconfig, $form->{currency}, $form->{invdate}, 'sell'); |
|
107 |
$form->{exchangerate} = $form->parse_amount($myconfig, $form->{exchangerate}, 5); |
|
108 |
|
|
109 |
# if default exchangerate is not defined, define one |
|
110 |
unless ($exchangerate) { |
|
111 |
$form->update_exchangerate($dbh, $form->{currency}, $form->{invdate}, 0, $form->{exchangerate}); |
|
112 |
# delete records exchangerate -> if user sets new invdate for record |
|
113 |
$query = qq|UPDATE ap set exchangerate = NULL where id = ?|; |
|
114 |
do_query($form, $dbh, $query, $form->{"id"}); |
|
115 |
} |
|
116 |
# update record exchangerate, if the default is set and differs from current |
|
117 |
if ($exchangerate && ($form->{exchangerate} != $exchangerate)) { |
|
118 |
$form->update_exchangerate($dbh, $form->{currency}, $form->{invdate}, |
|
119 |
0, $form->{exchangerate}, $form->{id}, 'ap'); |
|
120 |
} |
|
108 | 121 |
} |
109 |
|
|
110 |
$form->{exchangerate} = $exchangerate || $form->parse_amount($myconfig, $form->{exchangerate}); |
|
111 |
$form->{exchangerate} = 1 unless ($form->{exchangerate} * 1); |
|
112 |
|
|
113 | 122 |
my %item_units; |
114 | 123 |
my $q_item_unit = qq|SELECT unit FROM parts WHERE id = ?|; |
115 | 124 |
my $h_item_unit = prepare_query($form, $dbh, $q_item_unit); |
... | ... | |
543 | 552 |
|
544 | 553 |
$form->{paid} = $form->round_amount($form->{paid} * $form->{exchangerate} + $paiddiff, 2) if $form->{paid} != 0; |
545 | 554 |
|
546 |
# update exchangerate |
|
547 |
|
|
548 |
$form->update_exchangerate($dbh, $form->{currency}, $form->{invdate}, 0, $form->{exchangerate}) |
|
549 |
if ($form->{currency} ne $defaultcurrency) && !$exchangerate; |
|
550 |
|
|
551 |
# record acc_trans transactions |
|
555 |
# record acc_trans transactions |
|
552 | 556 |
my $taxdate = $form->{tax_point} || $form->{deliverydate} || $form->{invdate}; |
553 | 557 |
foreach my $trans_id (keys %{ $form->{amount} }) { |
554 | 558 |
foreach my $accno (keys %{ $form->{amount}{$trans_id} }) { |
SL/IS.pm | ||
---|---|---|
813 | 813 |
if ($form->{currency} eq $defaultcurrency) { |
814 | 814 |
$form->{exchangerate} = 1; |
815 | 815 |
} else { |
816 |
$exchangerate = $form->check_exchangerate($myconfig, $form->{currency}, $form->{invdate}, 'buy'); |
|
816 |
$exchangerate = $form->check_exchangerate($myconfig, $form->{currency}, $form->{invdate}, 'buy'); |
|
817 |
$form->{exchangerate} = $form->parse_amount($myconfig, $form->{exchangerate}, 5); |
|
818 |
|
|
819 |
# if default exchangerate is not defined, define one |
|
820 |
unless ($exchangerate) { |
|
821 |
$form->update_exchangerate($dbh, $form->{currency}, $form->{invdate}, $form->{exchangerate}, 0); |
|
822 |
# delete records exchangerate -> if user sets new invdate for record |
|
823 |
$query = qq|UPDATE ar set exchangerate = NULL where id = ?|; |
|
824 |
do_query($form, $dbh, $query, $form->{"id"}); |
|
825 |
} |
|
826 |
# update record exchangerate, if the default is set and differs from current |
|
827 |
if ($exchangerate && ($form->{exchangerate} != $exchangerate)) { |
|
828 |
$form->update_exchangerate($dbh, $form->{currency}, $form->{invdate}, |
|
829 |
$form->{exchangerate}, 0, $form->{id}, 'ar'); |
|
830 |
} |
|
817 | 831 |
} |
818 | 832 |
|
819 |
$form->{exchangerate} = |
|
820 |
($exchangerate) |
|
821 |
? $exchangerate |
|
822 |
: $form->parse_amount($myconfig, $form->{exchangerate}); |
|
823 |
|
|
824 | 833 |
$form->{expense_inventory} = ""; |
825 | 834 |
|
826 | 835 |
my %baseunits; |
... | ... | |
1101 | 1110 |
# reverse AR |
1102 | 1111 |
$form->{amount}{ $form->{id} }{ $form->{AR} } *= -1; |
1103 | 1112 |
|
1104 |
# update exchangerate |
|
1105 |
if (($form->{currency} ne $defaultcurrency) && !$exchangerate) { |
|
1106 |
$form->update_exchangerate($dbh, $form->{currency}, $form->{invdate}, |
|
1107 |
$form->{exchangerate}, 0); |
|
1108 |
} |
|
1109 |
|
|
1110 | 1113 |
$project_id = conv_i($form->{"globalproject_id"}); |
1111 | 1114 |
# entsprechend auch beim Bestimmen des Steuerschlüssels in Taxkey.pm berücksichtigen |
1112 | 1115 |
my $taxdate = $form->{tax_point} ||$form->{deliverydate} || $form->{invdate}; |
Auch abrufbar als: Unified diff
Beleg-Wechselkurs speichern, falls gesetzt und abweichend vom Tageskurs
Für alle 4 Buchungsmaske - Etwas zuviel in dem Commit, da die
form->id schon vorhanden sein muss und ich die Aufteilung an 2
Stellen von _post_invoice|post für das Holen und Setzen auf eine
reduzieren wollte.