@absolutejs/commerce 0.9.0-beta.0 → 0.11.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -80,6 +80,36 @@ var redeemGiftCard = async (db, code, amountCents) => {
80
80
  await db.update(commerceGiftCards).set({ balance_cents: balance }).where(eq(commerceGiftCards.code, card.code));
81
81
  return { appliedCents: applied, balanceCents: balance };
82
82
  };
83
+ var createCompany = async (db, company) => {
84
+ const [created] = await db.insert(commerceCompanies).values(company).returning();
85
+ return created;
86
+ };
87
+ var listCompanies = (db) => db.select().from(commerceCompanies).orderBy(desc(commerceCompanies.created_at));
88
+ var getCompany = async (db, id) => {
89
+ const [company] = await db.select().from(commerceCompanies).where(eq(commerceCompanies.id, id)).limit(1);
90
+ return company ?? null;
91
+ };
92
+ var updateCompany = async (db, id, patch) => {
93
+ const [updated] = await db.update(commerceCompanies).set(patch).where(eq(commerceCompanies.id, id)).returning();
94
+ return updated;
95
+ };
96
+ var createInvoice = async (db, invoice) => {
97
+ const [created] = await db.insert(commerceInvoices).values(invoice).returning();
98
+ return created;
99
+ };
100
+ var listInvoices = (db) => db.select().from(commerceInvoices).orderBy(desc(commerceInvoices.created_at));
101
+ var getInvoice = async (db, id) => {
102
+ const [invoice] = await db.select().from(commerceInvoices).where(eq(commerceInvoices.id, id)).limit(1);
103
+ return invoice ?? null;
104
+ };
105
+ var getInvoiceByOrder = async (db, orderSession) => {
106
+ const [invoice] = await db.select().from(commerceInvoices).where(eq(commerceInvoices.order_session, orderSession)).limit(1);
107
+ return invoice ?? null;
108
+ };
109
+ var setInvoiceStatus = async (db, id, status) => {
110
+ const [updated] = await db.update(commerceInvoices).set({ status }).where(eq(commerceInvoices.id, id)).returning();
111
+ return updated;
112
+ };
83
113
  var listInventory = (db) => db.select().from(commerceInventory).orderBy(desc(commerceInventory.created_at));
84
114
  var addInventoryItem = async (db, item) => {
85
115
  const [created] = await db.insert(commerceInventory).values(item).returning();
@@ -156,6 +186,33 @@ var commerceDesigns = pgTable("designs", {
156
186
  name: varchar({ length: 120 }).notNull(),
157
187
  public: boolean().notNull().default(true)
158
188
  });
189
+ var commerceCompanies = pgTable("companies", {
190
+ brand_logos: jsonb().$type().default([]),
191
+ contact_email: varchar({ length: 320 }),
192
+ created_at: timestamp().notNull().defaultNow(),
193
+ id: uuid().defaultRandom().primaryKey(),
194
+ name: varchar({ length: 200 }).notNull(),
195
+ net_terms: integer().notNull().default(0),
196
+ notes: text(),
197
+ po_required: boolean().notNull().default(false),
198
+ tax_exempt: boolean().notNull().default(false),
199
+ tax_exempt_id: varchar({ length: 80 })
200
+ });
201
+ var commerceInvoices = pgTable("invoices", {
202
+ amount_cents: integer().notNull().default(0),
203
+ company_id: uuid(),
204
+ created_at: timestamp().notNull().defaultNow(),
205
+ customer_email: varchar({ length: 320 }),
206
+ due_date: timestamp(),
207
+ id: uuid().defaultRandom().primaryKey(),
208
+ line_items: jsonb().$type().default([]),
209
+ notes: text(),
210
+ number: varchar({ length: 40 }).notNull(),
211
+ order_session: varchar({ length: 255 }),
212
+ po_number: varchar({ length: 80 }),
213
+ status: varchar({ length: 20 }).notNull().default("draft"),
214
+ tax_exempt: boolean().notNull().default(false)
215
+ });
159
216
  var commerceDiscounts = pgTable("discounts", {
160
217
  active: boolean().notNull().default(true),
161
218
  amount_off: integer(),
@@ -309,8 +366,10 @@ var commerceSubscribers = pgTable("subscribers", {
309
366
  });
310
367
  var commerceDrizzleSchema = {
311
368
  abandonedCarts: commerceAbandonedCarts,
369
+ companies: commerceCompanies,
312
370
  designs: commerceDesigns,
313
371
  discounts: commerceDiscounts,
372
+ invoices: commerceInvoices,
314
373
  favorites: commerceFavorites,
315
374
  galleryItems: commerceGalleryItems,
316
375
  giftCards: commerceGiftCards,
@@ -325,10 +384,12 @@ var commerceDrizzleSchema = {
325
384
  subscribers: commerceSubscribers
326
385
  };
327
386
  export {
387
+ updateCompany,
328
388
  toggleFavorite,
329
389
  subscribe,
330
390
  setReviewStatus,
331
391
  setReturnStatus,
392
+ setInvoiceStatus,
332
393
  setInventoryQuantity,
333
394
  saveDesign,
334
395
  redeemGiftCard,
@@ -340,16 +401,21 @@ export {
340
401
  listSubscribers,
341
402
  listSavedDesigns,
342
403
  listReturnRequests,
404
+ listInvoices,
343
405
  listInventory,
344
406
  listGroupStores,
345
407
  listGroupOrders,
346
408
  listGalleryItems,
347
409
  listFavorites,
410
+ listCompanies,
348
411
  listApprovedReviews,
349
412
  listAllReviews,
350
413
  issueGiftCard,
414
+ getInvoiceByOrder,
415
+ getInvoice,
351
416
  getGroupStoreBySlug,
352
417
  getGiftCard,
418
+ getCompany,
353
419
  findOrderForTracking,
354
420
  dueForReminder,
355
421
  deleteSavedDesign,
@@ -357,14 +423,17 @@ export {
357
423
  deleteGalleryItem,
358
424
  createReview,
359
425
  createReturnRequest,
426
+ createInvoice,
360
427
  createGroupStore,
361
428
  createGalleryItem,
429
+ createCompany,
362
430
  commerceSubscribers,
363
431
  commerceSavedDesigns,
364
432
  commerceReviews,
365
433
  commerceReturnRequests,
366
434
  commerceQuotes,
367
435
  commerceOrders,
436
+ commerceInvoices,
368
437
  commerceInventory,
369
438
  commerceGroupStores,
370
439
  commerceGroupOrders,
@@ -374,6 +443,7 @@ export {
374
443
  commerceDrizzleSchema,
375
444
  commerceDiscounts,
376
445
  commerceDesigns,
446
+ commerceCompanies,
377
447
  commerceAbandonedCarts,
378
448
  addInventoryItem
379
449
  };