feat: Initial purchase order views, login seems to be broken though.

This commit is contained in:
2025-01-17 12:58:32 -05:00
parent e1d07008a1
commit be0b5a6033
18 changed files with 534 additions and 288 deletions

View File

@@ -34,6 +34,11 @@ public extension DatabaseClient.VendorBranches {
}
return try await query.all().map { try $0.toDTO() }
} fetchAllWithDetail: {
try await VendorBranchModel.query(on: db)
.with(\.$vendor)
.all()
.map { try $0.toDetail() }
} get: { id in
try await VendorBranchModel.find(id, on: db).map { try $0.toDTO() }
} update: { id, updates in
@@ -147,6 +152,16 @@ final class VendorBranchModel: Model, @unchecked Sendable {
)
}
func toDetail() throws -> VendorBranch.Detail {
try .init(
id: requireID(),
name: name,
vendor: vendor.toDTO(),
createdAt: createdAt,
updatedAt: updatedAt
)
}
func applyUpdates(_ updates: VendorBranch.Update) throws {
try updates.validate()
if let name = updates.name {