Skip to content

Commit

Permalink
Merge pull request #2039 from CAFECA-IO/feature/test_repo
Browse files Browse the repository at this point in the history
Feature/test repo
  • Loading branch information
Luphia authored Aug 12, 2024
2 parents 0b478c0 + 6102221 commit 2c0fd36
Show file tree
Hide file tree
Showing 25 changed files with 584 additions and 97 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iSunFA",
"version": "0.8.0+2",
"version": "0.8.0+3",
"private": false,
"scripts": {
"dev": "next dev",
Expand Down
16 changes: 16 additions & 0 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,23 @@ import clients from '@/seed_json/client.json';
import journals from '@/seed_json/journal.json';
import vouchers from '@/seed_json/voucher.json';
import lineItems from '@/seed_json/line_item.json';
import salaryRecords from '@/seed_json/salary_record.json';
import voucherSalaryRecordFolder from '@/seed_json/voucher_salary_record_folder.json';

const prisma = new PrismaClient();

async function createSalaryRecord() {
await prisma.salaryRecord.createMany({
data: salaryRecords,
});
}

async function createVoucherSalaryRecordFolder() {
await prisma.voucherSalaryRecordFolder.createMany({
data: voucherSalaryRecordFolder,
});
}

async function createMilestones() {
await prisma.milestone.createMany({
data: milestones,
Expand Down Expand Up @@ -275,6 +289,8 @@ async function main() {
setTimeout(resolve, 3000);
});
await createLineItems();
await createSalaryRecord();
await createVoucherSalaryRecordFolder();
}

main()
Expand Down
3 changes: 2 additions & 1 deletion prisma/seed_json/employee.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"startDate": 1630435200,
"endDate": null,
"createdAt": 1630435200,
"updatedAt": 1630435200
"updatedAt": 1630435200,
"deletedAt": null
},
{
"id": 1001,
Expand Down
26 changes: 25 additions & 1 deletion prisma/seed_json/income_expense.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
[
[
{
"income": 500,
"expense": 400,
"companyId": 1000,
"projectId": 1001,
"createdAt": 1682933165,
"updatedAt": 1682933165
},
{
"income": 1010,
"expense": 510,
"companyId": 1000,
"projectId": 1001,
"createdAt": 1711911019,
"updatedAt": 1711911019
},
{
"income": 1000,
"expense": 500,
"companyId": 1000,
"projectId": 1001,
"createdAt": 1711997419,
"updatedAt": 1711997419
},
{
"income": 500,
"expense": 400,
Expand Down
7 changes: 7 additions & 0 deletions prisma/seed_json/journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,12 @@
"createdAt": 1,
"updatedAt": 1,
"event": "JOURNAL.UPLOADED"
},
{
"id": 1006,
"companyId": 8867,
"createdAt": 1723188860,
"updatedAt": 1723188860,
"event": "JOURNAL.UPLOADED"
}
]
17 changes: 17 additions & 0 deletions prisma/seed_json/salary_record.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"id": 1000,
"employeeId": 1000,
"startDate": 1630405200,
"endDate": 1630895200,
"salary": 40000,
"insurancePayment": 400,
"bonus": 890,
"description": "salary",
"workingHour": 80,
"confirmed": true,
"createdAt": 1630435200,
"updatedAt": 1630435200,
"deletedAt": null
}
]
9 changes: 8 additions & 1 deletion prisma/seed_json/voucher.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,12 @@
"no": "20240101006",
"createdAt": 1,
"updatedAt": 1
},
{
"id": 1006,
"journalId": 1006,
"no": "20240809001",
"createdAt": 1723188860,
"updatedAt": 1723188860
}
]
]
10 changes: 10 additions & 0 deletions prisma/seed_json/voucher_salary_record_folder.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"id": 10000099,
"name": "Salary Voucher: 20240809001",
"createdAt": 1723188860,
"updatedAt": 1723188860,
"companyId": 8867,
"deletedAt": null
}
]
2 changes: 1 addition & 1 deletion src/components/journal_list_body/journal_list_body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const JournalListBody = () => {
endDate: !(period ?? filteredPeriod).endTimeStamp
? undefined
: (period ?? filteredPeriod).endTimeStamp,
searchQuery: !(searchString ?? search) ? undefined : (searchString ?? search),
searchQuery: !(searchString ?? search) ? undefined : searchString ?? search,
},
});

Expand Down
2 changes: 1 addition & 1 deletion src/components/nav_bar/nav_bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ const NavBar = () => {
</button>
<div className="mt-3 flex justify-center gap-0 px-16">
<div className="my-auto text-base font-semibold leading-6 tracking-normal text-button-text-secondary">
{signedIn ? (username ?? DEFAULT_DISPLAYED_USER_NAME) : ''}
{signedIn ? username ?? DEFAULT_DISPLAYED_USER_NAME : ''}
</div>
{/* Info: edit name button (20240809 - Shirley) */}
<button
Expand Down
16 changes: 8 additions & 8 deletions src/components/new_journal_form/new_journal_form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ const getIdAndName = (id: number | null, array: { id: number | null; name: strin
const idAndName =
obj === undefined
? {
id: array[0].id,
name: array[0].name,
}
id: array[0].id,
name: array[0].name,
}
: {
id: obj.id,
name: obj.name,
};
id: obj.id,
name: obj.name,
};
return idAndName;
};

Expand Down Expand Up @@ -244,11 +244,11 @@ const NewJournalForm = () => {
setInputPartialPaid(OCRResult.payment.alreadyPaid);
setSelectedProject(
projectSelection.find((project) => project.id === OCRResult.projectId) ||
projectSelection[0]
projectSelection[0]
);
setSelectedContract(
contractSelection.find((contract) => contract.id === OCRResult.contractId) ||
contractSelection[0]
contractSelection[0]
);
setProgressRate(OCRResult.payment.progress);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/step_one_tab/step_one_tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const StepOneTab = () => {
setFileList(OCRList);
}

return () => { };
return () => {};
}, [OCRList, OCRListStatus]);

const handleOCRClick = (unprocessOCR: IOCR) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/uploaded_file_item/uploaded_file_item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const UploadedFileItem = ({
// status === ProgressStatus.IN_PROGRESS ||
// status === ProgressStatus.SUCCESS ||
// status === ProgressStatus.PAUSED
imageUrl && imageUrl.length > 0
(imageUrl && imageUrl.length > 0)
);

const pauseClickHandler = (event: React.MouseEvent<HTMLButtonElement>) => {
Expand Down
106 changes: 53 additions & 53 deletions src/lib/utils/repo/payment.beta.repo.ts
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
import { IPaymentBeta } from "@/interfaces/payment";
import prisma from "@/client";
import { Prisma, Payment } from "@prisma/client";
import { getTimestampNow } from "@/lib/utils/common";
import { IPaymentBeta } from '@/interfaces/payment';
import prisma from '@/client';
import { Prisma, Payment } from '@prisma/client';
import { getTimestampNow } from '@/lib/utils/common';

export async function createPayment(payment: IPaymentBeta) {
let result: Payment | null = null;
const nowInSecond = getTimestampNow();

const data: Prisma.PaymentCreateInput = {
...payment,
createdAt: nowInSecond,
updatedAt: nowInSecond,
deletedAt: null,
};

const paymentCreateArgs = {
data,
};

try {
result = await prisma.payment.create(paymentCreateArgs);
} catch (error) {
// Deprecate: ( 20240605 - Murky ) Debugging purpose
// eslint-disable-next-line no-console
console.log(error);
}

return result;
let result: Payment | null = null;
const nowInSecond = getTimestampNow();

const data: Prisma.PaymentCreateInput = {
...payment,
createdAt: nowInSecond,
updatedAt: nowInSecond,
deletedAt: null,
};

const paymentCreateArgs = {
data,
};

try {
result = await prisma.payment.create(paymentCreateArgs);
} catch (error) {
// Deprecate: ( 20240605 - Murky ) Debugging purpose
// eslint-disable-next-line no-console
console.log(error);
}

return result;
}

export async function updatePayment(paymentId: number, payment: IPaymentBeta) {
let result: Payment | null = null;
const nowInSecond = getTimestampNow();

const data: Prisma.PaymentUpdateInput = {
...payment,
updatedAt: nowInSecond,
};

const where: Prisma.PaymentWhereUniqueInput = {
id: paymentId,
};

const paymentUpdateArgs = {
where,
data,
};

try {
result = await prisma.payment.update(paymentUpdateArgs);
} catch (error) {
// Deprecate: ( 20240605 - Murky ) Debugging purpose
// eslint-disable-next-line no-console
console.log(error);
}

return result;
let result: Payment | null = null;
const nowInSecond = getTimestampNow();

const data: Prisma.PaymentUpdateInput = {
...payment,
updatedAt: nowInSecond,
};

const where: Prisma.PaymentWhereUniqueInput = {
id: paymentId,
};

const paymentUpdateArgs = {
where,
data,
};

try {
result = await prisma.payment.update(paymentUpdateArgs);
} catch (error) {
// Deprecate: ( 20240605 - Murky ) Debugging purpose
// eslint-disable-next-line no-console
console.log(error);
}

return result;
}
12 changes: 12 additions & 0 deletions src/lib/utils/repo_test/department.repo.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { getDepartments } from '@/lib/utils/repo/department.repo';
import departmentRecords from '@/seed_json/department.json';

describe('Department Repository Tests', () => {
describe('getDepartments', () => {
it('should get department records', async () => {
const departments = await getDepartments();
expect(departments).toBeDefined();
expect(departments).toEqual(departmentRecords.map((department) => department.name));
});
});
});
Loading

0 comments on commit 2c0fd36

Please sign in to comment.