Skip to content

Commit

Permalink
feat: ✨ im done
Browse files Browse the repository at this point in the history
  • Loading branch information
dfrnoch committed Aug 12, 2024
1 parent f53d6c2 commit 1314fce
Show file tree
Hide file tree
Showing 14 changed files with 364 additions and 43 deletions.
6 changes: 3 additions & 3 deletions src-tauri/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ model Settings {
defaultTemplateId Int
// tax Float
invoicePrefix String @default("I202400000")
invoicePrefix String @default("I{FULL_YEAR}XXX")
invoiceCounter Int @default(0)
proformaPrefix String @default("P")
proformaPrefix String @default("P{FULL_YEAR}XXX")
proformaCounter Int @default(0)
receivePrefix String @default("R")
receivePrefix String @default("R{FULL_YEAR}XXX")
receiveCounter Int @default(0)
}

Expand Down
8 changes: 3 additions & 5 deletions src-tauri/src/commands/company.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ pub struct ManageCompanyData {
bank_iban: Option<String>,
new_password: Option<String>,
old_password: Option<String>,
template_code: Option<String>,
}

#[tauri::command]
Expand Down Expand Up @@ -160,11 +161,8 @@ pub async fn create_company(
let template = client
.template()
.create(
"Default Invoice".to_string(),
"
TODO
"
.to_string(),
"Invoice Template".to_string(),
data.template_code.unwrap_or("default".to_string()),
company::id::equals(company.id),
vec![],
)
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"title": "Accounting",
"width": 900,
"height": 600,
"minWidth": 800,
"minWidth": 900,
"minHeight": 550,
"transparent": true,
"titleBarStyle": "Overlay",
Expand Down
1 change: 1 addition & 0 deletions src/bindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ export type ManageCompanyData = {
newPassword?: string;
oldPassword?: string;
passwordConfirmation?: string;
templateCode?: string;
};

export interface Document {
Expand Down
260 changes: 258 additions & 2 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export enum LANG {
EN = "en-US",
CS = "cs-CZ",
CZ = "cs-CZ",
}

export const templatesHtml = {
cz: [
en: [
{
id: 1,
code: `<div class="bg-white p-8">
Expand Down Expand Up @@ -254,6 +254,262 @@ export const templatesHtml = {
<p>Thanks for the business.</p>
</div>
<div class="mt-8 text-center text-sm text-gray-600">
<p>{{ company.email }} | {{ company.phone }}</p>
</div>
</div>`,
},
],
cz: [
{
id: 1,
code: `<div class="bg-white p-8">
<div class="mb-8 flex justify-between">
<div>
<h1 class="text-2xl font-bold">{{ company.name }}</h1>
<p>{{ company.website }}</p>
<p>{{ company.email }}</p>
<p>{{ company.phone }}</p>
</div>
<div class="text-right">
<p>{{ company.address }}</p>
<p>{{ company.city }}, {{ company.state }} - {{ company.zip }}</p>
<p>DIČ {{ company.vatId }}</p>
</div>
</div>
<div class="mb-8 flex justify-between">
<div>
<h2 class="mb-2 font-bold">Fakturováno</h2>
<p>{{ client.name }}</p>
<p>{{ client.address }}</p>
<p>{{ client.city }}, {{ client.country }} - {{ client.zip }}</p>
<p>{{ client.phone }}</p>
</div>
<div class="text-right">
<div class="mb-4">
<h2 class="font-bold">Číslo faktury</h2>
<p>{{ number }}</p>
</div>
<div>
<h2 class="font-bold">Reference</h2>
<p>FAK-057</p>
</div>
</div>
</div>
<div class="mb-8 flex justify-between">
<div>
<h2 class="mb-2 font-bold">Předmět</h2>
<p>{{ subject }}</p>
</div>
<div class="text-right">
<h2 class="text-3xl font-bold text-orange-500">{{ items | map: 'price' | sum }} {{ currency.code }}</h2>
</div>
</div>
<div class="mb-8 flex justify-between">
<div>
<h2 class="font-bold">Datum vystavení</h2>
<p>{{ issueDate }}</p>
</div>
<div class="text-right">
<h2 class="font-bold">Datum splatnosti</h2>
<p>{{ dueDate }}</p>
</div>
</div>
<table class="mb-8 w-full">
<thead>
<tr class="bg-gray-100">
<th class="px-4 py-2 text-left">POPIS POLOŽKY</th>
<th class="px-4 py-2 text-right">MNOŽSTVÍ</th>
<th class="px-4 py-2 text-right">CENA</th>
<th class="px-4 py-2 text-right">ČÁSTKA</th>
</tr>
</thead>
<tbody>
{% for item in items %}
<tr>
<td class="border-b px-4 py-2">
<p class="font-bold">{{ item.description }}</p>
<p class="text-gray-600">Popis položky</p>
</td>
<td class="border-b px-4 py-2 text-right">{{ item.quantity }}</td>
<td class="border-b px-4 py-2 text-right">{{ item.price }}</td>
<td class="border-b px-4 py-2 text-right">{{ item.quantity | times: item.price }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="flex justify-end">
<div class="w-1/2">
<div class="flex justify-between font-bold">
<span>Celkem</span>
<span>{{ items | map: 'price' | sum }} {{ currency.code }}</span>
</div>
</div>
</div>
<div class="mt-8">
<p>Děkujeme za obchod.</p>
</div>
<div class="mt-8">
<h2 class="mb-2 font-bold">Obchodní podmínky</h2>
<p>Prosím zaplaťte do 15 dnů od obdržení této faktury.</p>
</div>
</div>`,
},
{
id: 3,
code: `<div class="mx-auto flex h-full max-w-3xl flex-col justify-between bg-white p-8">
<div>
<div class="mb-8 flex items-start justify-between">
<div>
<h1 class="mb-8 text-4xl font-bold">FAKTURA</h1>
<div class="mb-4">
<h2 class="font-bold">Fakturováno</h2>
<p>{{ client.name }}</p>
<p>{{ client.address }}</p>
<p>{{ client.city }}, {{ client.country }} - {{ client.zip }}</p>
</div>
</div>
<div class="text-right">
<h2 class="text-2xl font-bold text-indigo-600">{{ company.name }}</h2>
<p>{{ company.address }}</p>
<p>{{ company.city }}, {{ company.state }}, {{ company.zip }}</p>
<p>DIČ {{ company.vatId }}</p>
</div>
</div>
<div class="mb-8 grid grid-cols-2 gap-8">
<div>
<p><span class="font-bold">Číslo faktury</span><br />{{ number }}</p>
<p class="mt-4"><span class="font-bold">Předmět</span><br />{{ subject }}</p>
<p class="mt-4"><span class="font-bold">Datum vystavení</span><br />{{ issueDate }}</p>
<p class="mt-4"><span class="font-bold">Datum splatnosti</span><br />{{ dueDate }}</p>
</div>
<div class="rounded-lg bg-gray-100 p-6">
<table class="w-full">
<thead>
<tr class="border-b border-gray-300">
<th class="pb-2 text-left">Služby</th>
<th class="pb-2 text-right">Množství</th>
<th class="pb-2 text-right">Cena</th>
<th class="pb-2 text-right">Celkem</th>
</tr>
</thead>
<tbody>
{% for item in items %}
<tr>
<td class="py-2">{{ item.description }}</td>
<td class="py-2 text-right">{{ item.quantity }}</td>
<td class="py-2 text-right">{{ item.price}} {{ currency.code }}</td>
<td class="py-2 text-right">{{ item.quantity | times: item.price }} {{ currency.code }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="mt-4 border-t border-gray-300 pt-4">
<div class="mt-2 flex justify-between font-bold">
<span>Celkem k úhradě</span>
<span class="text-indigo-600">{{ items | map: 'price' | sum }} {{ currency.code }}</span>
</div>
</div>
</div>
</div>
</div>
<div>
<div class="rounded-lg bg-gray-100 p-4 text-sm">
<p>Prosím zaplaťte do 14 dnů od obdržení této faktury.</p>
</div>
<div class="mt-8 text-center text-sm text-gray-500">
<p>{{ company.website }} | {{ company.phone }} | {{ company.email }}</p>
</div>
</div>
</div>`,
},
{
id: 2,
code: `<div class="mx-auto max-w-3xl bg-white p-8">
<div class="mb-8 flex items-start justify-between">
<h1 class="text-4xl font-bold">Faktura</h1>
<p class="text-xl text-gray-600">č. {{ number }}</p>
</div>
<div class="mb-8 grid grid-cols-3 gap-8">
<div>
<p class="mb-2 text-xl font-bold">K úhradě {{ items | map: 'price' | sum }} {{ currency.code }}</p>
<p class="text-gray-600">Splatnost {{ dueDate }}</p>
<p class="text-gray-600">Vystaveno {{ issueDate }}</p>
</div>
<div>
<h2 class="mb-2 font-bold">Fakturováno</h2>
<p>{{ client.name }}</p>
<p>{{ client.address }}</p>
<p>{{ client.city }}, {{ client.country }} - {{ client.zip }}</p>
<p>{{ client.phone }}</p>
</div>
<div>
<h2 class="mb-2 font-bold">Od</h2>
<p>{{ company.name }}</p>
<p>{{ company.address }}</p>
<p>{{ company.city }}, {{ company.state }}, {{ company.zip }}</p>
<p>DIČ {{ company.vatId }}</p>
</div>
</div>
<div class="mb-8">
<h2 class="mb-4 text-xl font-bold">{{ subject }}</h2>
<table class="w-full">
<thead>
<tr class="border-b border-gray-300 text-left">
<th class="pb-2">POPIS POLOŽKY</th>
<th class="pb-2">MNOŽSTVÍ</th>
<th class="pb-2">CENA</th>
<th class="pb-2">ČÁSTKA</th>
</tr>
</thead>
<tbody>
{% for item in items %}
<tr>
<td class="py-2">{{ item.description }}</td>
<td class="py-2">{{ item.quantity }}</td>
<td class="py-2">{{ item.price | round: 2 }} {{ currency.code }}</td>
<td class="py-2">{{ item.quantity | times: item.price | round: 2 }} {{ currency.code }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="flex justify-end">
<div class="w-1/2">
<div class="flex justify-between text-xl font-bold">
<span>Celkem</span>
<span class="text-pink-600">{{ items | map: 'price' | sum | round: 2 }} {{ currency.code }}</span>
</div>
</div>
</div>
<div class="mt-8 grid grid-cols-2 gap-8">
<div class="border-l-4 border-gray-300 pl-4">
<h2 class="mb-2 font-bold">Platební údaje</h2>
<p>Prosím zaplaťte do 14 dnů od obdržení této faktury.</p>
</div>
<div>
<p><span class="font-bold">Bankovní účet:</span> {{ company.bankName }}</p>
<p><span class="font-bold">IBAN:</span> {{ company.bankIban}}</p>
</div>
</div>
<div class="mt-8 border-l-4 border-gray-300 pl-4">
<p>Děkujeme za obchod.</p>
</div>
<div class="mt-8 text-center text-sm text-gray-600">
<p>{{ company.email }} | {{ company.phone }}</p>
</div>
Expand Down
5 changes: 3 additions & 2 deletions src/i18n/dict/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"retrieve_by_cin": "Po zadání správného IČA se načte zbytek údajů automaticky"
}
},
"error_creating_ompany": "Při vytváření firmy došlo k chybě. Zkuste to prosím znovu.",
"error_creating_company": "Při vytváření firmy došlo k chybě. Zkuste to prosím znovu.",
"company_created": "Firma byla úspěšně vytvořena"
},
"table": {
Expand Down Expand Up @@ -211,7 +211,8 @@
"number": "Číslo dokumentu",
"client": "Klient",
"total": "Cena",
"date": "Datum vystavení"
"date": "Datum vystavení",
"status": "Status"
},
"document": {
"title": {
Expand Down
5 changes: 3 additions & 2 deletions src/i18n/dict/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"retrieve_by_cin": "After entering your CIN, we will try to retrieve your company information from the government database."
}
},
"error_creating_ompany": "Error creating company",
"error_creating_company": "Error creating company",
"company_created": "Company created"
},
"table": {
Expand Down Expand Up @@ -158,7 +158,8 @@
"number": "Number",
"client": "Client",
"total": "Price",
"date": "Issue Date"
"date": "Issue Date",
"status": "Status"
},
"document": {
"title": {
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/dict/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ export type Dict = Flatten<typeof en>;

export default {
[LANG.EN]: en,
[LANG.CS]: cs,
[LANG.CZ]: cs,
};
Loading

0 comments on commit 1314fce

Please sign in to comment.