-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from dtrai2/2-create-config-class
create config class with automatic validation
- Loading branch information
Showing
8 changed files
with
103 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,47 +13,15 @@ pip install shiny-invoice | |
``` | ||
|
||
Once `shiny-invoice` is installed you need to create configuration file. | ||
A suitable example looks like this: | ||
|
||
```yaml | ||
paths: | ||
invoices_dir: /home/user/invoices/ # must be an absolute path, and it needs to end with / | ||
html_template: shiny_invoice/templates/default_en.html | ||
datastore: datastore.json | ||
company: # here you can specify details of your company | ||
name: Company Name | ||
skills: | ||
- Primary Skill | ||
- Secondary Skill | ||
address: | ||
- Address line 1 | ||
- 4234 Addresline2 | ||
contact: | ||
- [email protected] | ||
- +49 123 456789 | ||
- shinyinvoice.de | ||
bank: | ||
name: SomeBank | ||
iban: DE12 1234 5678 9100 00 | ||
bic: BICCCCCCC | ||
tax_number: 11/2222/3333 | ||
tax_rate: 0.19 | ||
payment_terms_days: 14 | ||
invoice_defaults: # here you can set defaults, which will be used to prefill the invoice formular | ||
introduction: Dear Sir or Madam, | ||
recipient: |- | ||
Comp 2 | ||
Compstreet Comp | ||
1335 Compvill | ||
items: | | ||
Services, Hours, Rate, Price | ||
Service 1, 40h, 100 €, 4.000 € | ||
A suitable default configuration can be generated with | ||
```bash | ||
shiny-invoice generate-default-config | ||
``` | ||
|
||
Once everything is set up you can run `shiny-invoice` with: | ||
|
||
```bash | ||
shiny-invoice run --config config.yaml | ||
shiny-invoice run --config default_config.yaml | ||
``` | ||
|
||
More information you can find with | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
"""This module contains the definition of the configurations and the respecting default values""" | ||
|
||
from typing import List | ||
|
||
from pydantic import BaseModel, PositiveInt | ||
|
||
|
||
class PathConfig(BaseModel): | ||
"""Config values for different resources""" | ||
|
||
invoices_dir: str = "/home/user/invoices/" | ||
html_template: str = "shiny_invoice/templates/default_en.html" | ||
datastore: str = "datastore.json" | ||
|
||
|
||
class BankConfig(BaseModel): | ||
"""Configuration of bank details""" | ||
|
||
name: str = "Some Bank" | ||
iban: str = "DE12 1234 5678 9100 00" | ||
bic: str = "BICCCCCCC" | ||
tax_number: str = "11/2222/3333" | ||
|
||
|
||
class CompanyConfig(BaseModel): | ||
"""Configuration of company details""" | ||
|
||
name: str = "Company Name" | ||
skills: List[str] = ["Primary Skill", "Secondary Skill"] | ||
address: List[str] = ["Address line 1", "4234 Addressline 2"] | ||
contact: List[str] = ["[email protected]", "+49 123 456789", "shinyinvoice.de"] | ||
bank: BankConfig = BankConfig() | ||
tax_rate: float = 0.19 | ||
payment_terms_days: PositiveInt = 14 | ||
|
||
|
||
class InvoiceDefaultsConfig(BaseModel): | ||
"""Configuration of invoice defaults that should be rendered in the invoice""" | ||
|
||
introduction: str = "Dear Sir or Madam," | ||
recipient: str = "Comp 2\nCompstreet Comp\n1335 Compvill" | ||
items: str = "Services, Hours, Rate, Price\nService 1, 40h, 100 €, 4.000 €" | ||
|
||
|
||
class Config(BaseModel): | ||
"""Shiny-Invoice configuration""" | ||
|
||
paths: PathConfig = PathConfig() | ||
company: CompanyConfig = CompanyConfig() | ||
invoice_defaults: InvoiceDefaultsConfig = InvoiceDefaultsConfig() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters