示例#1
0
def createClient():
    clear()
    name = raw_input("Nazwa firmy klienta: ")
    street = raw_input("Ulica: ")
    house_number = raw_input("Numer domu: ")
    city = raw_input("Miasto: ")
    postal = raw_input("Kod pocztowy: ")
    nip = raw_input("NIP/VAT ID: ")
    rate = raw_input("Stawka godzinowa: ")
    currency = raw_input("Waluta: ")
    payment_delay = raw_input("Termin platnosci w dniach: ")
    template = raw_input("Wzor (html bez rozszerzenia): ")
    save_name = raw_input("Nazwa (bez spacji): ")
    print('''Data na fakturze:
1. Ostatni dzien roboczy poprzedniego miesiaca
2. Pierwszy dzien roboczy obecnego miesiaca
3. Dzien generowania faktury''')
    date_day = Getch().__call__()
    if date_day == '1':
        date_day = 0
    elif date_day == '2':
        date_day = 1
    else:
        date_day = 2
    create(
        Settings.client_file('{}.json'.format(save_name)),
        Client(name,
               Address(postal, city, street=street, house_number=house_number),
               nip, rate, template, payment_delay, currency, date_day))
    clear()
    print("Klient {} utworzony".format(save_name))
    step1()
示例#2
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()
示例#3
0
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'))

    print os.path.dirname(os.path.abspath(sys.argv[0]))