maaslalani / invoice

Command line invoice generator
MIT License
1.83k stars 80 forks source link

How to? #9

Closed se7en-x230 closed 1 year ago

se7en-x230 commented 1 year ago
  1. How would I include a address with several lines?

  2. How could I add a currency? DONE I see the file and would add the currency + symbol but how would I compile it with the additional currency? Recompiled it with my currency added and set as default. All good.

  3. Also --date "June 10, 2023" does not print the date on the invoice. Would it be possible to add the current date without typing it on the invoice? Something like --date current or similar even better set it in env?

se7en-x230 commented 1 year ago

Some changes you made make it impossible to compile.

shop-2023-06-27-11-30

go version go1.20.5 linux/amd64 arch linux

maaslalani commented 1 year ago
image

Hey @se7en-x230, I'm not able to reproduce. Can you try the following:

go clean -modcache -cache
go install .
se7en-x230 commented 1 year ago

Thanks go clean -modcache -cache Did work

se7en-x230 commented 1 year ago

I use dmenu to collect the infos like --to --date --item ...
Fast, easy and the result looks good.

shop-2023-06-27-19-52

Thanks

maaslalani commented 1 year ago

Thanks, I will eventually add support for multiline From and To fields it will likely look something along the lines of:

invoice generate --from "Name<br>Address<br>Zip Code<br>City, State"

or

invoice generate --from "Name\nAddress\nZip Code\nCity, State"
maaslalani commented 1 year ago

You might also like gum for collecting the infos:

https://github.com/charmbracelet/gum

akyag commented 1 year ago

I am trying to add common options to json. How do I add multiple items with different quantity/prices to the json?

dvrd commented 1 year ago

@se7en-x230 you can do something like this in pdf.go

func writeNotes(pdf *gopdf.GoPdf, notes string) {
    pdf.SetY(650)

    _ = pdf.SetFont("Inter", "", 10)
    pdf.SetTextColor(55, 55, 55)
    _ = pdf.Cell(nil, "Notes")
    pdf.Br(18)
    _ = pdf.SetFont("Inter", "", 8)
    pdf.SetTextColor(0, 0, 0)

    notesArr := strings.Split(notes, "\\n")

    for i := 0; i < len(notesArr); i++ {
        _ = pdf.Cell(nil, notesArr[i])
        pdf.Br(15)
    }
    pdf.Br(48)
}
se7en-x230 commented 1 year ago

SOLVED!

shop-2023-06-29-08-30

./pdf.go:103:14: undefined: strings

shop-2023-06-29-08-07

se7en-x230 commented 1 year ago

works fine

--from --to and --notes should have the possibility for multiple lines

maaslalani commented 1 year ago

I am trying to add common options to json. How do I add multiple items with different quantity/prices to the json?

@akyag You can do something like the following:

{
    "items": ["Item 1", "Item 2", "Item 3"],
    "rates": [1, 2, 3],
    "quantities": [1, 2, 3]
}
invoice generate --import <file>.json
piotryordanov commented 1 year ago

can the notes section be multiline? I'm trying to add wire info toit, and it gets all on a single line instead of multi-line.

I tried adding both <br/> and \\n and \n but nothing seems to do the job

dvrd commented 1 year ago

@piotryordanov I just made a PR to fix it, it's an issue with an extra escape character

piotryordanov commented 1 year ago

@dvrd awesome! Please let me know when this gets merged