]> git.plutz.net Git - invoices/blobdiff - odtgen.sh
sort invoice list, newest to oldest
[invoices] / odtgen.sh
index 177065a9c9a0fd10f92cba31058aceacc51f1b98..abed2db2028e43f153aee28ec1d4f2701e8000f0 100755 (executable)
--- a/odtgen.sh
+++ b/odtgen.sh
@@ -178,8 +178,8 @@ odt_content(){
                  </table:table-row>
                </table:table-header-rows>
                $(sed 1d "invoices/$id" |while read -r time work hours; do
-                   time="$(UNSTRING "${time#time=}" |sed 's;\r;<text:line-break/>;g')"
-                   work="$(UNSTRING "${work#work=}" |sed 's;\r;<text:line-break/>;g')"
+                   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>
@@ -190,10 +190,16 @@ odt_content(){
                            <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