add support for printing addresses in invoices
This commit is contained in:
parent
83047ea410
commit
c81ac0c2cf
13
invoice.rb
13
invoice.rb
|
@ -35,9 +35,10 @@ Product = Struct.new(:id, :description, :price) do
|
|||
end
|
||||
|
||||
class Person
|
||||
def initialize(id, name)
|
||||
def initialize(id, name, address)
|
||||
@id = id
|
||||
@name = name
|
||||
@address = address
|
||||
@purchases = {}
|
||||
end
|
||||
|
||||
|
@ -46,7 +47,7 @@ class Person
|
|||
end
|
||||
|
||||
attr_reader :id
|
||||
attr_accessor :name, :purchases
|
||||
attr_accessor :name, :purchases, :address
|
||||
end
|
||||
|
||||
def read_file(file)
|
||||
|
@ -76,7 +77,11 @@ end
|
|||
def load_persons_from_db(db)
|
||||
persons = {}
|
||||
db.query("SELECT * FROM Persons").each do |row|
|
||||
person = Person.new(row['id'],row['name'])
|
||||
address = []
|
||||
if (row['address'])
|
||||
address << row['address']
|
||||
end
|
||||
person = Person.new(row['id'],row['name'],address)
|
||||
persons[row['id']] = person
|
||||
if Options[:verbose]
|
||||
puts "Found person: #{person}"
|
||||
|
@ -130,7 +135,7 @@ def generate_receipt(persons,products,db,draft)
|
|||
total_payment = 0
|
||||
|
||||
yaml = YAML_BASE.clone
|
||||
yaml["to"] = person.name
|
||||
yaml["to"] = [person.name].concat person.address
|
||||
yaml["invoice-nr"] = Time.now.strftime('%Y%W') + "-" + counter.to_s
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user