@@ -37,6 +37,7 @@ export const partners = pgTable('partners', {
3737 updatedAt : timestamp ( 'updated_at' , { precision : 3 , withTimezone : true , mode : 'string' } ) . notNull ( ) . defaultNow ( ) ,
3838 priceLevel : integer ( 'price_level' ) . notNull ( ) . default ( 0 ) ,
3939 prestige : integer ( 'prestige' ) . notNull ( ) . default ( 0 ) ,
40+ balance : numeric ( 'balance' , { mode : 'number' } ) . notNull ( ) . default ( 0 ) ,
4041 isActive : boolean ( 'is_active' ) . notNull ( ) . default ( true ) ,
4142 city : varchar ( 'city' ) ,
4243 legalEntityId : cuid2 ( 'legal_entity_id' ) . references ( ( ) => partnerLegalEntities . id ) ,
@@ -780,6 +781,17 @@ export const flowItemViews = pgTable('flow_item_views', {
780781 } ) ,
781782} )
782783
784+ export const invoices = pgTable ( 'invoices' , {
785+ id : cuid2 ( 'id' ) . defaultRandom ( ) . primaryKey ( ) ,
786+ createdAt : timestamp ( 'created_at' , { precision : 3 , withTimezone : true , mode : 'string' } ) . notNull ( ) . defaultNow ( ) ,
787+ updatedAt : timestamp ( 'updated_at' , { precision : 3 , withTimezone : true , mode : 'string' } ) . notNull ( ) . defaultNow ( ) ,
788+ title : varchar ( 'title' ) . notNull ( ) ,
789+ total : numeric ( 'total' , { mode : 'number' } ) . notNull ( ) . default ( 0 ) ,
790+ paid : numeric ( 'paid' , { mode : 'number' } ) . notNull ( ) . default ( 0 ) ,
791+ status : varchar ( 'status' ) . notNull ( ) . $type < entities . InvoiceStatus > ( ) . default ( 'unpaid' ) ,
792+ partnerId : cuid2 ( 'partner_id' ) . references ( ( ) => partners . id ) ,
793+ } )
794+
783795export const userRelations = relations ( users , ( { many, one } ) => ( {
784796 chatMessages : many ( chatMessages ) ,
785797 chatMembers : many ( chatMembers ) ,
@@ -805,6 +817,7 @@ export const userRelations = relations(users, ({ many, one }) => ({
805817export const partnerRelations = relations ( partners , ( { many, one } ) => ( {
806818 kitchens : many ( kitchens ) ,
807819 users : many ( users ) ,
820+ invoices : many ( invoices ) ,
808821 legalEntity : one ( partnerLegalEntities , {
809822 fields : [ partners . legalEntityId ] ,
810823 references : [ partnerLegalEntities . id ] ,
@@ -1284,3 +1297,10 @@ export const flowItemViewRelations = relations(flowItemViews, ({ one }) => ({
12841297 references : [ flowItems . id ] ,
12851298 } ) ,
12861299} ) )
1300+
1301+ export const invoiceRelations = relations ( invoices , ( { one } ) => ( {
1302+ partner : one ( partners , {
1303+ fields : [ invoices . partnerId ] ,
1304+ references : [ partners . id ] ,
1305+ } ) ,
1306+ } ) )
0 commit comments