Skip to content

Commit d6e49ec

Browse files
committed
minor feature called tax identification number inducer
1 parent b94c99d commit d6e49ec

File tree

2 files changed

+77
-6
lines changed

2 files changed

+77
-6
lines changed

index.html

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,62 @@
3636
display: flex;
3737
gap: 20px;
3838
}
39+
40+
/* Toggle Switch CSS */
41+
.toggle-container {
42+
display: flex;
43+
justify-content: center;
44+
align-items: center;
45+
margin: 20px 0;
46+
}
47+
48+
.toggle-container label {
49+
margin: 0 10px;
50+
font-weight: bold;
51+
}
52+
53+
.toggle {
54+
display: inline-block;
55+
width: 60px;
56+
height: 34px;
57+
position: relative;
58+
}
59+
60+
.toggle input {
61+
display: none;
62+
}
63+
64+
.slider {
65+
position: absolute;
66+
top: 0;
67+
left: 0;
68+
right: 0;
69+
bottom: 0;
70+
background-color: #ccc;
71+
border-radius: 34px;
72+
cursor: pointer;
73+
transition: 0.4s;
74+
}
75+
76+
.slider:before {
77+
position: absolute;
78+
content: "";
79+
height: 26px;
80+
width: 26px;
81+
background-color: white;
82+
border-radius: 50%;
83+
bottom: 4px;
84+
left: 4px;
85+
transition: 0.4s;
86+
}
87+
88+
input:checked + .slider {
89+
background-color: #4CAF50;
90+
}
91+
92+
input:checked + .slider:before {
93+
transform: translateX(26px);
94+
}
3995
</style>
4096
</head>
4197
<body>
@@ -49,6 +105,10 @@
49105

50106
<!-- Main Content -->
51107
<h1>Fatrocu</h1>
108+
<div>
109+
<label for="invoiceName">Satıcı/Alıcı Adı:</label>
110+
<input type="text" id="invoiceName" placeholder="Faturalar gelir ise satıcı, gider is alıcı firmanın/kişinin adını Girin">
111+
</div>
52112
<div id="dropArea">Faturaları buraya sürükleyin veya tıklayarak seçin</div>
53113
<input type="file" id="fileInput" style="display: none;" multiple accept="image/*,.pdf">
54114
<div id="fileList"></div>

script.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const fileInput = document.getElementById('fileInput');
44
const fileList = document.getElementById('fileList');
55
const progressBar = document.getElementById('progressBar').firstElementChild;
66
const analyzeButton = document.getElementById('analyzeButton');
7+
const invoiceNameInput = document.getElementById('invoiceName'); // Yeni input alanı
78
let selectedFiles = [];
89

910
// Sürükle-bırak ve dosya seçme olayları
@@ -49,16 +50,26 @@ function handleFiles(files) {
4950
selectedFiles = Array.from(files.target.files);
5051
}
5152
updateFileList();
52-
analyzeButton.disabled = selectedFiles.length === 0;
53+
analyzeButton.disabled = selectedFiles.length === 0 || !invoiceNameInput.value.trim();
5354
}
5455

56+
invoiceNameInput.addEventListener('input', () => {
57+
analyzeButton.disabled = selectedFiles.length === 0 || !invoiceNameInput.value.trim();
58+
});
59+
5560
function updateFileList() {
5661
fileList.innerHTML = selectedFiles.map(file => `<p>${file.name}</p>`).join('');
5762
}
5863

5964
analyzeButton.addEventListener('click', analyzeInvoices);
6065

6166
async function analyzeInvoices() {
67+
const invoiceName = invoiceNameInput.value.trim();
68+
if (!invoiceName) {
69+
alert("Lütfen satıcı veya alıcı adını giriniz!");
70+
return;
71+
}
72+
6273
analyzeButton.disabled = true;
6374
const totalFiles = selectedFiles.length;
6475
let processedFiles = 0;
@@ -72,7 +83,7 @@ async function analyzeInvoices() {
7283
}
7384

7485
for (const chunk of chunks) {
75-
const chunkPromises = chunk.map(file => analyzeInvoice(file));
86+
const chunkPromises = chunk.map(file => analyzeInvoice(file, invoiceName));
7687
const results = await Promise.all(chunkPromises);
7788

7889
results.forEach((result, index) => {
@@ -95,12 +106,12 @@ function updateProgress(percentage) {
95106
progressBar.style.width = `${percentage}%`;
96107
}
97108

98-
async function analyzeInvoice(file) {
109+
async function analyzeInvoice(file, invoiceName) {
99110
try {
100-
API_KEY = localStorage.getItem('API_KEY') || API_KEY; // Anahtarı her işlemden önce günceller.
111+
API_KEY = localStorage.getItem('API_KEY') || API_KEY;
101112
const base64 = await fileToBase64(file);
102113
const mimeType = file.type;
103-
114+
104115
const response = await fetch(`https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=${API_KEY}`, {
105116
method: 'POST',
106117
headers: {
@@ -112,7 +123,7 @@ async function analyzeInvoice(file) {
112123
text: `Fatura bilgilerini analiz et ve sadece aşağıdaki bilgilere ulaşmaya çalış:
113124
- Fatura Tarihi
114125
- Fatura Türü (Alış/Satış)
115-
- Alıcı Firma'nın VKN veya TCKN Numarası
126+
- Alıcı veya Satıcı'nın VKN veya V.D. veya TCKN Numarası(vkn veya tckn asla ${invoiceName} firmasının olmamalı)
116127
- Fatura Numarası
117128
- Matrah (Toplam tutar)
118129
- KDV Tutarı

0 commit comments

Comments
 (0)