Revision 03ff37cb
Von Niclas Zimmermann vor fast 12 Jahren hinzugefügt
SL/IS.pm | ||
---|---|---|
822 | 822 |
|
823 | 823 |
$project_id = conv_i($form->{"globalproject_id"}); |
824 | 824 |
|
825 |
my $taxdate = $form->{deliverydate} ? $form->{deliverydate} : $form->{invdate}; |
|
826 |
|
|
825 | 827 |
foreach my $trans_id (keys %{ $form->{amount_cogs} }) { |
826 | 828 |
foreach my $accno (keys %{ $form->{amount_cogs}{$trans_id} }) { |
827 | 829 |
next unless ($form->{expense_inventory} =~ /\Q$accno\E/); |
... | ... | |
830 | 832 |
|
831 | 833 |
if (!$payments_only && ($form->{amount_cogs}{$trans_id}{$accno} != 0)) { |
832 | 834 |
$query = |
833 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, project_id) |
|
834 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 0, ?)|; |
|
835 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id)
|
|
836 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, (SELECT id FROM tax WHERE taxkey=0), 0, ?)|;
|
|
835 | 837 |
@values = (conv_i($trans_id), $accno, $form->{amount_cogs}{$trans_id}{$accno}, conv_date($form->{invdate}), conv_i($project_id)); |
836 | 838 |
do_query($form, $dbh, $query, @values); |
837 | 839 |
$form->{amount_cogs}{$trans_id}{$accno} = 0; |
... | ... | |
843 | 845 |
|
844 | 846 |
if (!$payments_only && ($form->{amount_cogs}{$trans_id}{$accno} != 0)) { |
845 | 847 |
$query = |
846 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, project_id) |
|
847 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 0, ?)|; |
|
848 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id)
|
|
849 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, (SELECT id FROM tax WHERE taxkey=0), 0, ?)|;
|
|
848 | 850 |
@values = (conv_i($trans_id), $accno, $form->{amount_cogs}{$trans_id}{$accno}, conv_date($form->{invdate}), conv_i($project_id)); |
849 | 851 |
do_query($form, $dbh, $query, @values); |
850 | 852 |
} |
... | ... | |
859 | 861 |
|
860 | 862 |
if (!$payments_only && ($form->{amount}{$trans_id}{$accno} != 0)) { |
861 | 863 |
$query = |
862 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, project_id) |
|
864 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id)
|
|
863 | 865 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, |
866 |
(SELECT tax_id FROM taxkeys WHERE chart_id= (SELECT id FROM chart WHERE accno = ?) AND startdate <= ? ORDER BY startdate DESC LIMIT 1), |
|
864 | 867 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?)|; |
865 |
@values = (conv_i($trans_id), $accno, $form->{amount}{$trans_id}{$accno}, conv_date($form->{invdate}), $accno, conv_i($project_id)); |
|
868 |
@values = (conv_i($trans_id), $accno, $form->{amount}{$trans_id}{$accno}, conv_date($form->{invdate}), $accno, conv_date($taxdate), $accno, conv_i($project_id));
|
|
866 | 869 |
do_query($form, $dbh, $query, @values); |
867 | 870 |
$form->{amount}{$trans_id}{$accno} = 0; |
868 | 871 |
} |
... | ... | |
873 | 876 |
|
874 | 877 |
if (!$payments_only && ($form->{amount}{$trans_id}{$accno} != 0)) { |
875 | 878 |
$query = |
876 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, project_id) |
|
879 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id)
|
|
877 | 880 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, |
881 |
(SELECT tax_id FROM taxkeys WHERE chart_id= (SELECT id FROM chart WHERE accno = ?) AND startdate <= ? ORDER BY startdate DESC LIMIT 1), |
|
878 | 882 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?)|; |
879 |
@values = (conv_i($trans_id), $accno, $form->{amount}{$trans_id}{$accno}, conv_date($form->{invdate}), $accno, conv_i($project_id)); |
|
883 |
@values = (conv_i($trans_id), $accno, $form->{amount}{$trans_id}{$accno}, conv_date($form->{invdate}), $accno, conv_date($taxdate), $accno, conv_i($project_id));
|
|
880 | 884 |
do_query($form, $dbh, $query, @values); |
881 | 885 |
} |
882 | 886 |
} |
... | ... | |
922 | 926 |
|
923 | 927 |
if ($form->{amount}{ $form->{id} }{ $form->{AR} } != 0) { |
924 | 928 |
$query = |
925 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, project_id) |
|
929 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id)
|
|
926 | 930 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, |
931 |
(SELECT tax_id FROM taxkeys WHERE chart_id= (SELECT id FROM chart WHERE accno = ?) AND startdate <= ? ORDER BY startdate DESC LIMIT 1), |
|
927 | 932 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?)|; |
928 |
@values = (conv_i($form->{"id"}), $form->{AR}, $amount, $form->{"datepaid_$i"}, $form->{AR}, $project_id); |
|
933 |
@values = (conv_i($form->{"id"}), $form->{AR}, $amount, $form->{"datepaid_$i"}, $form->{AR}, conv_date($taxdate), $form->{AR}, $project_id);
|
|
929 | 934 |
do_query($form, $dbh, $query, @values); |
930 | 935 |
} |
931 | 936 |
|
... | ... | |
934 | 939 |
my $gldate = (conv_date($form->{"gldate_$i"}))? conv_date($form->{"gldate_$i"}) : conv_date($form->current_date($myconfig)); |
935 | 940 |
|
936 | 941 |
$query = |
937 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, taxkey, project_id) |
|
942 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, tax_id, taxkey, project_id)
|
|
938 | 943 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, |
944 |
(SELECT tax_id FROM taxkeys WHERE chart_id= (SELECT id FROM chart WHERE accno = ?) AND startdate <= ? ORDER BY startdate DESC LIMIT 1), |
|
939 | 945 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?)|; |
940 | 946 |
@values = (conv_i($form->{"id"}), $accno, $form->{"paid_$i"}, $form->{"datepaid_$i"}, |
941 |
$gldate, $form->{"source_$i"}, $form->{"memo_$i"}, $accno, $project_id); |
|
947 |
$gldate, $form->{"source_$i"}, $form->{"memo_$i"}, $accno, conv_date($taxdate), $accno, $project_id);
|
|
942 | 948 |
do_query($form, $dbh, $query, @values); |
943 | 949 |
|
944 | 950 |
# exchangerate difference |
... | ... | |
978 | 984 |
if ( $form->{fx}{$accno}{$transdate} != 0 ) { |
979 | 985 |
|
980 | 986 |
$query = |
981 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, cleared, fx_transaction, taxkey, project_id) |
|
987 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, cleared, fx_transaction, tax_id, taxkey, project_id)
|
|
982 | 988 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, '0', '1', |
983 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?)|; |
|
984 |
@values = (conv_i($form->{"id"}), $accno, $form->{fx}{$accno}{$transdate}, conv_date($transdate), $accno, conv_i($project_id)); |
|
989 |
(SELECT tax_id FROM taxkeys WHERE chart_id= (SELECT id FROM chart WHERE accno = ?) AND startdate <= ? ORDER BY startdate DESC LIMIT 1), |
|
990 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?)|; |
|
991 |
@values = (conv_i($form->{"id"}), $accno, $form->{fx}{$accno}{$transdate}, conv_date($transdate), $accno, conv_date($taxdate), $accno, conv_i($project_id)); |
|
985 | 992 |
do_query($form, $dbh, $query, @values); |
986 | 993 |
} |
987 | 994 |
} |
Auch abrufbar als: Unified diff
tax_id in acc_trans
Dieser Commit enthält das Update-Script um eine neue Spalte Namens
'tax_id' in die Tabelle 'acc_trans' einzufügen. Diese Spalte hat
Constrait NOT NULL und einen Fremdschlüssel auf die id von tax.
Das Pflichtfeld wird jetzt immer geschrieben bei:
-VK-Rechnungen (auch automatisch erzeugten)
-EK-Rechnungen
-Kreditorenbuchungen
-Debitorenbuchungen
-Dialogbuchungen
Durch das Feld 'tax_id' können in der Tabelle tax der
Steuerschlüssel und der Steuersatz ausgelesen werden.
In diesem Commit wird allerdings der Wert in tax_id nur geschrieben,
im Moment wird er noch nirgendwo ausgelesen.