Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] - Database schema voucher, certificate, askai #2707

Closed
1 task
TinyMurky opened this issue Oct 4, 2024 · 4 comments · Fixed by #2762
Closed
1 task

[FEATURE] - Database schema voucher, certificate, askai #2707

TinyMurky opened this issue Oct 4, 2024 · 4 comments · Fixed by #2762
Assignees
Labels
5 hard level 5 enhancement New feature or request

Comments

@TinyMurky
Copy link
Contributor

Summary

Database schema voucher, certificate, askai

Tasks

  • Database schema voucher, certificate, askai

Dependencies

No response

Other Dependencies

No response

Additional Notes

No response

@TinyMurky TinyMurky added enhancement New feature or request 5 hard level 5 labels Oct 4, 2024
@TinyMurky TinyMurky self-assigned this Oct 4, 2024
@RexBearIU RexBearIU self-assigned this Oct 4, 2024
@RexBearIU
Copy link
Contributor

Murky write the change for schema and I write the docs and code

@TinyMurky
Copy link
Contributor Author

TinyMurky commented Oct 4, 2024

model InvoiceV2 {
  id             Int     @id @default(autoincrement())
  inputOrOutput  String  @map("inpt_or_output") // Info: (20241004 - Murky) ex: "input", "output"
  invoiceDate    Int     @map("invoice_date")
  invoiceNo      String  @map("invoice_no") // Info: (20241004 - Murky) ex: "AB-12345678"
  currencyAlias  String  @map("currency_alias") // Info: (20241004 - Murky) ex: "TWD"
  priceBeforeTax Float   @map("price_before_tax")
  taxRatio       Float   @map("tax_ratio") // Info: (20241004 - Murky) 5 means 5%
  taxPrice       Float   @map("tax_price")
  invoiceType    String  @map("invoice_type") // Info: (20241004 - Murky) ex: "triplicate_uniform_invoice"
  deductible     Boolean @map("deductible") // Info: (20241004 - Murky) true: it can be used to deduct output tax

  counterPartyId Int @map("counter_party_id") // connect to counter party

  createdAt Int  @map("created_at")
  updatedAt Int  @map("updated_at")
  deletedAt Int? @map("deleted_at")

  certificateId Int         @map("certificate_id") // connect to certificate
  certificate   Certificate @relation(fields: [certificateId], references: [id])
}

model Certificate {
  id        Int  @id @default(autoincrement())
  createdAt Int  @map("created_at")
  updatedAt Int  @map("updated_at")
  deletedAt Int? @map("deleted_at")

  fileId             Int                  @map("file_id")
  voucherCertificate voucherCertificate[]
  invoiceV2          InvoiceV2[]

  @@map("certificate")
}

model Event {
  // Info (20241004 - Murky) This is for recursive voucher and asset
  id           Int      @id @default(autoincrement())
  eventType    String   @map("event_type") // Info (20241004 - Murky) ex: "asset", "recursiveVoucher"
  frequence    String   @map("frequence") // Info (20241004 - Murky) ex: "month", "week"
  startDate    Int      @map("start_date") // Info (20241004 - Murky) the start date of the event
  endDate      Int      @map("end_date") // Info (20241004 - Murky) the end date of the event
  daysOfWeek   Int[]    @map("days_of_week") // Info (20241004 - Murky) the days of week that the event will be trigger
  monthsOfYear String[] @map("months_of_year") // Info (20241004 - Murky) the months of year that the event will be trigger

  createdAt    Int            @map("created_at")
  updatedAt    Int            @map("updated_at")
  deletedAt    Int?           @map("deleted_at")
  eventVoucher eventVoucher[]
}

model voucherCertificate {
  id        Int  @id @default(autoincrement())
  createdAt Int  @map("created_at")
  updatedAt Int  @map("updated_at")
  deletedAt Int? @map("deleted_at")

  voucherId     Int @map("voucher_id")
  certificateId Int @map("certificate_id")

  voucher     VoucherV2   @relation(fields: [voucherId], references: [id])
  certificate Certificate @relation(fields: [certificateId], references: [id])

  @@map("voucher_certificate")
}

