updated stuff
This commit is contained in:
parent
0133798ba6
commit
3d18dc16e0
|
@ -105,7 +105,7 @@ $for(to)$
|
|||
$to$\\
|
||||
$endfor$
|
||||
|
||||
\vspace{6em}
|
||||
%\vspace{6em}
|
||||
|
||||
\begin{flushright}
|
||||
\small
|
||||
|
@ -122,18 +122,18 @@ $endfor$
|
|||
\STautoround*{2} % Get spreadtab to always display the decimal part
|
||||
$if(commasep)$\STsetdecimalsep{,}$endif$ % Use comma as decimal separator
|
||||
|
||||
\begin{spreadtab}{{tabular}[t t t]{lp{8.2cm}r}}
|
||||
\begin{spreadtab}{{tabular}[t t t t]{lp{7.2cm}cr}}
|
||||
\hdashline[1pt/1pt]
|
||||
@ \noalign{\vskip 2mm} \textbf{\#} & @ \textbf{Produkt} & @ \textbf{Priser i $currency$} \\ \hline
|
||||
@ \noalign{\vskip 2mm} \textbf{\#} & @ \textbf{Produkt} & @ \textbf{Antal} & @ \textbf{Priser i $currency$} \\ \hline
|
||||
$for(service)$ @ \noalign{\vskip 2mm} \refstepcounter{pos} \thepos
|
||||
& @ $service.description$
|
||||
$if(service.details)$\newline \begin{itemize}
|
||||
$for(service.details)$\scriptsize \item $service.details$
|
||||
$endfor$ \end{itemize}
|
||||
$endif$ & $service.price$\\$endfor$ \noalign{\vskip 2mm} \hline
|
||||
@ & @ \multicolumn{1}{r}{Subtotal:} & :={sum(c1:[0,-1])} \\ \hhline{~~-}
|
||||
@ & @ \multicolumn{1}{r}{Rabat fra kantinekort (-10\%):} & -(100-90)/100*[0,-1] \\ \hhline{~~-}
|
||||
@ & @ \multicolumn{1}{r}{\textbf{Total:}} & \textbf{:={[0,-2]+[0,-1]}} \\ \hhline{~~-}
|
||||
$endif$ & $service.amount$ & $service.price$\\$endfor$ \noalign{\vskip 2mm} \hline
|
||||
@ & @ \multicolumn{2}{r}{Subtotal:} & :={sum(d1:[0,-1])} \\ \hhline{~~~-}
|
||||
@ & @ \multicolumn{2}{r}{Rabat fra kantinekort (-10\%):} & -(100-90)/100*[0,-1] \\ \hhline{~~~-}
|
||||
@ & @ \multicolumn{2}{r}{\textbf{Total:}} & \textbf{:={[0,-2]+[0,-1]}} \\ \hhline{~~~-}
|
||||
\end{spreadtab}
|
||||
|
||||
\vspace{15mm}
|
||||
|
|
46
receipt.rb
46
receipt.rb
|
@ -2,21 +2,19 @@
|
|||
require 'CSV'
|
||||
require 'yaml'
|
||||
|
||||
YAML_BASE = {"invoice-nr" => "2017-01-31", "author": "Christoffer Müller Madsen", 'currency': 'DKK', 'commasep': true, 'lang': 'danish', 'seriffont': 'Hoefler Text', 'sansfont': 'Helvetica Neue', 'fontsize': '10pt', 'geometry': 'a4paper, left=43mm, right=43mm, top=51mm, bottom=17mm', 'closingnote': %Q[Please transfer the due amount to the following bank account within the next 14 days:
|
||||
YAML_BASE = {"author": "Christoffer Müller Madsen", "city": "Aarhus", "from": ["Falstersgade 18, 4. th", "8000 Aarhus C"], 'currency': 'DKK', 'commasep': true, 'lang': 'danish', 'seriffont': 'Hoefler Text', 'sansfont': 'Helvetica Neue', 'fontsize': '10pt', 'geometry': 'a4paper, left=43mm, right=43mm, top=51mm, bottom=17mm', 'closingnote': %Q[Overfør venligst det anførte beløb via MobilePay til følgende telefonnummer i løbet af de næste 14 dage:
|
||||
|
||||
Mustermann GmbH
|
||||
Kreditinstitut: Deutsche Postbank AG
|
||||
IBAN: DE18 3601 0043 9999 9999 99
|
||||
BIC: PBNKDEFF
|
||||
+45 81 73 02 02
|
||||
|
||||
We really appreciate your business and look forward to future projects together.
|
||||
På forhånd tak.
|
||||
|
||||
Best regards,
|
||||
Med venlig hilsen
|
||||
] }
|
||||
|
||||
PATH_BASE = "./pdf/"
|
||||
PRETTY_NAMES = {"papkaffe" => "Papkrus kaffe (0.35 L)", "kage" => "Kage", "spandaur" => "Spandaur"}
|
||||
PRICES = {'papkaffe' => 7, "kage" => 11}
|
||||
PRETTY_PRODUCTS = {"papkaffe" => "Papkrus kaffe (0.35 L)", "kage" => "Kage", "spandaur" => "Spandaur", "kaffekrus" => "Kaffe i krus (0.25 L)"}
|
||||
PRETTY_NAMES = {"Alexander" => "Alexander Munch-Hansen", "Jon" => "Jon Michael Aanes"}
|
||||
PRICES = {'papkaffe' => 7, "kage" => 11, "kaffekrus" => 5}
|
||||
lines = {}
|
||||
|
||||
class LogItem
|
||||
|
@ -29,13 +27,6 @@ class LogItem
|
|||
attr_accessor :time, :person, :product, :amount
|
||||
end
|
||||
|
||||
class LineItem
|
||||
def initialize(type)
|
||||
@type = type
|
||||
end
|
||||
attr_accessor(:type)
|
||||
end
|
||||
|
||||
def read_file(file)
|
||||
rows = Array.new
|
||||
CSV.foreach(file, col_sep: ';', converters: :float) do |row|
|
||||
|
@ -55,22 +46,27 @@ def partition_rows(rows)
|
|||
end
|
||||
|
||||
def generate_receipt(skyldnere)
|
||||
counter = 0
|
||||
skyldnere.each do |person, products|
|
||||
counter += 1
|
||||
yaml = YAML_BASE.clone
|
||||
yaml["to"] = person
|
||||
yaml["to"] = PRETTY_NAMES[person]
|
||||
products.each do |product, amount|
|
||||
yaml["invoice-nr"] = Time.now.strftime('%Y%W') + "-" + counter.to_s
|
||||
yaml["service"] = Array.new unless yaml["service"]
|
||||
hash = {description: PRETTY_NAMES[product], price: PRICES[product]*amount, amount: amount}
|
||||
hash = {description: PRETTY_PRODUCTS[product], price: PRICES[product]*amount, amount: amount}
|
||||
yaml["service"] << Hash[hash.map{ |k, v| [k.to_s, v] }]
|
||||
end
|
||||
puts Hash[yaml.map{ |k, v| [k.to_s, v] }].to_yaml
|
||||
|
||||
output = Hash[yaml.map{ |k, v| [k.to_s, v] }].to_yaml
|
||||
output += "---\n"
|
||||
file = File.open("./pandoc/details.yml","w")
|
||||
file << output
|
||||
file.close
|
||||
`cd pandoc/; make -B`
|
||||
`cp pandoc/output.pdf pdf/#{yaml["invoice-nr"]}.pdf`
|
||||
puts "#{person}: #{yaml["invoice-nr"]}.pdf"
|
||||
end
|
||||
# pdf_path = PATH_BASE + "temp.pdf"
|
||||
|
||||
# return pdf_path
|
||||
end
|
||||
|
||||
partition = partition_rows(read_file("./log/matkant.log"))
|
||||
puts partition.inspect
|
||||
partition = partition_rows(read_file("./log/matkant-#{Time.now.strftime('%Y%W')}.log"))
|
||||
generate_receipt(partition)
|
||||
|
|
Loading…
Reference in New Issue
Block a user