Skip to content

Commit

Permalink
fix: invoice details
Browse files Browse the repository at this point in the history
  • Loading branch information
kimthu09 committed Jan 15, 2024
1 parent b641122 commit 7e110ed
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 44 deletions.
66 changes: 48 additions & 18 deletions frontend/app/invoice/[invoiceId]/detail-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,59 @@ const DetailLayout = (responseData: any) => {
width={36}
height={36}
></Image>
<h1 className="text-3xl uppercase font-medium">{shop.name}</h1>
<h1 className="xl:text-3xl text-2xl uppercase font-medium">
{shop.name}
</h1>
</div>
{shop.address && shop.address !== "" ? (
<span className="text-lg uppercase font-medium">
<span className="text-base uppercase font-medium printScreen">
Địa chỉ: {shop.address}
</span>
) : null}
{shop.phone && shop.phone !== "" ? (
<span className="text-base font-medium">
<span className="text-base font-medium printScreen">
Số điện thoại: {shop.phone}
</span>
) : null}
{shop.wifiPass && shop.wifiPass !== "" ? (
<span className="text-base font-light">
<span className="text-base font-light printScreen">
Wifi: {shop.wifiPass}
</span>
) : null}
</div>

<div className="flex flex-row justify-between p-4 mb-6 border rounded-md">
<div className="flex flex-col items-end gap-2 text-sm">
<div className="flex flex-col items-stretch gap-2 text-sm">
<div className="flex gap-2">
<span className="font-light">Mã hóa đơn:</span>
<span className="font-light w-[6rem]">Mã hóa đơn:</span>
<span className="font-semibold">{responseData.invoice.id}</span>
</div>
{responseData.invoice.customer && (
<>
<div className="flex gap-2">
<span className="font-light w-[6rem] whitespace-nowrap">
Khách hàng:
</span>
<div className="font-semibold flex flex-col">
{responseData.invoice.customer.name}
<span className="font-normal">
({responseData.invoice.customer.phone})
</span>
</div>
</div>
<div className="flex gap-2">
<span className="font-light w-[6rem] whitespace-nowrap">
Điểm:
</span>
<div className="font-semibold flex gap-2 text-green-700">
+{" "}
{responseData.invoice.pointReceive.toLocaleString(
"vi-VN"
)}
</div>
</div>
</>
)}
</div>

<div className="flex flex-col items-end gap-2 text-sm">
Expand All @@ -90,19 +118,21 @@ const DetailLayout = (responseData: any) => {
<div className="flex flex-col gap-4">
<InvoiceDetailTable details={details} />
<div className="flex flex-col gap-2">
<div className="grid grid-cols-2 space-x-2 font-semibold">
<span className="min-w-[6rem]">Tổng tiền: </span>
<span className="text-right">
{toVND(responseData.invoice.totalPrice)}
</span>
</div>
{responseData.invoice.amountPriceUsePoint !== 0 ? (
<div className="grid grid-cols-2 space-x-2 font-semibold">
<span className="min-w-[6rem]">Giảm: </span>
<span className="text-right">
- {toVND(responseData.invoice.amountPriceUsePoint)}
</span>
</div>
<>
<div className="grid grid-cols-2 space-x-2 font-semibold">
<span className="min-w-[6rem]">Tổng tiền: </span>
<span className="text-right">
{toVND(responseData.invoice.totalPrice)}
</span>
</div>
<div className="grid grid-cols-2 space-x-2 font-semibold">
<span className="min-w-[6rem]">Giảm: </span>
<span className="text-right">
- {toVND(responseData.invoice.amountPriceUsePoint)}
</span>
</div>
</>
) : null}
<div className="grid grid-cols-2 space-x-2 font-semibold">
<span className="min-w-[6rem]">Thành tiền: </span>
Expand Down
1 change: 1 addition & 0 deletions frontend/app/sale/page-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ const SaleScreen = () => {
details: [],
});
mutate(`${endPoint}/v1/customers/all`);
mutate(`${endPoint}/v1/books/all`);
router.refresh();
}
};
Expand Down
15 changes: 14 additions & 1 deletion frontend/app/setting/detail-layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"use client";
import ConfirmDialog from "@/components/confirm-dialog";
import Loading from "@/components/loading";
import { Button } from "@/components/ui/button";
import { Card, CardContent } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
Expand Down Expand Up @@ -255,6 +254,20 @@ const DetailLayout = () => {
)}
</div>
</div>
<div className="basis-2/3">
<Label htmlFor="add">Địa chỉ</Label>
<Input
id="add"
readOnly={readOnly}
defaultValue={shop?.address ?? ""}
{...register("address")}
></Input>
{errors.address && (
<span className="error___message">
{errors.address.message}
</span>
)}
</div>
<div className="flex gap-4 lg:flex-row flex-col">
<div className="basis-1/2">
<Label htmlFor="accumulatePointPercent">
Expand Down
12 changes: 7 additions & 5 deletions frontend/components/invoice/invoice-detail-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,20 @@ export const columns: ColumnDef<InvoiceDetailProps>[] = [
{
accessorKey: "name",
header: () => {
return <span className="font-semibold">Tên sách</span>;
return <span className="font-semibold ">Tên sách</span>;
},
cell: ({ row }) => (
<div className="leading-6 flex flex-col">{row.original.book.name}</div>
<div className="leading-6 flex flex-col 2xl:max-w-[20rem] xl:max-w-[14rem] max-w-[8rem]">
{row.original.book.name}
</div>
),
size: 4,
},
{
accessorKey: "amountImport",
header: ({ column }) => (
<div className="flex justify-end whitespace-normal">
<span className="font-semibold">Số lượng</span>
<span className="font-semibold">SL</span>
</div>
),
cell: ({ row }) => {
Expand Down Expand Up @@ -145,8 +147,8 @@ export function InvoiceDetailTable({
},
});
return (
<div className="rounded-md border w-full">
<Table>
<div className="rounded-md border overflow-x-auto min-w-full max-w-[40vw]">
<Table className="min-w-full w-max">
<TableHeader>
{table.getHeaderGroups().map((headerGroup) => (
<TableRow key={headerGroup.id}>
Expand Down
56 changes: 42 additions & 14 deletions frontend/components/invoice/print-invoice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,39 @@ const PrintInvoice = ({
</div>

<div className="flex flex-row justify-between p-4 mb-6 border rounded-md">
<div className="flex flex-col items-end gap-2 text-sm">
<div className="flex flex-col items-stretch gap-2 text-sm">
<div className="flex gap-2">
<span className="font-light">Mã hóa đơn:</span>
<span className="font-light w-[6rem]">Mã hóa đơn:</span>
<span className="font-semibold">
{responseData.invoice.id}
</span>
</div>
{responseData.invoice.customer && (
<>
<div className="flex gap-2">
<span className="font-light w-[6rem] whitespace-nowrap">
Khách hàng:
</span>
<div className="font-semibold flex flex-col">
{responseData.invoice.customer.name}
<span className="font-normal">
({responseData.invoice.customer.phone})
</span>
</div>
</div>
<div className="flex gap-2">
<span className="font-light w-[6rem] whitespace-nowrap">
Điểm:
</span>
<div className="font-semibold flex gap-2 text-green-700">
+{" "}
{responseData.invoice.pointReceive.toLocaleString(
"vi-VN"
)}
</div>
</div>
</>
)}
</div>

<div className="flex flex-col items-end gap-2 text-sm">
Expand All @@ -96,19 +122,21 @@ const PrintInvoice = ({
<div className="flex flex-col gap-4">
<InvoiceDetailTable details={details} />
<div className="flex flex-col gap-2">
<div className="grid grid-cols-2 space-x-2 font-semibold">
<span className="min-w-[6rem]">Tổng tiền: </span>
<span className="text-right">
{toVND(responseData.invoice.totalPrice)}
</span>
</div>
{responseData.invoice.amountPriceUsePoint !== 0 ? (
<div className="grid grid-cols-2 space-x-2 font-semibold">
<span className="min-w-[6rem]">Giảm: </span>
<span className="text-right">
- {toVND(responseData.invoice.amountPriceUsePoint)}
</span>
</div>
<>
<div className="grid grid-cols-2 space-x-2 font-semibold">
<span className="min-w-[6rem]">Tổng tiền: </span>
<span className="text-right">
{toVND(responseData.invoice.totalPrice)}
</span>
</div>
<div className="grid grid-cols-2 space-x-2 font-semibold">
<span className="min-w-[6rem]">Giảm: </span>
<span className="text-right">
- {toVND(responseData.invoice.amountPriceUsePoint)}
</span>
</div>
</>
) : null}
<div className="grid grid-cols-2 space-x-2 font-semibold">
<span className="min-w-[6rem]">Thành tiền: </span>
Expand Down
1 change: 0 additions & 1 deletion frontend/components/invoice/table-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const TableLayout = async ({
search: search?.toString(),
});
const staffs = await staffsData;
console.log(staffs);
const totalPage = Math.ceil(staffs.paging.total / staffs.paging.limit);
return <InvoiceTable data={staffs.data} totalPage={totalPage} />;
};
Expand Down
6 changes: 5 additions & 1 deletion frontend/components/sale/bill-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,11 @@ const BillTab = ({
field.value.customerId !== "" &&
shop && (
<Label>
Dùng {field.value.customerPoint} điểm (giảm{" "}
Dùng{" "}
{field.value.customerPoint.toLocaleString(
"vi-VN"
)}{" "}
điểm (giảm{" "}
{toVND(
field.value.customerPoint *
(shop?.usePointPercent ?? 0)
Expand Down
2 changes: 2 additions & 0 deletions frontend/components/staff/change-image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const ChangeImage = ({
});
console.log("file không hợp lệ");
}
} else {
setImage(null);
}
};
const [open, setOpen] = useState(false);
Expand Down
2 changes: 2 additions & 0 deletions frontend/components/staff/create-staff-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ const CreateStaffDialog = () => {
});
console.log("file không hợp lệ");
}
} else {
setImage(null);
}
};

Expand Down
3 changes: 0 additions & 3 deletions frontend/components/supplier-manage/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,12 @@ const CreateDialog = ({
const responseData = await response;
hideLoading();
if (responseData.hasOwnProperty("errorKey")) {
console.log("hi");
toast({
variant: "destructive",
title: "Có lỗi",
description: responseData.message,
});
} else {
console.log("there");

toast({
variant: "success",
title: "Thành công",
Expand Down
1 change: 0 additions & 1 deletion frontend/lib/shop-general/getShopGeneral.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { getApiKey } from "../auth/action";

export default async function getShopGeneral() {
const url = `${endPoint}/v1/shop`;
console.log(url);
const token = await getApiKey();
const res = await fetch(url, {
headers: {
Expand Down

0 comments on commit 7e110ed

Please sign in to comment.