]> git.plutz.net Git - invoices/blobdiff - odtgen.sh
sort invoice list, newest to oldest
[invoices] / odtgen.sh
index 67232a9659cfcda9e465712ec51a9d6edde8634b..abed2db2028e43f153aee28ec1d4f2701e8000f0 100755 (executable)
--- a/odtgen.sh
+++ b/odtgen.sh
@@ -72,14 +72,17 @@ odt_content(){
              <style:table-properties style:width="6.7in" fo:margin-top="0in" fo:margin-bottom="0in" table:align="margins"/>
            </style:style>
            <style:style style:name="Table1.A" style:family="table-column">
-             <style:table-column-properties style:column-width="1.1in" style:rel-column-width="11000*"/>
+             <style:table-column-properties style:column-width="1.2in" style:rel-column-width="12000*"/>
            </style:style>
            <style:style style:name="Table1.B" style:family="table-column">
              <style:table-column-properties style:column-width="3.4in" style:rel-column-width="34000*"/>
            </style:style>
-           <style:style style:name="Table1.CD" style:family="table-column">
+           <style:style style:name="Table1.C" style:family="table-column">
              <style:table-column-properties style:column-width="1.1in" style:rel-column-width="11000*"/>
            </style:style>
+           <style:style style:name="Table1.D" style:family="table-column">
+             <style:table-column-properties style:column-width="1.0in" style:rel-column-width="10000*"/>
+           </style:style>
            <style:style style:name="Table1.1" style:family="table-cell">
              <style:table-cell-properties fo:padding="0.0201in" fo:border-left="none" fo:border-right="none" fo:border-top="none" fo:border-bottom="0.05pt solid #000000"/>
            </style:style>
@@ -92,6 +95,10 @@ odt_content(){
            <style:style style:name="P3" style:family="paragraph" style:parent-style-name="Standard">
              <style:text-properties style:font-name="DejaVu Sans" fo:font-size="10.5pt" style:font-size-asian="10.5pt" style:font-size-complex="10.5pt"/>
            </style:style>
+           <style:style style:name="P4" style:family="paragraph" style:parent-style-name="Standard">
+             <style:paragraph-properties fo:text-align="end" style:justify-single-word="false"/>
+             <style:text-properties style:font-name="DejaVu Sans" fo:font-size="10.5pt" style:font-size-asian="10.5pt" style:font-size-complex="10.5pt"/>
+           </style:style>
            <style:style style:name="P5" style:family="paragraph" style:parent-style-name="Standard">
              <style:paragraph-properties fo:text-align="end" style:justify-single-word="false"/>
              <style:text-properties fo:font-size="10.5pt" style:font-size-asian="10.5pt" style:font-size-complex="10.5pt"/>
@@ -152,8 +159,8 @@ odt_content(){
              <table:table table:name="Table1" table:style-name="Table1">
                <table:table-column table:style-name="Table1.A"/>
                <table:table-column table:style-name="Table1.B"/>
-               <table:table-column table:style-name="Table1.CD"/>
-               <table:table-column table:style-name="Table1.CD"/>
+               <table:table-column table:style-name="Table1.C"/>
+               <table:table-column table:style-name="Table1.D"/>
                <table:table-header-rows>
                  <table:table-row>
                    <table:table-cell table:style-name="Table1.1" office:value-type="string">
@@ -171,22 +178,28 @@ odt_content(){
                  </table:table-row>
                </table:table-header-rows>
                $(sed 1d "invoices/$id" |while read -r time work hours; do
-                   time="$(UNSTRING "${time#time=}")"
-                   work="$(UNSTRING "${work#work=}")"
+                   time="$(UNSTRING "${time#time=}" |sed -r 's;(&#13\;)?&#10\;|(&#x0?[Dd]\;)?&#x0?[aA]\;|\r?$;<text:line-break/>;g')"
+                   work="$(UNSTRING "${work#work=}" |sed -r 's;(&#13\;)?&#10\;|(&#x0?[Dd]\;)?&#x0?[aA]\;|\r?$;<text:line-break/>;g')"
                   hours="$(UNSTRING "${hours#hours=}")"
                  cat <<-TROW
                        <table:table-row>
                          <table:table-cell table:style-name="Table1.2" office:value-type="string">
-                           <text:p text:style-name="P3">${time}</text:p>
+                           <text:p text:style-name="P4">${time} </text:p>
                          </table:table-cell>
                          <table:table-cell table:style-name="Table1.2" office:value-type="string">
                            <text:p text:style-name="P3">${work}</text:p>
                          </table:table-cell>
                          <table:table-cell table:style-name="Table1.2" office:value-type="string">
-                           <text:p text:style-name="P5">${hours}</text:p>
+                           <text:p text:style-name="P5">$( awk "BEGIN { 
+                                                                 if ( int(${hours}) == ${hours} ) 
+                                                                    printf \"%i\", ${hours};
+                                                                 else
+                                                                    printf \"%i:%i\", int(${hours}), int((${hours} - int(${hours})) * 60);
+                                                                 }"
+                                                           )</text:p>
                          </table:table-cell>
                          <table:table-cell table:style-name="Table1.2" office:value-type="string">
-                           <text:p text:style-name="P5">$((${hourly} * ${hours})) €</text:p>
+                           <text:p text:style-name="P5">$(awk "BEGIN { printf \"%.2f\", ${hourly} * ${hours}; }" ) €</text:p>
                          </table:table-cell>
                        </table:table-row>
                        TROW