You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

67 rivejä
1.5 KiB

  1. "use server"
  2. import { serverFetchJson } from "@/app/utils/fetchUtil";
  3. import { BASE_API_URL } from "@/config/api";
  4. import { cache } from "react";
  5. export interface InvoiceResult {
  6. id: number;
  7. projectCode: string;
  8. projectName: string;
  9. stage: string;
  10. comingPaymentMileStone: string;
  11. paymentMilestoneDate: string;
  12. resourceUsage: number;
  13. unbilledHours: number;
  14. reminder: string;
  15. }
  16. export interface CreateInvoiceInputs {
  17. id: number;
  18. // Project Details
  19. projectCode: string;
  20. projectName: string;
  21. stage: string;
  22. comingPaymentMileStone: string;
  23. paymentMilestoneDate: string;
  24. resourceUsage: number;
  25. unbilledHours: number;
  26. // Invoice Info
  27. client: string;
  28. address: string;
  29. attention: string;
  30. invoiceDate: string;
  31. dueDate: string;
  32. projectRefNo: string;
  33. // Invoice related Info
  34. reminder: string;
  35. amount: number;
  36. billHours: number;
  37. }
  38. export interface InvoiceInformation{
  39. id: number;
  40. client: string;
  41. address: string;
  42. attention: string;
  43. invoiceDate: string;
  44. dueDate: string;
  45. projectRefNo: string;
  46. amount: number;
  47. }
  48. export const fetchProjectInvoiceById = cache(async (id: number) => {
  49. return serverFetchJson<InvoiceResult[]>(`${BASE_API_URL}/invoices/getProjectDetail/${id}`, {
  50. next: { tags: ["projectDetailById"] },
  51. });
  52. })
  53. export const fetchInvoiceInfoById = cache(async (id: number) => {
  54. return serverFetchJson<InvoiceInformation[]>(`${BASE_API_URL}/invoices/getInvoiceInfo/${id}`, {
  55. next: { tags: ["invoiceInfoById"] },
  56. });
  57. })