model associateVoucher {
  id                 Int    @id @default(autoincrement())
  reason             String // Info (20241004 - Murky) ex: "revert", "payable", "receivable"
  originalVoucherId  Int    @map("original_voucher_id")
  associateVoucherId Int    @map("reverted_voucher_id")

  createdAt Int  @map("created_at")
  updatedAt Int  @map("updated_at")
  deletedAt Int? @map("deleted_at")

  originalVoucher  VoucherV2 @relation("original_voucher", fields: [originalVoucherId], references: [id])
  associateVoucher VoucherV2 @relation("associate_voucher", fields: [associateVoucherId], references: [id])

  @@map("associate_voucher")
}

// model paymentOrReceivingInfo {
//   id              Int    @id @default(autoincrement())
//   type            String // Info (20241004 - Murky) ex: "payment", "receiving"
//   total           Float // Info (20241004 - Murky) the total amount of the payment or receiving
//   alreadyHappened Float  @map("already_happened") // Info (20241004 - Murky) the amount that already happened
//   createdAt       Int    @map("created_at")
//   updatedAt       Int    @map("updated_at")
//   deletedAt       Int?   @map("deleted_at")

//   voucherV2Id Int       @unique
//   VoucherV2   VoucherV2 @relation(fields: [voucherV2Id], references: [id])

//   @@map("payment_or_receiving_info")
// }

model eventVoucher {
  id                  Int @id @default(autoincrement())
  eventId             Int @map("event_id")
  templateVoucherV2Id Int @map("voucher_v2_id")
  resultVoucherV2Id   Int @map("result_voucher_v2_id")

  event             Event     @relation(fields: [eventId], references: [id])
  templateVoucherV2 VoucherV2 @relation("template_voucher_v2", fields: [templateVoucherV2Id], references: [id])
  resultVoucherV2   VoucherV2 @relation("result_voucher_v2", fields: [resultVoucherV2Id], references: [id])

  createdAt Int  @map("created_at")
  updatedAt Int  @map("updated_at")
  deletedAt Int? @map("deleted_at")

  @@map("event_voucher")
}

model VoucherV2 {
  id          Int     @id @default(autoincrement())
  status      String // Info (20241004 - Murky) ex: "uploaded", "upcoming
  canBeEdit   Boolean @map("can_be_edit") // Info (20241004 - Murky) true: the voucher can be edit
  voucherNo   String  @map("voucher_no") // Info (20241004 - Murky) the voucher number
  voucherDate Int     @map("voucher_date") // Info (20241004 - Murky) the date of the voucher
  type        String // Info (20241004 - Murky) ex: "payment", "transfer", "receiving"
  note        String // Info (20241004 - Murky) the note of the voucher
  createdAt   Int     @map("created_at")
  updatedAt   Int     @map("updated_at")
  deletedAt   Int?    @map("deleted_at")

  issuerId       Int @map("issuer_id") // Info (20241004 - Murky) the issuer (User) of the voucher
  counterPartyId Int @map("counter_party_id") // connect to counter party
  companyId  Int @map("company_id")

  voucherCertificate        voucherCertificate[]
  originalAssociateVouchers associateVoucher[]   @relation("original_voucher")
  associateVouchers         associateVoucher[]   @relation("associate_voucher")
  user                      User                 @relation(fields: [issuerId], references: [id])
  // counterParty            CounterParty         @relation(fields: [counterPartyId], references: [id]) // (please help me add this)
  // asset Asset[] @relation("voucher_asset") // (please help me add this)
  // lineItem LineItem[] @relation("voucher_line_item") // (please help me add this)

  eventTemplateVoucher eventVoucher[] @relation("template_voucher_v2")
  eventResultVoucher   eventVoucher[] @relation("result_voucher_v2")
}

@RexBearIU
Copy link
Contributor

eventVoucher and associateVoucher can be combine

@TeresaYang00 TeresaYang00 added this to the v0.9.0 Beta Release milestone Oct 8, 2024
@RexBearIU
Copy link
Contributor

It takes 4 hours.

done

@RexBearIU RexBearIU linked a pull request Oct 14, 2024 that will close this issue
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 hard level 5 enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants