Container Accounting Management
This commit is contained in:
parent
33850550a6
commit
ecb32cf6cf
7 changed files with 650 additions and 798 deletions
|
|
@ -1,64 +1,61 @@
|
|||
import React, { useState, useEffect } from "react";
|
||||
import BankManagement from "./components/BankManagement";
|
||||
import BankAccountForm from "./components/BankAccountForm";
|
||||
import BankMovementForm from "./components/BankMovementForm";
|
||||
import BankAccountDetails from "./components/BankAccountDetails";
|
||||
import React, { useState, useEffect } from 'react'
|
||||
import BankManagement from './components/BankManagement'
|
||||
import BankAccountForm from './components/BankAccountForm'
|
||||
import BankMovementForm from './components/BankMovementForm'
|
||||
import BankAccountDetails from './components/BankAccountDetails'
|
||||
import {
|
||||
FiBankMovement,
|
||||
BankAccountTypeEnum,
|
||||
BankTransactionTypeEnum,
|
||||
TransactionStatusEnum,
|
||||
} from "../../types/fi";
|
||||
import { mockBanks } from "../../mocks/mockBanks";
|
||||
import { mockBankMovements } from "../../mocks/mockBankMovements";
|
||||
import { BankAccount } from "../../types/common";
|
||||
} from '../../types/fi'
|
||||
import { mockBanks } from '../../mocks/mockBanks'
|
||||
import { mockBankMovements } from '../../mocks/mockBankMovements'
|
||||
import { BankAccount } from '../../types/common'
|
||||
import { Container } from '@/components/shared'
|
||||
|
||||
const BankPage: React.FC = () => {
|
||||
const [bankAccounts, setBankAccounts] = useState<BankAccount[]>(mockBanks);
|
||||
const [bankMovements, setBankMovements] = useState<FiBankMovement[]>([]);
|
||||
const [bankAccounts, setBankAccounts] = useState<BankAccount[]>(mockBanks)
|
||||
const [bankMovements, setBankMovements] = useState<FiBankMovement[]>([])
|
||||
|
||||
// Initialize bank movements after bank accounts are set
|
||||
useEffect(() => {
|
||||
if (bankAccounts.length > 0) {
|
||||
setBankMovements(mockBankMovements);
|
||||
setBankMovements(mockBankMovements)
|
||||
}
|
||||
}, [bankAccounts]);
|
||||
}, [bankAccounts])
|
||||
|
||||
// Modal states
|
||||
const [isAccountFormOpen, setIsAccountFormOpen] = useState(false);
|
||||
const [isMovementFormOpen, setIsMovementFormOpen] = useState(false);
|
||||
const [isAccountDetailsOpen, setIsAccountDetailsOpen] = useState(false);
|
||||
const [selectedAccount, setSelectedAccount] = useState<
|
||||
BankAccount | undefined
|
||||
>(undefined);
|
||||
const [selectedMovement, setSelectedMovement] = useState<
|
||||
FiBankMovement | undefined
|
||||
>(undefined);
|
||||
const [isAccountFormOpen, setIsAccountFormOpen] = useState(false)
|
||||
const [isMovementFormOpen, setIsMovementFormOpen] = useState(false)
|
||||
const [isAccountDetailsOpen, setIsAccountDetailsOpen] = useState(false)
|
||||
const [selectedAccount, setSelectedAccount] = useState<BankAccount | undefined>(undefined)
|
||||
const [selectedMovement, setSelectedMovement] = useState<FiBankMovement | undefined>(undefined)
|
||||
|
||||
const handleAddAccount = () => {
|
||||
setSelectedAccount(undefined);
|
||||
setIsAccountFormOpen(true);
|
||||
};
|
||||
setSelectedAccount(undefined)
|
||||
setIsAccountFormOpen(true)
|
||||
}
|
||||
|
||||
const handleEditAccount = (account: BankAccount) => {
|
||||
setSelectedAccount(account);
|
||||
setIsAccountFormOpen(true);
|
||||
};
|
||||
setSelectedAccount(account)
|
||||
setIsAccountFormOpen(true)
|
||||
}
|
||||
|
||||
const handleAddMovement = () => {
|
||||
setSelectedMovement(undefined);
|
||||
setIsMovementFormOpen(true);
|
||||
};
|
||||
setSelectedMovement(undefined)
|
||||
setIsMovementFormOpen(true)
|
||||
}
|
||||
|
||||
const handleEditMovement = (movement: FiBankMovement) => {
|
||||
setSelectedMovement(movement);
|
||||
setIsMovementFormOpen(true);
|
||||
};
|
||||
setSelectedMovement(movement)
|
||||
setIsMovementFormOpen(true)
|
||||
}
|
||||
|
||||
const handleViewDetails = (account: BankAccount) => {
|
||||
setSelectedAccount(account);
|
||||
setIsAccountDetailsOpen(true);
|
||||
};
|
||||
setSelectedAccount(account)
|
||||
setIsAccountDetailsOpen(true)
|
||||
}
|
||||
|
||||
const handleSaveAccount = (accountData: Partial<BankAccount>) => {
|
||||
if (selectedAccount) {
|
||||
|
|
@ -67,20 +64,20 @@ const BankPage: React.FC = () => {
|
|||
prev.map((acc) =>
|
||||
acc.id === selectedAccount.id
|
||||
? { ...acc, ...accountData, lastModificationTime: new Date() }
|
||||
: acc
|
||||
: acc,
|
||||
),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
// Add new account
|
||||
const newAccount: BankAccount = {
|
||||
id: Date.now().toString(),
|
||||
accountCode: accountData.accountCode || "",
|
||||
bankName: accountData.bankName || "",
|
||||
branchName: accountData.branchName || "",
|
||||
accountNumber: accountData.accountNumber || "",
|
||||
iban: accountData.iban || "",
|
||||
accountCode: accountData.accountCode || '',
|
||||
bankName: accountData.bankName || '',
|
||||
branchName: accountData.branchName || '',
|
||||
accountNumber: accountData.accountNumber || '',
|
||||
iban: accountData.iban || '',
|
||||
accountType: accountData.accountType || BankAccountTypeEnum.Current,
|
||||
currency: accountData.currency || "TRY",
|
||||
currency: accountData.currency || 'TRY',
|
||||
balance: accountData.balance || 0,
|
||||
overdraftLimit: accountData.overdraftLimit || 0,
|
||||
dailyTransferLimit: accountData.dailyTransferLimit || 0,
|
||||
|
|
@ -90,66 +87,61 @@ const BankPage: React.FC = () => {
|
|||
creationTime: new Date(),
|
||||
lastModificationTime: new Date(),
|
||||
isDefault: false,
|
||||
};
|
||||
setBankAccounts((prev) => [...prev, newAccount]);
|
||||
}
|
||||
setIsAccountFormOpen(false);
|
||||
setSelectedAccount(undefined);
|
||||
};
|
||||
setBankAccounts((prev) => [...prev, newAccount])
|
||||
}
|
||||
setIsAccountFormOpen(false)
|
||||
setSelectedAccount(undefined)
|
||||
}
|
||||
|
||||
const handleSaveMovement = (movementData: Partial<FiBankMovement>) => {
|
||||
if (selectedMovement) {
|
||||
// Update existing movement
|
||||
setBankMovements((prev) =>
|
||||
prev.map((mov) =>
|
||||
mov.id === selectedMovement.id ? { ...mov, ...movementData } : mov
|
||||
prev.map((mov) => (mov.id === selectedMovement.id ? { ...mov, ...movementData } : mov)),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
// Add new movement
|
||||
const bankAccount = bankAccounts.find(
|
||||
(acc) => acc.id === movementData.bankAccountId
|
||||
);
|
||||
const bankAccount = bankAccounts.find((acc) => acc.id === movementData.bankAccountId)
|
||||
const newMovement: FiBankMovement = {
|
||||
id: Date.now().toString(),
|
||||
bankAccountId: movementData.bankAccountId || "",
|
||||
bankAccountId: movementData.bankAccountId || '',
|
||||
bankAccount: bankAccount,
|
||||
transactionDate: movementData.transactionDate || new Date(),
|
||||
valueDate: movementData.valueDate || new Date(),
|
||||
description: movementData.description || "",
|
||||
description: movementData.description || '',
|
||||
referenceNumber: movementData.referenceNumber,
|
||||
transactionType:
|
||||
movementData.transactionType || BankTransactionTypeEnum.Deposit,
|
||||
transactionType: movementData.transactionType || BankTransactionTypeEnum.Deposit,
|
||||
amount: movementData.amount || 0,
|
||||
currency: movementData.currency || "TRY",
|
||||
currency: movementData.currency || 'TRY',
|
||||
recipientName: movementData.recipientName,
|
||||
recipientIban: movementData.recipientIban,
|
||||
recipientBank: movementData.recipientBank,
|
||||
currentAccountId: movementData.currentAccountId,
|
||||
status: movementData.status || TransactionStatusEnum.Pending,
|
||||
creationTime: new Date(),
|
||||
};
|
||||
setBankMovements((prev) => [...prev, newMovement]);
|
||||
}
|
||||
setBankMovements((prev) => [...prev, newMovement])
|
||||
|
||||
// Update account balance
|
||||
if (bankAccount) {
|
||||
const isIncoming = [
|
||||
BankTransactionTypeEnum.Deposit,
|
||||
BankTransactionTypeEnum.Interest,
|
||||
].includes(newMovement.transactionType);
|
||||
].includes(newMovement.transactionType)
|
||||
const isOutgoing = [
|
||||
BankTransactionTypeEnum.Withdrawal,
|
||||
BankTransactionTypeEnum.Transfer,
|
||||
BankTransactionTypeEnum.EFT,
|
||||
BankTransactionTypeEnum.Fee,
|
||||
].includes(newMovement.transactionType);
|
||||
].includes(newMovement.transactionType)
|
||||
|
||||
if (newMovement.status === TransactionStatusEnum.Completed) {
|
||||
const balanceChange = isIncoming
|
||||
? newMovement.amount
|
||||
: isOutgoing
|
||||
? -newMovement.amount
|
||||
: 0;
|
||||
: 0
|
||||
setBankAccounts((prev) =>
|
||||
prev.map((acc) =>
|
||||
acc.id === bankAccount.id
|
||||
|
|
@ -158,18 +150,18 @@ const BankPage: React.FC = () => {
|
|||
balance: acc.balance + balanceChange,
|
||||
lastModificationTime: new Date(),
|
||||
}
|
||||
: acc
|
||||
: acc,
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
setIsMovementFormOpen(false);
|
||||
setSelectedMovement(undefined);
|
||||
};
|
||||
setIsMovementFormOpen(false)
|
||||
setSelectedMovement(undefined)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Container>
|
||||
<BankManagement
|
||||
bankAccounts={bankAccounts}
|
||||
bankMovements={bankMovements}
|
||||
|
|
@ -185,8 +177,8 @@ const BankPage: React.FC = () => {
|
|||
account={selectedAccount}
|
||||
isOpen={isAccountFormOpen}
|
||||
onClose={() => {
|
||||
setIsAccountFormOpen(false);
|
||||
setSelectedAccount(undefined);
|
||||
setIsAccountFormOpen(false)
|
||||
setSelectedAccount(undefined)
|
||||
}}
|
||||
onSave={handleSaveAccount}
|
||||
/>
|
||||
|
|
@ -197,8 +189,8 @@ const BankPage: React.FC = () => {
|
|||
bankAccounts={bankAccounts}
|
||||
isOpen={isMovementFormOpen}
|
||||
onClose={() => {
|
||||
setIsMovementFormOpen(false);
|
||||
setSelectedMovement(undefined);
|
||||
setIsMovementFormOpen(false)
|
||||
setSelectedMovement(undefined)
|
||||
}}
|
||||
onSave={handleSaveMovement}
|
||||
/>
|
||||
|
|
@ -210,17 +202,17 @@ const BankPage: React.FC = () => {
|
|||
movements={bankMovements}
|
||||
isOpen={isAccountDetailsOpen}
|
||||
onClose={() => {
|
||||
setIsAccountDetailsOpen(false);
|
||||
setSelectedAccount(undefined);
|
||||
setIsAccountDetailsOpen(false)
|
||||
setSelectedAccount(undefined)
|
||||
}}
|
||||
onEdit={(account) => {
|
||||
setIsAccountDetailsOpen(false);
|
||||
handleEditAccount(account);
|
||||
setIsAccountDetailsOpen(false)
|
||||
handleEditAccount(account)
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
</Container>
|
||||
)
|
||||
}
|
||||
|
||||
export default BankPage;
|
||||
export default BankPage
|
||||
|
|
|
|||
|
|
@ -1,91 +1,78 @@
|
|||
import React, { useState } from "react";
|
||||
import CashManagement from "./components/CashManagement";
|
||||
import CashAccountForm from "./components/CashAccountForm";
|
||||
import CashMovementForm from "./components/CashMovementForm";
|
||||
import CashAccountDetails from "./components/CashAccountDetails";
|
||||
import {
|
||||
FiCashAccount,
|
||||
FiCashMovement,
|
||||
CashMovementTypeEnum,
|
||||
} from "../../types/fi";
|
||||
import { mockCashAccounts } from "../../mocks/mockCashAccounts";
|
||||
import { mockCashMovements } from "../../mocks/mockCashMovements";
|
||||
import React, { useState } from 'react'
|
||||
import CashManagement from './components/CashManagement'
|
||||
import CashAccountForm from './components/CashAccountForm'
|
||||
import CashMovementForm from './components/CashMovementForm'
|
||||
import CashAccountDetails from './components/CashAccountDetails'
|
||||
import { FiCashAccount, FiCashMovement, CashMovementTypeEnum } from '../../types/fi'
|
||||
import { mockCashAccounts } from '../../mocks/mockCashAccounts'
|
||||
import { mockCashMovements } from '../../mocks/mockCashMovements'
|
||||
import { Container } from '@/components/shared'
|
||||
|
||||
const CashPage: React.FC = () => {
|
||||
const [showAccountForm, setShowAccountForm] = useState(false);
|
||||
const [showMovementForm, setShowMovementForm] = useState(false);
|
||||
const [showAccountDetails, setShowAccountDetails] = useState(false);
|
||||
const [editingAccount, setEditingAccount] = useState<
|
||||
FiCashAccount | undefined
|
||||
>();
|
||||
const [editingMovement, setEditingMovement] = useState<
|
||||
FiCashMovement | undefined
|
||||
>();
|
||||
const [viewingAccount, setViewingAccount] = useState<
|
||||
FiCashAccount | undefined
|
||||
>();
|
||||
const [cashAccounts, setCashAccounts] = useState(mockCashAccounts);
|
||||
const [cashMovements, setCashMovements] = useState(mockCashMovements);
|
||||
const [showAccountForm, setShowAccountForm] = useState(false)
|
||||
const [showMovementForm, setShowMovementForm] = useState(false)
|
||||
const [showAccountDetails, setShowAccountDetails] = useState(false)
|
||||
const [editingAccount, setEditingAccount] = useState<FiCashAccount | undefined>()
|
||||
const [editingMovement, setEditingMovement] = useState<FiCashMovement | undefined>()
|
||||
const [viewingAccount, setViewingAccount] = useState<FiCashAccount | undefined>()
|
||||
const [cashAccounts, setCashAccounts] = useState(mockCashAccounts)
|
||||
const [cashMovements, setCashMovements] = useState(mockCashMovements)
|
||||
|
||||
const handleAddAccount = () => {
|
||||
setEditingAccount(undefined);
|
||||
setShowAccountForm(true);
|
||||
};
|
||||
setEditingAccount(undefined)
|
||||
setShowAccountForm(true)
|
||||
}
|
||||
|
||||
const handleEditAccount = (account: FiCashAccount) => {
|
||||
setEditingAccount(account);
|
||||
setShowAccountForm(true);
|
||||
};
|
||||
setEditingAccount(account)
|
||||
setShowAccountForm(true)
|
||||
}
|
||||
|
||||
const handleSaveAccount = (accountData: Omit<FiCashAccount, "id">) => {
|
||||
const handleSaveAccount = (accountData: Omit<FiCashAccount, 'id'>) => {
|
||||
if (editingAccount) {
|
||||
// Update existing account
|
||||
setCashAccounts((prev) =>
|
||||
prev.map((acc) =>
|
||||
acc.id === editingAccount.id
|
||||
? { ...accountData, id: editingAccount.id }
|
||||
: acc
|
||||
acc.id === editingAccount.id ? { ...accountData, id: editingAccount.id } : acc,
|
||||
),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
// Add new account
|
||||
const newAccount: FiCashAccount = {
|
||||
...accountData,
|
||||
id: Date.now().toString(),
|
||||
};
|
||||
setCashAccounts((prev) => [...prev, newAccount]);
|
||||
}
|
||||
setShowAccountForm(false);
|
||||
setEditingAccount(undefined);
|
||||
};
|
||||
setCashAccounts((prev) => [...prev, newAccount])
|
||||
}
|
||||
setShowAccountForm(false)
|
||||
setEditingAccount(undefined)
|
||||
}
|
||||
|
||||
const handleAddMovement = () => {
|
||||
setEditingMovement(undefined);
|
||||
setShowMovementForm(true);
|
||||
};
|
||||
setEditingMovement(undefined)
|
||||
setShowMovementForm(true)
|
||||
}
|
||||
|
||||
const handleEditMovement = (movement: FiCashMovement) => {
|
||||
setEditingMovement(movement);
|
||||
setShowMovementForm(true);
|
||||
};
|
||||
setEditingMovement(movement)
|
||||
setShowMovementForm(true)
|
||||
}
|
||||
|
||||
const handleSaveMovement = (movementData: Omit<FiCashMovement, "id">) => {
|
||||
const handleSaveMovement = (movementData: Omit<FiCashMovement, 'id'>) => {
|
||||
if (editingMovement) {
|
||||
// Update existing movement
|
||||
setCashMovements((prev) =>
|
||||
prev.map((mov) =>
|
||||
mov.id === editingMovement.id
|
||||
? { ...movementData, id: editingMovement.id }
|
||||
: mov
|
||||
mov.id === editingMovement.id ? { ...movementData, id: editingMovement.id } : mov,
|
||||
),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
// Add new movement
|
||||
const newMovement: FiCashMovement = {
|
||||
...movementData,
|
||||
id: Date.now().toString(),
|
||||
};
|
||||
setCashMovements((prev) => [...prev, newMovement]);
|
||||
}
|
||||
setCashMovements((prev) => [...prev, newMovement])
|
||||
}
|
||||
|
||||
// Update cash account balance
|
||||
|
|
@ -96,44 +83,44 @@ const CashPage: React.FC = () => {
|
|||
const balanceChange =
|
||||
movementData.movementType === CashMovementTypeEnum.Income
|
||||
? movementData.amount
|
||||
: -movementData.amount;
|
||||
: -movementData.amount
|
||||
return {
|
||||
...acc,
|
||||
balance: acc.balance + balanceChange,
|
||||
lastModificationTime: new Date(),
|
||||
};
|
||||
}
|
||||
return acc;
|
||||
})
|
||||
);
|
||||
}
|
||||
return acc
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
setShowMovementForm(false);
|
||||
setEditingMovement(undefined);
|
||||
};
|
||||
setShowMovementForm(false)
|
||||
setEditingMovement(undefined)
|
||||
}
|
||||
|
||||
const handleViewDetails = (account: FiCashAccount) => {
|
||||
setViewingAccount(account);
|
||||
setShowAccountDetails(true);
|
||||
};
|
||||
setViewingAccount(account)
|
||||
setShowAccountDetails(true)
|
||||
}
|
||||
|
||||
const handleCloseAccountForm = () => {
|
||||
setShowAccountForm(false);
|
||||
setEditingAccount(undefined);
|
||||
};
|
||||
setShowAccountForm(false)
|
||||
setEditingAccount(undefined)
|
||||
}
|
||||
|
||||
const handleCloseMovementForm = () => {
|
||||
setShowMovementForm(false);
|
||||
setEditingMovement(undefined);
|
||||
};
|
||||
setShowMovementForm(false)
|
||||
setEditingMovement(undefined)
|
||||
}
|
||||
|
||||
const handleCloseAccountDetails = () => {
|
||||
setShowAccountDetails(false);
|
||||
setViewingAccount(undefined);
|
||||
};
|
||||
setShowAccountDetails(false)
|
||||
setViewingAccount(undefined)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Container>
|
||||
<CashManagement
|
||||
cashAccounts={cashAccounts}
|
||||
cashMovements={cashMovements}
|
||||
|
|
@ -172,13 +159,13 @@ const CashPage: React.FC = () => {
|
|||
movements={cashMovements}
|
||||
onClose={handleCloseAccountDetails}
|
||||
onEdit={(account) => {
|
||||
setShowAccountDetails(false);
|
||||
handleEditAccount(account);
|
||||
setShowAccountDetails(false)
|
||||
handleEditAccount(account)
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
</Container>
|
||||
)
|
||||
}
|
||||
|
||||
export default CashPage;
|
||||
export default CashPage
|
||||
|
|
|
|||
|
|
@ -1,79 +1,64 @@
|
|||
import React, { useState } from "react";
|
||||
import CheckNoteManagement from "./components/CheckNoteManagement";
|
||||
import {
|
||||
FiCheck,
|
||||
PromissoryNote,
|
||||
CheckStatusEnum,
|
||||
NoteStatusEnum,
|
||||
} from "../../types/fi";
|
||||
import { mockChecks } from "../../mocks/mockChecks";
|
||||
import { mockPromissoryNotes } from "../../mocks/mockPromissoryNotes";
|
||||
import { mockCurrentAccounts } from "../../mocks/mockCurrentAccounts";
|
||||
import React, { useState } from 'react'
|
||||
import CheckNoteManagement from './components/CheckNoteManagement'
|
||||
import { FiCheck, PromissoryNote, CheckStatusEnum, NoteStatusEnum } from '../../types/fi'
|
||||
import { mockChecks } from '../../mocks/mockChecks'
|
||||
import { mockPromissoryNotes } from '../../mocks/mockPromissoryNotes'
|
||||
import { mockCurrentAccounts } from '../../mocks/mockCurrentAccounts'
|
||||
import { Container } from '@/components/shared'
|
||||
|
||||
const CheckNotePage: React.FC = () => {
|
||||
const [checks, setChecks] = useState<FiCheck[]>(mockChecks);
|
||||
const [promissoryNotes, setPromissoryNotes] =
|
||||
useState<PromissoryNote[]>(mockPromissoryNotes);
|
||||
const [checks, setChecks] = useState<FiCheck[]>(mockChecks)
|
||||
const [promissoryNotes, setPromissoryNotes] = useState<PromissoryNote[]>(mockPromissoryNotes)
|
||||
|
||||
const handleAddCheck = (
|
||||
checkData: Omit<FiCheck, "id" | "creationTime" | "lastModificationTime">
|
||||
checkData: Omit<FiCheck, 'id' | 'creationTime' | 'lastModificationTime'>,
|
||||
) => {
|
||||
const newCheck: FiCheck = {
|
||||
...checkData,
|
||||
id: `check_${Date.now()}`,
|
||||
creationTime: new Date(),
|
||||
lastModificationTime: new Date(),
|
||||
};
|
||||
setChecks((prev) => [...prev, newCheck]);
|
||||
console.log("Check added:", newCheck);
|
||||
};
|
||||
}
|
||||
setChecks((prev) => [...prev, newCheck])
|
||||
console.log('Check added:', newCheck)
|
||||
}
|
||||
|
||||
const handleEditCheck = (
|
||||
id: string,
|
||||
checkData: Omit<FiCheck, "id" | "creationTime" | "lastModificationTime">
|
||||
checkData: Omit<FiCheck, 'id' | 'creationTime' | 'lastModificationTime'>,
|
||||
) => {
|
||||
setChecks((prev) =>
|
||||
prev.map((check) =>
|
||||
check.id === id
|
||||
? { ...check, ...checkData, lastModificationTime: new Date() }
|
||||
: check
|
||||
check.id === id ? { ...check, ...checkData, lastModificationTime: new Date() } : check,
|
||||
),
|
||||
)
|
||||
);
|
||||
console.log("Check updated:", id, checkData);
|
||||
};
|
||||
console.log('Check updated:', id, checkData)
|
||||
}
|
||||
|
||||
const handleAddNote = (
|
||||
noteData: Omit<
|
||||
PromissoryNote,
|
||||
"id" | "creationTime" | "lastModificationTime"
|
||||
>
|
||||
noteData: Omit<PromissoryNote, 'id' | 'creationTime' | 'lastModificationTime'>,
|
||||
) => {
|
||||
const newNote: PromissoryNote = {
|
||||
...noteData,
|
||||
id: `note_${Date.now()}`,
|
||||
creationTime: new Date(),
|
||||
lastModificationTime: new Date(),
|
||||
};
|
||||
setPromissoryNotes((prev) => [...prev, newNote]);
|
||||
console.log("Promissory note added:", newNote);
|
||||
};
|
||||
}
|
||||
setPromissoryNotes((prev) => [...prev, newNote])
|
||||
console.log('Promissory note added:', newNote)
|
||||
}
|
||||
|
||||
const handleEditNote = (
|
||||
id: string,
|
||||
noteData: Omit<
|
||||
PromissoryNote,
|
||||
"id" | "creationTime" | "lastModificationTime"
|
||||
>
|
||||
noteData: Omit<PromissoryNote, 'id' | 'creationTime' | 'lastModificationTime'>,
|
||||
) => {
|
||||
setPromissoryNotes((prev) =>
|
||||
prev.map((note) =>
|
||||
note.id === id
|
||||
? { ...note, ...noteData, lastModificationTime: new Date() }
|
||||
: note
|
||||
note.id === id ? { ...note, ...noteData, lastModificationTime: new Date() } : note,
|
||||
),
|
||||
)
|
||||
);
|
||||
console.log("Promissory note updated:", id, noteData);
|
||||
};
|
||||
console.log('Promissory note updated:', id, noteData)
|
||||
}
|
||||
|
||||
const handleCollectCheck = (id: string, collectionDate: Date) => {
|
||||
setChecks((prev) =>
|
||||
|
|
@ -85,11 +70,11 @@ const CheckNotePage: React.FC = () => {
|
|||
collectionDate,
|
||||
lastModificationTime: new Date(),
|
||||
}
|
||||
: check
|
||||
: check,
|
||||
),
|
||||
)
|
||||
);
|
||||
console.log("Check collected:", id, collectionDate);
|
||||
};
|
||||
console.log('Check collected:', id, collectionDate)
|
||||
}
|
||||
|
||||
const handleCollectNote = (id: string, collectionDate: Date) => {
|
||||
setPromissoryNotes((prev) =>
|
||||
|
|
@ -101,11 +86,11 @@ const CheckNotePage: React.FC = () => {
|
|||
collectionDate,
|
||||
lastModificationTime: new Date(),
|
||||
}
|
||||
: note
|
||||
: note,
|
||||
),
|
||||
)
|
||||
);
|
||||
console.log("Promissory note collected:", id, collectionDate);
|
||||
};
|
||||
console.log('Promissory note collected:', id, collectionDate)
|
||||
}
|
||||
|
||||
const handleEndorseCheck = (id: string, endorsedTo: string) => {
|
||||
setChecks((prev) =>
|
||||
|
|
@ -117,11 +102,11 @@ const CheckNotePage: React.FC = () => {
|
|||
endorsedTo,
|
||||
lastModificationTime: new Date(),
|
||||
}
|
||||
: check
|
||||
: check,
|
||||
),
|
||||
)
|
||||
);
|
||||
console.log("Check endorsed:", id, endorsedTo);
|
||||
};
|
||||
console.log('Check endorsed:', id, endorsedTo)
|
||||
}
|
||||
|
||||
const handleEndorseNote = (id: string, endorsedTo: string) => {
|
||||
setPromissoryNotes((prev) =>
|
||||
|
|
@ -133,13 +118,14 @@ const CheckNotePage: React.FC = () => {
|
|||
endorsedTo,
|
||||
lastModificationTime: new Date(),
|
||||
}
|
||||
: note
|
||||
: note,
|
||||
),
|
||||
)
|
||||
);
|
||||
console.log("Promissory note endorsed:", id, endorsedTo);
|
||||
};
|
||||
console.log('Promissory note endorsed:', id, endorsedTo)
|
||||
}
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<CheckNoteManagement
|
||||
checks={checks}
|
||||
promissoryNotes={promissoryNotes}
|
||||
|
|
@ -153,7 +139,8 @@ const CheckNotePage: React.FC = () => {
|
|||
onEndorseCheck={handleEndorseCheck}
|
||||
onEndorseNote={handleEndorseNote}
|
||||
/>
|
||||
);
|
||||
};
|
||||
</Container>
|
||||
)
|
||||
}
|
||||
|
||||
export default CheckNotePage;
|
||||
export default CheckNotePage
|
||||
|
|
|
|||
|
|
@ -1,15 +1,18 @@
|
|||
import React from "react";
|
||||
import CurrentAccountManagement from "./components/CurrentAccountManagement";
|
||||
import { mockCurrentAccounts } from "../../mocks/mockCurrentAccounts";
|
||||
import { mockCurrentAccountMovements } from "../../mocks/mockCurrentAccountMovements";
|
||||
import React from 'react'
|
||||
import CurrentAccountManagement from './components/CurrentAccountManagement'
|
||||
import { mockCurrentAccounts } from '../../mocks/mockCurrentAccounts'
|
||||
import { mockCurrentAccountMovements } from '../../mocks/mockCurrentAccountMovements'
|
||||
import { Container } from '@/components/shared'
|
||||
|
||||
const CurrentAccountPage: React.FC = () => {
|
||||
return (
|
||||
<Container>
|
||||
<CurrentAccountManagement
|
||||
accounts={mockCurrentAccounts}
|
||||
accountMovements={mockCurrentAccountMovements}
|
||||
/>
|
||||
);
|
||||
};
|
||||
</Container>
|
||||
)
|
||||
}
|
||||
|
||||
export default CurrentAccountPage;
|
||||
export default CurrentAccountPage
|
||||
|
|
|
|||
|
|
@ -1,58 +1,53 @@
|
|||
import React, { useState } from "react";
|
||||
import InvoiceManagement from "./components/InvoiceManagement";
|
||||
import InvoiceForm from "./components/InvoiceForm";
|
||||
import InvoiceDetails from "./components/InvoiceDetails";
|
||||
import PaymentForm from "./components/PaymentForm";
|
||||
import WaybillToInvoice from "./components/WaybillToInvoice";
|
||||
import {
|
||||
FiInvoice,
|
||||
PaymentMethodEnum,
|
||||
PaymentStatusEnum,
|
||||
} from "../../types/fi";
|
||||
import { mockInvoices } from "../../mocks/mockInvoices";
|
||||
import React, { useState } from 'react'
|
||||
import InvoiceManagement from './components/InvoiceManagement'
|
||||
import InvoiceForm from './components/InvoiceForm'
|
||||
import InvoiceDetails from './components/InvoiceDetails'
|
||||
import PaymentForm from './components/PaymentForm'
|
||||
import WaybillToInvoice from './components/WaybillToInvoice'
|
||||
import { FiInvoice, PaymentMethodEnum, PaymentStatusEnum } from '../../types/fi'
|
||||
import { mockInvoices } from '../../mocks/mockInvoices'
|
||||
import { Container } from '@/components/shared'
|
||||
|
||||
interface PaymentData {
|
||||
amount: number;
|
||||
paymentDate: Date;
|
||||
paymentMethod: PaymentMethodEnum;
|
||||
description: string;
|
||||
referenceNumber?: string;
|
||||
amount: number
|
||||
paymentDate: Date
|
||||
paymentMethod: PaymentMethodEnum
|
||||
description: string
|
||||
referenceNumber?: string
|
||||
}
|
||||
|
||||
const InvoicePage: React.FC = () => {
|
||||
const [invoices, setInvoices] = useState<FiInvoice[]>(mockInvoices);
|
||||
const [showInvoiceForm, setShowInvoiceForm] = useState(false);
|
||||
const [showInvoiceDetails, setShowInvoiceDetails] = useState(false);
|
||||
const [showPaymentForm, setShowPaymentForm] = useState(false);
|
||||
const [showWaybillToInvoice, setShowWaybillToInvoice] = useState(false);
|
||||
const [selectedInvoice, setSelectedInvoice] = useState<FiInvoice | null>(
|
||||
null
|
||||
);
|
||||
const [editingInvoice, setEditingInvoice] = useState<FiInvoice | null>(null);
|
||||
const [invoices, setInvoices] = useState<FiInvoice[]>(mockInvoices)
|
||||
const [showInvoiceForm, setShowInvoiceForm] = useState(false)
|
||||
const [showInvoiceDetails, setShowInvoiceDetails] = useState(false)
|
||||
const [showPaymentForm, setShowPaymentForm] = useState(false)
|
||||
const [showWaybillToInvoice, setShowWaybillToInvoice] = useState(false)
|
||||
const [selectedInvoice, setSelectedInvoice] = useState<FiInvoice | null>(null)
|
||||
const [editingInvoice, setEditingInvoice] = useState<FiInvoice | null>(null)
|
||||
|
||||
const handleAdd = () => {
|
||||
setEditingInvoice(null);
|
||||
setShowInvoiceForm(true);
|
||||
};
|
||||
setEditingInvoice(null)
|
||||
setShowInvoiceForm(true)
|
||||
}
|
||||
|
||||
const handleEdit = (invoice: FiInvoice) => {
|
||||
setEditingInvoice(invoice);
|
||||
setShowInvoiceForm(true);
|
||||
};
|
||||
setEditingInvoice(invoice)
|
||||
setShowInvoiceForm(true)
|
||||
}
|
||||
|
||||
const handleCreatePayment = (invoice: FiInvoice) => {
|
||||
setSelectedInvoice(invoice);
|
||||
setShowPaymentForm(true);
|
||||
};
|
||||
setSelectedInvoice(invoice)
|
||||
setShowPaymentForm(true)
|
||||
}
|
||||
|
||||
const handleViewDetails = (invoice: FiInvoice) => {
|
||||
setSelectedInvoice(invoice);
|
||||
setShowInvoiceDetails(true);
|
||||
};
|
||||
setSelectedInvoice(invoice)
|
||||
setShowInvoiceDetails(true)
|
||||
}
|
||||
|
||||
const handleConvertFromWaybill = () => {
|
||||
setShowWaybillToInvoice(true);
|
||||
};
|
||||
setShowWaybillToInvoice(true)
|
||||
}
|
||||
|
||||
const handleSaveInvoice = (invoiceData: Partial<FiInvoice>) => {
|
||||
if (editingInvoice) {
|
||||
|
|
@ -61,9 +56,9 @@ const InvoicePage: React.FC = () => {
|
|||
prev.map((inv) =>
|
||||
inv.id === editingInvoice.id
|
||||
? { ...inv, ...invoiceData, lastModificationTime: new Date() }
|
||||
: inv
|
||||
: inv,
|
||||
),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
// Yeni ekleme
|
||||
const newInvoice: FiInvoice = {
|
||||
|
|
@ -71,15 +66,15 @@ const InvoicePage: React.FC = () => {
|
|||
creationTime: new Date(),
|
||||
lastModificationTime: new Date(),
|
||||
...invoiceData,
|
||||
} as FiInvoice;
|
||||
setInvoices((prev) => [newInvoice, ...prev]);
|
||||
} as FiInvoice
|
||||
setInvoices((prev) => [newInvoice, ...prev])
|
||||
}
|
||||
setShowInvoiceForm(false)
|
||||
setEditingInvoice(null)
|
||||
}
|
||||
setShowInvoiceForm(false);
|
||||
setEditingInvoice(null);
|
||||
};
|
||||
|
||||
const handleSavePayment = (paymentData: PaymentData) => {
|
||||
if (!selectedInvoice) return;
|
||||
if (!selectedInvoice) return
|
||||
|
||||
// Ödeme bilgilerini faturaya ekle
|
||||
const updatedInvoice = {
|
||||
|
|
@ -91,50 +86,48 @@ const InvoicePage: React.FC = () => {
|
|||
? PaymentStatusEnum.Paid
|
||||
: PaymentStatusEnum.PartiallyPaid,
|
||||
lastModificationTime: new Date(),
|
||||
};
|
||||
}
|
||||
|
||||
setInvoices((prev) =>
|
||||
prev.map((inv) => (inv.id === selectedInvoice.id ? updatedInvoice : inv))
|
||||
);
|
||||
setInvoices((prev) => prev.map((inv) => (inv.id === selectedInvoice.id ? updatedInvoice : inv)))
|
||||
|
||||
setShowPaymentForm(false);
|
||||
setSelectedInvoice(null);
|
||||
setShowPaymentForm(false)
|
||||
setSelectedInvoice(null)
|
||||
|
||||
// Başarı mesajı
|
||||
alert(
|
||||
`${paymentData.amount.toLocaleString("tr-TR", {
|
||||
style: "currency",
|
||||
currency: "TRY",
|
||||
})} tutarında ödeme kaydedildi.`
|
||||
);
|
||||
};
|
||||
`${paymentData.amount.toLocaleString('tr-TR', {
|
||||
style: 'currency',
|
||||
currency: 'TRY',
|
||||
})} tutarında ödeme kaydedildi.`,
|
||||
)
|
||||
}
|
||||
|
||||
const handleSaveFromWaybill = () => {
|
||||
setShowWaybillToInvoice(false);
|
||||
alert("İrsaliyelerden fatura başarıyla oluşturuldu.");
|
||||
};
|
||||
setShowWaybillToInvoice(false)
|
||||
alert('İrsaliyelerden fatura başarıyla oluşturuldu.')
|
||||
}
|
||||
|
||||
const handleCancelForm = () => {
|
||||
setShowInvoiceForm(false);
|
||||
setEditingInvoice(null);
|
||||
};
|
||||
setShowInvoiceForm(false)
|
||||
setEditingInvoice(null)
|
||||
}
|
||||
|
||||
const handleCancelDetails = () => {
|
||||
setShowInvoiceDetails(false);
|
||||
setSelectedInvoice(null);
|
||||
};
|
||||
setShowInvoiceDetails(false)
|
||||
setSelectedInvoice(null)
|
||||
}
|
||||
|
||||
const handleCancelPayment = () => {
|
||||
setShowPaymentForm(false);
|
||||
setSelectedInvoice(null);
|
||||
};
|
||||
setShowPaymentForm(false)
|
||||
setSelectedInvoice(null)
|
||||
}
|
||||
|
||||
const handleCancelWaybillToInvoice = () => {
|
||||
setShowWaybillToInvoice(false);
|
||||
};
|
||||
setShowWaybillToInvoice(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Container>
|
||||
<InvoiceManagement
|
||||
invoices={invoices}
|
||||
onAdd={handleAdd}
|
||||
|
|
@ -173,8 +166,8 @@ const InvoicePage: React.FC = () => {
|
|||
onInvoiceCreated={handleSaveFromWaybill}
|
||||
isVisible={showWaybillToInvoice}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
</Container>
|
||||
)
|
||||
}
|
||||
|
||||
export default InvoicePage;
|
||||
export default InvoicePage
|
||||
|
|
|
|||
|
|
@ -1,39 +1,38 @@
|
|||
import React, { useState } from "react";
|
||||
import WaybillManagement from "./components/WaybillManagement";
|
||||
import WaybillForm from "./components/WaybillForm";
|
||||
import WaybillDetails from "./components/WaybillDetails";
|
||||
import WaybillToInvoice from "./components/WaybillToInvoice";
|
||||
import { FiWaybill, WaybillStatusEnum } from "../../types/fi";
|
||||
import { mockWaybills } from "../../mocks/mockWaybills";
|
||||
import React, { useState } from 'react'
|
||||
import WaybillManagement from './components/WaybillManagement'
|
||||
import WaybillForm from './components/WaybillForm'
|
||||
import WaybillDetails from './components/WaybillDetails'
|
||||
import WaybillToInvoice from './components/WaybillToInvoice'
|
||||
import { FiWaybill, WaybillStatusEnum } from '../../types/fi'
|
||||
import { mockWaybills } from '../../mocks/mockWaybills'
|
||||
import { Container } from '@/components/shared'
|
||||
|
||||
type ViewType = "management" | "form" | "details" | "createInvoice";
|
||||
type ViewType = 'management' | 'form' | 'details' | 'createInvoice'
|
||||
|
||||
const WaybillPage: React.FC = () => {
|
||||
const [currentView, setCurrentView] = useState<ViewType>("management");
|
||||
const [waybills, setWaybills] = useState<FiWaybill[]>(mockWaybills);
|
||||
const [selectedWaybill, setSelectedWaybill] = useState<
|
||||
FiWaybill | undefined
|
||||
>();
|
||||
const [currentView, setCurrentView] = useState<ViewType>('management')
|
||||
const [waybills, setWaybills] = useState<FiWaybill[]>(mockWaybills)
|
||||
const [selectedWaybill, setSelectedWaybill] = useState<FiWaybill | undefined>()
|
||||
|
||||
const handleAdd = () => {
|
||||
setSelectedWaybill(undefined);
|
||||
setCurrentView("form");
|
||||
};
|
||||
setSelectedWaybill(undefined)
|
||||
setCurrentView('form')
|
||||
}
|
||||
|
||||
const handleEdit = (waybill: FiWaybill) => {
|
||||
setSelectedWaybill(waybill);
|
||||
setCurrentView("form");
|
||||
};
|
||||
setSelectedWaybill(waybill)
|
||||
setCurrentView('form')
|
||||
}
|
||||
|
||||
const handleViewDetails = (waybill: FiWaybill) => {
|
||||
setSelectedWaybill(waybill);
|
||||
setCurrentView("details");
|
||||
};
|
||||
setSelectedWaybill(waybill)
|
||||
setCurrentView('details')
|
||||
}
|
||||
|
||||
const handleCreateInvoice = (waybill: FiWaybill) => {
|
||||
setSelectedWaybill(waybill);
|
||||
setCurrentView("createInvoice");
|
||||
};
|
||||
setSelectedWaybill(waybill)
|
||||
setCurrentView('createInvoice')
|
||||
}
|
||||
|
||||
const handleMarkAsDelivered = (waybill: FiWaybill) => {
|
||||
setWaybills((prev) =>
|
||||
|
|
@ -44,13 +43,11 @@ const WaybillPage: React.FC = () => {
|
|||
status: WaybillStatusEnum.Delivered,
|
||||
lastModificationTime: new Date(),
|
||||
}
|
||||
: w
|
||||
: w,
|
||||
),
|
||||
)
|
||||
);
|
||||
alert(
|
||||
`${waybill.waybillNumber} numaralı irsaliye teslim edildi olarak işaretlendi.`
|
||||
);
|
||||
};
|
||||
alert(`${waybill.waybillNumber} numaralı irsaliye teslim edildi olarak işaretlendi.`)
|
||||
}
|
||||
|
||||
const handleSaveWaybill = (waybillData: Partial<FiWaybill>) => {
|
||||
if (selectedWaybill) {
|
||||
|
|
@ -62,9 +59,9 @@ const WaybillPage: React.FC = () => {
|
|||
...waybillData,
|
||||
lastModificationTime: new Date(),
|
||||
}
|
||||
: w
|
||||
);
|
||||
setWaybills(updatedWaybills);
|
||||
: w,
|
||||
)
|
||||
setWaybills(updatedWaybills)
|
||||
} else {
|
||||
// Create new waybill
|
||||
const newWaybill: FiWaybill = {
|
||||
|
|
@ -72,17 +69,17 @@ const WaybillPage: React.FC = () => {
|
|||
id: Date.now().toString(),
|
||||
creationTime: new Date(),
|
||||
lastModificationTime: new Date(),
|
||||
};
|
||||
setWaybills([...waybills, newWaybill]);
|
||||
}
|
||||
setCurrentView("management");
|
||||
setSelectedWaybill(undefined);
|
||||
};
|
||||
setWaybills([...waybills, newWaybill])
|
||||
}
|
||||
setCurrentView('management')
|
||||
setSelectedWaybill(undefined)
|
||||
}
|
||||
|
||||
const handleCancel = () => {
|
||||
setCurrentView("management");
|
||||
setSelectedWaybill(undefined);
|
||||
};
|
||||
setCurrentView('management')
|
||||
setSelectedWaybill(undefined)
|
||||
}
|
||||
|
||||
const handleInvoiceCreated = () => {
|
||||
// Mark waybill as invoiced
|
||||
|
|
@ -90,17 +87,17 @@ const WaybillPage: React.FC = () => {
|
|||
const updatedWaybills = waybills.map((w) =>
|
||||
w.id === selectedWaybill.id
|
||||
? { ...w, isInvoiced: true, lastModificationTime: new Date() }
|
||||
: w
|
||||
);
|
||||
setWaybills(updatedWaybills);
|
||||
: w,
|
||||
)
|
||||
setWaybills(updatedWaybills)
|
||||
}
|
||||
setCurrentView('management')
|
||||
setSelectedWaybill(undefined)
|
||||
}
|
||||
setCurrentView("management");
|
||||
setSelectedWaybill(undefined);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{currentView === "management" && (
|
||||
<Container>
|
||||
{currentView === 'management' && (
|
||||
<WaybillManagement
|
||||
waybills={waybills}
|
||||
onAdd={handleAdd}
|
||||
|
|
@ -115,7 +112,7 @@ const WaybillPage: React.FC = () => {
|
|||
waybill={selectedWaybill}
|
||||
onSave={handleSaveWaybill}
|
||||
onCancel={handleCancel}
|
||||
isVisible={currentView === "form"}
|
||||
isVisible={currentView === 'form'}
|
||||
/>
|
||||
|
||||
{selectedWaybill && (
|
||||
|
|
@ -123,7 +120,7 @@ const WaybillPage: React.FC = () => {
|
|||
waybill={selectedWaybill}
|
||||
onClose={handleCancel}
|
||||
onCreateInvoice={() => handleCreateInvoice(selectedWaybill)}
|
||||
isVisible={currentView === "details"}
|
||||
isVisible={currentView === 'details'}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
|
@ -132,11 +129,11 @@ const WaybillPage: React.FC = () => {
|
|||
selectedWaybills={[selectedWaybill.id]}
|
||||
onClose={handleCancel}
|
||||
onInvoiceCreated={handleInvoiceCreated}
|
||||
isVisible={currentView === "createInvoice"}
|
||||
isVisible={currentView === 'createInvoice'}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
</Container>
|
||||
)
|
||||
}
|
||||
|
||||
export default WaybillPage;
|
||||
export default WaybillPage
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue