Apply patch [skip ci]
This commit is contained in:
parent
6685923277
commit
d33c0ead99
@ -1,4 +1,63 @@
|
|||||||
lease_status: "new",
|
// services/leaseService.ts
|
||||||
|
// Handle lease management, creation, updates, and tenant relationships
|
||||||
|
|
||||||
|
import { and, eq } from "drizzle-orm";
|
||||||
|
import { db } from "../db/db.ts";
|
||||||
|
import { leases } from "../db/schema.ts";
|
||||||
|
import { Lease } from "../db/interfaces.ts";
|
||||||
|
import {
|
||||||
|
getE2ELeaseById,
|
||||||
|
getE2ELeasesByOwner,
|
||||||
|
getE2ELeasesByTenant,
|
||||||
|
isE2EEnabled,
|
||||||
|
} from "./e2eFixtures.ts";
|
||||||
|
|
||||||
|
// export interface Lease {
|
||||||
|
// id: string;
|
||||||
|
// title: string | null;
|
||||||
|
// property_id: string;
|
||||||
|
// property_address: string;
|
||||||
|
// tenant_id: string | null;
|
||||||
|
// owner_id: string;
|
||||||
|
// start_date: number;
|
||||||
|
// end_date: number;
|
||||||
|
// rent: number | null;
|
||||||
|
// security_deposit: number | null;
|
||||||
|
// lease_status: string | null; // 'draft', 'active', 'expired', 'terminated'
|
||||||
|
// lease_document_url: string | null;
|
||||||
|
// payment_schedule_id: string | null;
|
||||||
|
// late_fee_rules: string | null; // JSON string of late fee rules
|
||||||
|
// auto_renewal: boolean | null;
|
||||||
|
// encrypted_data: string | null;
|
||||||
|
// created_on: number;
|
||||||
|
// updated_on: number;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Create new lease
|
||||||
|
export async function createLease(
|
||||||
|
title: string,
|
||||||
|
property_id: string,
|
||||||
|
owner_id: string,
|
||||||
|
start_date: number,
|
||||||
|
end_date: number,
|
||||||
|
rent: number,
|
||||||
|
security_deposit: number = 0,
|
||||||
|
tenant_id?: string,
|
||||||
|
payment_schedule_id?: string,
|
||||||
|
) {
|
||||||
|
const now = Date.now();
|
||||||
|
return await db.insert(leases)
|
||||||
|
.values({
|
||||||
|
id: crypto.randomUUID(),
|
||||||
|
title,
|
||||||
|
property_id,
|
||||||
|
tenant_id: tenant_id || null,
|
||||||
|
owner_id,
|
||||||
|
start_date,
|
||||||
|
end_date,
|
||||||
|
rent,
|
||||||
|
security_deposit,
|
||||||
|
lease_status: "draft",
|
||||||
lease_document_url: null,
|
lease_document_url: null,
|
||||||
payment_schedule_id: payment_schedule_id || null,
|
payment_schedule_id: payment_schedule_id || null,
|
||||||
late_fee_rules: null,
|
late_fee_rules: null,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user