mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-05-13 15:16:38 +02:00
saving column into invoices
This commit is contained in:
parent
ba041a56b6
commit
4c11beb331
7 changed files with 222 additions and 283 deletions
|
@ -19,6 +19,7 @@ use Lib::Config;
|
|||
use Mod::Buttons;
|
||||
use Mod::Libenz;
|
||||
use Mod::Libenzdb;
|
||||
use Mod::Pricing;
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
|
@ -33,6 +34,8 @@ sub printpre(){
|
|||
my $lb = new Libenz;
|
||||
my $db = new Libenzdb;
|
||||
my $but = new Buttons;
|
||||
my $pri = new Pricing;
|
||||
|
||||
my %varenv = $cf->envonline();
|
||||
my $path = $q->path_info();
|
||||
my $script = $q->script_name();
|
||||
|
@ -149,8 +152,6 @@ td {
|
|||
my $ctf = $db->get_content1("contentuser","$mandant_main_id");
|
||||
$ctf->{txt13} = $1 if($ctf->{txt13} =~ /(\d+)/);
|
||||
|
||||
my $tpl = $db->get_tpl($ctf->{txt34});#Verkauf template
|
||||
$tpl = $db->get_tpl($ctf->{txt36}) if($users->{kind_of_trans} =~ /Faktur/);
|
||||
my $ctt = $db->get_content1("contenttrans",$c_id);
|
||||
|
||||
#payone Bank
|
||||
|
@ -170,9 +171,9 @@ td {
|
|||
my $mtime = $lb->time4de("$invoice_time","");
|
||||
|
||||
$db->updater("contenttrans","c_id",$ctt->{c_id},"invoice_time","$invoice_time","");
|
||||
#
|
||||
my $scol = "c_id";
|
||||
#$scol = "$users->{cash_sort}" if($users->{cash_sort});
|
||||
|
||||
#my $scol = "c_id";
|
||||
my $scol = "itime";
|
||||
my $i=0;
|
||||
my $tplf = $db->get_tpl("201");#Firma tpl
|
||||
my @tplf_order = split /,/,$tplf->{tpl_order};
|
||||
|
@ -208,7 +209,7 @@ td {
|
|||
&data_invoice("0",$vendor,$kd_nr,$mandat_nr,$ctt->{txt00},$ct_name2print,$mtime);
|
||||
|
||||
#table
|
||||
my ($sum_paid,$break_table_wc,$nullcount) = &data_table("0",$c_id,$scol,"",$mandant_main_id,$users->{kind_of_trans},$tpl->{tpl_order},"0",$max_table_wc,$ctt);
|
||||
my ($sum_paid,$break_table_wc,$nullcount) = &data_table("0",$c_id,$scol,"",$mandant_main_id,"0",$max_table_wc,$ctt);
|
||||
|
||||
#print "$site_all++ if(($wc > $max_site_wc) || ($table_wc > $max_table_wc)) --> $break_table_wc";
|
||||
#$site_all++ if(($wc > $max_site_wc) || ($table_wc > $max_table_wc));
|
||||
|
@ -220,7 +221,7 @@ td {
|
|||
|
||||
print PMA "$site_all,$footer_top,$site,$site_all,$wc\n";
|
||||
if($site_all == 1){
|
||||
&text_description("0",$mandant_main_id,$ctt->{txt21},$ctt->{txt12},$users->{kind_of_trans},$ctt->{txt00},$nullcount);
|
||||
&text_description("0",$mandant_main_id,$ctt->{txt21},$ctt->{txt12},$ctt->{txt00},$nullcount);
|
||||
&text_footer($mandant_main_id,$footer_top,$site,$site_all,$wc,$footer_bank,$logo);
|
||||
}else{
|
||||
&text_footer($mandant_main_id,$footer_top,$site,$site_all,$wc,$footer_bank,$logo);
|
||||
|
@ -236,13 +237,13 @@ td {
|
|||
$h_top +=60;
|
||||
#table_break
|
||||
if($break_table_wc >= $max_table_wc){
|
||||
my ($sum_paid,$exit_table_wc,$nullcount) = &data_table($h_top,$c_id,$scol,"",$mandant_main_id,$users->{kind_of_trans},$tpl->{tpl_order},$break_table_wc,$max_table_wc,$ctt,$sum_paid);
|
||||
my ($sum_paid,$exit_table_wc,$nullcount) = &data_table($h_top,$c_id,$scol,"",$mandant_main_id,$break_table_wc,$max_table_wc,$ctt,$sum_paid);
|
||||
$h_top += ($table_wc - $max_table_wc) * 65;
|
||||
print PMA "h_top: $h_top += ($table_wc - $max_table_wc) * 65\n";
|
||||
}
|
||||
|
||||
#print "$h_top | $table_wc | $break_table_wc >= $max_table_wc";
|
||||
&text_description($h_top,$mandant_main_id,$ctt->{txt21},$ctt->{txt12},$users->{kind_of_trans},$ctt->{txt00},$nullcount);
|
||||
&text_description($h_top,$mandant_main_id,$ctt->{txt21},$ctt->{txt12},$ctt->{txt00},$nullcount);
|
||||
$footer_top +=130;
|
||||
$site++;
|
||||
print PMA "$site_all,$footer_top,$site,$site_all,$wc\n";
|
||||
|
@ -338,10 +339,9 @@ td {
|
|||
}
|
||||
|
||||
sub data_table(){
|
||||
my ($h_top,$c_id,$scol,$ctt_dummy,$mandant_main_id,$kind_of_trans,$tpl_order,$break_table_wc,$max_table_wc,$ctt,$sum_break) = @_;
|
||||
my ($h_top,$c_id,$scol,$ctt_dummy,$mandant_main_id,$break_table_wc,$max_table_wc,$ctt,$sum_break) = @_;
|
||||
$ctf = $db->get_content1("contentuser","$mandant_main_id");
|
||||
|
||||
my $umst1619 = $lb->umst_breaking($ctt,"");
|
||||
#my $umst1619 = $lb->umst_breaking($ctt,"");
|
||||
|
||||
my $txt20 = $ctt->{txt20};
|
||||
my $max_timestamp = "210001012359";
|
||||
|
@ -354,14 +354,20 @@ td {
|
|||
}
|
||||
|
||||
my $max_sum = $ctf->{int03} || "10000";
|
||||
my @tpl_order = ("txt01=Beschreibung","ct_name=Nummer","date_time=Mietzeit","int03=Menge","int02=Preis","int07=Rabatt","int04=Gesamt");
|
||||
my ($cttpos,$rows) = $db->collect_contentpos("contenttrans",$c_id);
|
||||
foreach my $id (keys(%$cttpos)){
|
||||
if($cttpos->{$id}->{int26}){
|
||||
@tpl_order = ("txt01=Beschreibung","ct_name=Nummer","date_time=Mietzeit","int26=Einsparung","int03=Menge","int02=Preis","int07=Rabatt","int04=Gesamt");
|
||||
}
|
||||
}
|
||||
|
||||
my $h_toppx = "$h_top" . "px";
|
||||
my $position;
|
||||
$position = "position:absolute; top: $h_toppx;" if($h_top);
|
||||
|
||||
print "\n<div style='width:$width;$position border:0px solid black;'>\n";
|
||||
print $q->start_table({ -border=>'0', -width=>'100%',-align=>'center', -cellpadding=>'3', -cellspacing=>'0'}),"\n";
|
||||
my @tpl_order = split /,/,$tpl_order;
|
||||
|
||||
#Tableheader
|
||||
my $h=0;
|
||||
|
@ -371,13 +377,7 @@ td {
|
|||
$h++ if($val && $key !~ /int07/);
|
||||
print $q->th({-class=>'tdint'},"$val"),"\n" if("$key" eq "ct_name");
|
||||
print $q->th({-class=>'tdtxt2'},"$val"),"\n" if($key =~ /txt01/);
|
||||
print $q->th({-class=>'tdint'},"$val"),"\n" if($key =~ /int03/);
|
||||
if($ctt->{txt00} =~ /Lieferschein/){
|
||||
print $q->th(""),"\n" if($key =~ /int02|int03/);
|
||||
}else{
|
||||
print $q->th({-class=>'tdint'},"$val"),"\n" if($key =~ /int02/);
|
||||
print $q->th({-class=>'tdint'},"$val"),"\n" if($key =~ /int04/);
|
||||
}
|
||||
print $q->th({-class=>'tdint'},"$val"),"\n" if($key =~ /int02|int03|int04|int26/);
|
||||
}
|
||||
$h--;
|
||||
|
||||
|
@ -398,39 +398,23 @@ td {
|
|||
}
|
||||
|
||||
#Tablecontent (ct_name(primary key))
|
||||
my $sum_parts0=0;
|
||||
my $sum_parts7=0;
|
||||
my $sum_parts19=0;
|
||||
my $j=0;
|
||||
my $k=0;
|
||||
my $nullcount=0;
|
||||
foreach my $id (sort { $cttpos->{$a}->{$scol} <=> $cttpos->{$b}->{$scol} } keys(%$cttpos)){
|
||||
#foreach my $id (sort { $cttpos->{$a}->{$scol} <=> $cttpos->{$b}->{$scol} } keys(%$cttpos)){
|
||||
foreach my $id (sort { $cttpos->{$b}->{$scol} cmp $cttpos->{$a}->{$scol} } keys(%$cttpos)){
|
||||
my $cttpos_timestamp = $1 . $2 . $3 . "0000" if($cttpos->{$id}->{itime} =~ /(\d+)\-(\d+)\-(\d+)/);
|
||||
#$k++;
|
||||
my $menge="0";my $gesamt="0";my $kaution="0";my $gesamt_kaution="0";
|
||||
my $timeing="0";my $times;my $rent_time;my $start_time;my $end_time;
|
||||
#Mietzeit wenn Verleihräder
|
||||
if($kind_of_trans =~ /Faktur|Verleih/ && $cttpos->{$id}->{int12} =~ /$ctf->{txt29}/){
|
||||
$timeing="1";
|
||||
$times = $db->get_time4ct("contenttranspos",$cttpos->{$id}->{c_id});
|
||||
$start_time = $lb->time4de($times->{start_time},"1");
|
||||
$end_time = $lb->time4de($times->{end_time},"1");
|
||||
}
|
||||
|
||||
my $gesamt = 0;
|
||||
my $rabatt = "";
|
||||
my $einzel = $cttpos->{$id}->{int02};
|
||||
my $menge = $cttpos->{$id}->{int03} || 0;
|
||||
my $unit = $cttpos->{$id}->{txt03};
|
||||
|
||||
#start copri pricing on 2018-03-21
|
||||
my $dt1 = DateTime->new(year => 2018, month => 3, day => 20);
|
||||
my $dt0 = $dt1;
|
||||
my $dt2 = $dt1;
|
||||
$dt0 = DateTime::Format::Pg->parse_datetime($cttpos->{$id}->{start_time}) if($cttpos->{$id}->{start_time});
|
||||
$dt2 = DateTime::Format::Pg->parse_datetime($cttpos->{$id}->{end_time}) if($cttpos->{$id}->{end_time});
|
||||
|
||||
if(looks_like_number($einzel) && $einzel != 0 && looks_like_number($menge) && $menge != 0){
|
||||
$gesamt = $einzel * $menge;
|
||||
}
|
||||
($gesamt,$rabatt) = $pri->price2calc($cttpos->{$id});
|
||||
$gesamt = $lb->round($gesamt);
|
||||
$gesamt = $lb->cashme($gesamt,",");
|
||||
|
||||
#max. Rechnungspositionen
|
||||
if(($gesamt == 0) && ($cttpos_timestamp <= $max_timestamp || $ctt->{int05} == 1) && ($sum_parts19 <= $max_sum)){
|
||||
|
@ -441,25 +425,10 @@ td {
|
|||
$j++;
|
||||
if($j<=$max_table_wc || $break_table_wc){
|
||||
|
||||
|
||||
my $rabatt_val = $cttpos->{$id}->{int07} || "";
|
||||
if($rabatt_val != 0 && looks_like_number($einzel) && $einzel != 0 && looks_like_number($menge) && $menge != 0){
|
||||
my $rabatt_eur = $rabatt_val;
|
||||
$rabatt_eur = $einzel * $menge * $rabatt_val/100 if($cttpos->{$id}->{int08} != 1);#wenn int08 != 1 alias €
|
||||
$gesamt = $einzel * $menge - $rabatt_eur;
|
||||
}
|
||||
$gesamt = $lb->round($gesamt);
|
||||
$gesamt = $lb->cashme($gesamt);
|
||||
#summieren
|
||||
if("$cttpos->{$id}->{int05}" =~ /\d/){
|
||||
$sum_parts0 += $gesamt if("$cttpos->{$id}->{int05}" == "0");
|
||||
$sum_parts7 += $gesamt if("$cttpos->{$id}->{int05}" == "7");
|
||||
$sum_parts19 += $gesamt if("$cttpos->{$id}->{int05}" >= "16");
|
||||
}else{
|
||||
$sum_parts0 += $gesamt if("$ctf->{txt13}" == "0");
|
||||
$sum_parts7 += $gesamt if("$ctf->{txt13}" == "7");
|
||||
$sum_parts19 += $gesamt if($ctf->{txt13} >= 16);
|
||||
}
|
||||
($gesamt,$rabatt) = $pri->price2calc($cttpos->{$id});
|
||||
$sum_parts19 += $gesamt;
|
||||
$gesamt = $lb->round($gesamt);
|
||||
$gesamt = $lb->cashme($gesamt,",");
|
||||
|
||||
#2. empty loop for sum
|
||||
if($break_table_wc){
|
||||
|
@ -467,13 +436,6 @@ td {
|
|||
next if($j<=$max_table_wc);
|
||||
}
|
||||
|
||||
my ($s_date,$s_dd,$s_mo,$s_yy,$s_hh,$s_mi,$e_date,$e_yy,$e_mo,$e_dd,$e_hh,$e_mi,$times_id);
|
||||
|
||||
#Make date and time
|
||||
if($cttpos->{$id}->{start_time} && $cttpos->{$id}->{end_time}){
|
||||
($s_yy,$s_mo,$s_dd,$s_hh,$s_mi) = $lb->split_date($cttpos->{$id}->{start_time});
|
||||
($e_yy,$e_mo,$e_dd,$e_hh,$e_mi) = $lb->split_date($cttpos->{$id}->{end_time});
|
||||
}
|
||||
|
||||
#Tablecontent (parameter)
|
||||
print $q->Tr(),"\n";
|
||||
|
@ -481,9 +443,6 @@ td {
|
|||
foreach (@tpl_order){
|
||||
#$k++;
|
||||
my ($key,$val) = split /=/,$_;
|
||||
#if($cttpos->{$id}->{sort} =~ /^\d+$/){
|
||||
# $txtstyle = "border-bottom-width:1px;border-bottom-style:dotted;border-bottom-color:silver;";
|
||||
#}
|
||||
$cttpos->{$id}->{$key} = $q->unescapeHTML("$cttpos->{$id}->{$key}");
|
||||
$cttpos->{$id}->{$key} = $lb->newline($cttpos->{$id}->{$key},"");
|
||||
if("$key" eq "ct_name"){
|
||||
|
@ -502,31 +461,40 @@ td {
|
|||
$cttpos->{$id}->{$key} =~ s/\<br \/\>/; /g;
|
||||
print "$cttpos->{$id}->{$key}<br />\n";
|
||||
}
|
||||
#if($cttpos->{$id}->{int04}){
|
||||
# print $q->span("Station: $cttpos->{$id}->{int04}"),"\n";
|
||||
#}
|
||||
#if($cttpos->{$id}->{txt06}){
|
||||
# print $q->span(" (GPS: $cttpos->{$id}->{txt06})"),"\n";
|
||||
#}
|
||||
if($cttpos->{$id}->{start_time}){
|
||||
if($cttpos->{$id}->{start_time} && $cttpos->{$id}->{end_time}){
|
||||
#print "<br />\n";
|
||||
print $q->span("Mietzeit: $s_dd.$s_mo.$s_yy $s_hh:$s_mi – $e_dd.$e_mo.$e_yy $e_hh:$e_mi"),"\n";
|
||||
$cttpos->{$id}->{start_time} = $lb->time4de($cttpos->{$id}->{start_time},"1");
|
||||
$cttpos->{$id}->{end_time} = $lb->time4de($cttpos->{$id}->{end_time},"1");
|
||||
|
||||
print $q->span("Mietzeit: $cttpos->{$id}->{start_time} – $cttpos->{$id}->{end_time}"),"\n";
|
||||
}
|
||||
print "</td>\n";
|
||||
}
|
||||
|
||||
if($key eq "int26"){
|
||||
my $co2saving = "";
|
||||
if($cttpos->{$id}->{int26}){
|
||||
$co2saving = "Einsparung</br>";
|
||||
my $co2diff = $pri->co2calc($cttpos->{$id});
|
||||
my $sprit_price = $pri->sprit2calc($cttpos->{$id});
|
||||
$co2saving .= "$co2diff kg CO²<br />";
|
||||
$co2saving .= "$sprit_price EUR<br />";
|
||||
$cttpos->{$id}->{int26} =~ s/\./,/;
|
||||
$co2saving .= "bei $cttpos->{$id}->{int26} KM";
|
||||
}
|
||||
print $q->td({-class=>'tdint'},"$co2saving");
|
||||
}
|
||||
if($key =~ /int03/){
|
||||
$menge =~ s/\./,/;
|
||||
print $q->td({-class=>'tdint'},"$menge"),"\n";
|
||||
$cttpos->{$id}->{$key} =~ s/\./,/;
|
||||
print $q->td({-class=>'tdint'},"$cttpos->{$id}->{$key}"),"\n";
|
||||
}
|
||||
|
||||
if($key =~ /int02/){
|
||||
if($einzel == "0"){
|
||||
$einzel="";
|
||||
if($cttpos->{$id}->{$key} == "0"){
|
||||
$cttpos->{$id}->{$key}="";
|
||||
}else{
|
||||
$einzel =~ s/\./,/;
|
||||
$cttpos->{$id}->{$key} =~ s/\./,/;
|
||||
}
|
||||
print $q->td({-nowrap=>'1',-class=>'tdint'},"$einzel"),"\n";
|
||||
print $q->td({-nowrap=>'1',-class=>'tdint'},"$cttpos->{$id}->{$key}"),"\n";
|
||||
}
|
||||
|
||||
if($key =~ /int04/){
|
||||
|
@ -536,11 +504,10 @@ td {
|
|||
$gesamt .= " €";
|
||||
$gesamt =~ s/\./,/;
|
||||
}
|
||||
#if($rabatt_val != 0 && $gesamt != 0){
|
||||
if($rabatt_val != 0){
|
||||
if($rabatt != 0){
|
||||
my $proz="%";
|
||||
$proz = "€" if($cttpos->{$id}->{int08} == 1);
|
||||
print $q->td({-nowrap=>'1',-class=>'tdint'},"(Rabatt $rabatt_val $proz) $gesamt"),"\n";
|
||||
print $q->td({-nowrap=>'1',-class=>'tdint'},"(Rabatt $rabatt $proz) $gesamt"),"\n";
|
||||
}else{
|
||||
print $q->td({-nowrap=>'1',-class=>'tdint'},"$gesamt"),"\n";
|
||||
}
|
||||
|
@ -569,34 +536,24 @@ td {
|
|||
}
|
||||
|
||||
|
||||
my $diff7 = 100 + 7;
|
||||
my $diff19 = 100 + $umst1619;
|
||||
my $sum_umst7 = $sum_parts7 / $diff7 * 7;
|
||||
my $sum_umst19 = $sum_parts19 / $diff19 * $umst1619;
|
||||
$sum_umst7 = $lb->round($sum_umst7);
|
||||
my $diff19 = 100 + 19;
|
||||
my $sum_umst19 = $sum_parts19 / $diff19 * 19;
|
||||
$sum_umst19 = $lb->round($sum_umst19);
|
||||
my $sum_netto7 = $sum_parts7 - $sum_umst7;
|
||||
my $sum_netto19 = $sum_parts19 - $sum_umst19;
|
||||
$sum_netto7 = $lb->cashme($sum_netto7);
|
||||
$sum_netto19 = $lb->cashme($sum_netto19);
|
||||
my $sum_nettoall = $sum_parts0 + $sum_netto7 + $sum_netto19;
|
||||
my $sum_nettoall = $sum_netto19;
|
||||
$sum_nettoall = $lb->cashme($sum_nettoall,",");
|
||||
my $sum_paid = $sum_parts0 + $sum_parts7 + $sum_parts19;
|
||||
$sum_parts0 = $lb->cashme($sum_parts0,",");
|
||||
$sum_parts7 = $lb->cashme($sum_parts7,",");
|
||||
my $sum_paid = $sum_parts19;
|
||||
$sum_parts19 = $lb->cashme($sum_parts19,",");
|
||||
$sum_umst7 = $lb->cashme($sum_umst7,",");
|
||||
$sum_umst19 = $lb->cashme($sum_umst19,",");
|
||||
$sum_paid = $lb->cashme($sum_paid,",");
|
||||
|
||||
|
||||
if($ctt->{txt00} !~ /Lieferschein/){
|
||||
|
||||
print $q->Tr(),"\n";
|
||||
print $q->td({-class=>'Oline',-colspan=>5}," "),"\n";
|
||||
print $q->td({-class=>'Oline',-colspan=>6}," "),"\n";
|
||||
|
||||
print "<tr>\n";
|
||||
print "<td colspan='2' style='border:0px solid silver;vertical-align:top;padding:0.2em 0.5em;font-size:1em;'>$payment_text</td>\n";
|
||||
print "<td colspan='3' style='border:0px solid silver;vertical-align:top;padding:0.2em 0.5em;font-size:1em;'>$payment_text</td>\n";
|
||||
print "<td colspan='3' style='font-size:1em;'>\n";
|
||||
print $q->start_table({-style=>'border:1px solid silver;', -border=>'0', -width=>'100%',-align=>'center', -cellpadding=>'3', -cellspacing=>'0'}),"\n";
|
||||
|
||||
|
@ -612,19 +569,9 @@ td {
|
|||
print $q->Tr(),"\n";
|
||||
print $q->td({-class=>'tdint'},"Betrag Netto:"),"\n";
|
||||
print $q->td({-class=>'tdint',-nowrap=>"1"},"$sum_nettoall €"),"\n";
|
||||
if($sum_parts0 != "0"){
|
||||
print $q->Tr(),"\n";
|
||||
print $q->td({-class=>'tdint',-nowrap=>"1"},"0% UmSt auf $sum_parts0 €:"),"\n";
|
||||
print $q->td({-class=>'tdint',-nowrap=>"1"},"0,00 €"),"\n";
|
||||
}
|
||||
if($sum_netto7 != "0"){
|
||||
print $q->Tr(),"\n";
|
||||
print $q->td({-class=>'tdint',-nowrap=>"1"},"7% UmSt auf $sum_netto7 €:"),"\n";
|
||||
print $q->td({-class=>'tdint',-nowrap=>"1"},"$sum_umst7 €"),"\n";
|
||||
}
|
||||
if($sum_parts19 != "0"){
|
||||
print $q->Tr();
|
||||
print $q->td({-class=>'tdint',-nowrap=>"1"},"$umst1619% UmSt auf $sum_netto19 €:"),"\n";
|
||||
print $q->td({-class=>'tdint',-nowrap=>"1"},"19% UmSt auf $sum_netto19 €:"),"\n";
|
||||
print $q->td({-class=>'tdint',-nowrap=>"1"},"$sum_umst19 €"),"\n";
|
||||
}
|
||||
}
|
||||
|
@ -639,7 +586,6 @@ td {
|
|||
print $q->end_table,"\n";
|
||||
print "</td>\n";
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
print $q->end_table,"\n";
|
||||
print "</div>\n";
|
||||
|
@ -648,7 +594,7 @@ td {
|
|||
|
||||
#Beschreibungs-Text
|
||||
sub text_description(){
|
||||
my ($h_top,$mandant_main_id,$ctt_txt21,$ctt_txt12,$kind_of_trans,$node_name,$nullcount) = @_;
|
||||
my ($h_top,$mandant_main_id,$ctt_txt21,$ctt_txt12,$node_name,$nullcount) = @_;
|
||||
my $ctf = $db->get_content1("contentuser","$mandant_main_id");
|
||||
my $position;
|
||||
my $h_toppx = "$h_top" . "px";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue