示例#1
0
def step1():
    print('''Welcome to the data wizard!
In step-by-step process, you will be able to build the configuration files.
Type:
1. To create owner data.
2. To create client data.
3. To generate sample data.
4. To change settings.
5. To exit.
Any other key to exit.
Select option:''')

    user_input = Getch().__call__()

    if user_input == '1':
        createOwner()
    elif user_input == '2':
        createClient()
    elif user_input == '3':
        owner = Owner(
            'Sample Owner Company',
            Address('43-190', 'Mikołów', street='Fajna', house_number='77'),
            1111111111,
            Account('Cool bank', '33 5555 5555 5555 5555 5555 5555', "123",
                    "Przelew"))

        client = Client(
            'Sample client company',
            Address('43-190', 'Mikołów', street='Fajna', house_number='77'),
            2222222222, 60, 'templatePL', 14)

        deliver_to = Client(
            'Sample deliver company',
            Address('43-190', 'Mikołów', street='Not Cool', house_number='66'),
            3333333333, 20, None, 0)

        create(Settings.owner_file('owner.json'), owner)
        create(Settings.client_file('client.json'), client)
        create(Settings.client_file('delivery.json'), deliver_to)
        print('Created sample clients!')
    elif user_input == '4':
        change_settings(Settings.get())
    elif user_input == '5':
        exit()
    else:
        clear()
        step1()
示例#2
0
import sys

from utils.htmlToPdf import generate_pdf
from utils.json_helper import Json
from utils.models import Invoice
from utils.settings import Settings

# region script
parser = argparse.ArgumentParser()
parser.add_argument("owner", help="The seller of products issued on the invoice.", type=str)
parser.add_argument("client", help="The receiver of the products issued on the invoice.", type=str)
parser.add_argument("amount", help="The amount of the service in invoice.", type=str)
parser.add_argument("--delivery", help="The company's that is receiving the delivery of the invoice.", type=str)
arguments = parser.parse_args()

with open(Settings.owner_file("{}.json".format(arguments.owner)), 'r') as new_file:
    owner = json.loads(new_file.read().decode('utf-8'), object_hook=Json)

with open(Settings.client_file("{}.json".format(arguments.client)), 'r') as new_file:
    client = json.loads(new_file.read().decode('utf-8'), object_hook=Json)

invoice = Invoice(owner, client, arguments.amount, None)

# jpk.generate(owner)

with open("templates/{}.html".format(client.template), 'r') as htmlInput:
    html = htmlInput.read().decode('utf-8').format(**invoice.asFormatter())

    shutil.copyfile('templates/pdf.css', os.path.join(Settings.output_dir(), 'pdf.css'))
    with open(os.path.join(Settings.output_dir(), 'fakturka.html'), 'w') as htmlOutput:
        htmlOutput.write(html.encode('utf-8'))
示例#3
0
def createOwner():
    clear()

    name = raw_input("Nazwa firmy: ")

    street = raw_input("Ulica: ")

    house_number = raw_input("Numer domu: ")

    flat_number = raw_input("Numer mieszkania: ")

    provinces = DB().get_province_list()
    for province in DB().get_province_list():
        print u'{}'.format(province.__str__().decode("utf-8"))
    print u'Podaj numer województwa:',
    province = provinces[int(raw_input()) - 1]
    print u'Wybrano: {}'.format(province.name)

    print u'Wyszukaj miejscowość: ',
    cities = db.search_city(province, raw_input())
    if len(cities) > 1:
        print u'Znaleziono więcej miast, wybierz jedno z poniższych: '
        for i, city in enumerate(cities):
            print u'{}. {}'.format(i + 1, city.as_string())
        print u'Wybierz miejscowość: ',
        city = cities[int(raw_input()) - 1]
        print u'Wybrano: {}, {}'.format(city.city, city.commune)
    else:
        city = cities[0]
        print u'Znaleziono: {}'.format(city.city)
    province_id = province.id
    province = city.province
    district = city.district
    commune = city.city
    city = city.city

    postal = raw_input("Kod pocztowy: ")

    nip = raw_input("NIP/VAT ID: ")

    troublemaker = raw_input(
        "Wpisz miasto urzedu skarbowego (puste, jesli to samo co wyzej): ")
    if len(troublemaker) == 0:
        troublemaker = city
    troublemaker = db.search_for_trouble(province_id, troublemaker)
    if len(troublemaker) > 1:
        print u'Znaleziono więcej urzędów, wybierz jeden z poniższych: '
        for i, x in enumerate(troublemaker):
            print u'{}. {}'.format(i + 1, x[1])
        print u'Wybierz urząd:',
        troublemaker = troublemaker[int(raw_input()) - 1]
        print u'Wybrano: {}'.format(troublemaker[1])
    else:
        troublemaker = troublemaker[0]
        print u'Znaleziono: {}'.format(troublemaker[1])
    troublemaker = troublemaker[0]

    bank_name = raw_input("Nazwa banku: ")

    account = raw_input("Numer konta: ")

    swift = raw_input("Numer SWIFT (tylko FVAT UE, PL puste):")

    print('''Numerowanie faktur:
1. Roczne
2. Miesieczne''')

    annual_number = Getch().__call__() == '1'

    transfer = "Przelew"

    save_name = raw_input("Nazwa (nazwa pliku, bez spacji): ")
    create(
        Settings.owner_file(u'{}.json'.format(save_name)),
        Owner(name,
              Address(postal, city, province, district, commune, street,
                      house_number, flat_number),
              nip,
              gov_code=troublemaker,
              annual_number=annual_number,
              account=Account(bank_name, account, swift, transfer)))
    clear()
    print("Owner {} utworzony".format(save_name))
    step1()