This commit is contained in:
2026-08-28 17:31:02 +02:00
commit 2b30e8bd39
694 changed files with 49243 additions and 0 deletions
@@ -0,0 +1,24 @@
import type { Repository, SelectQueryBuilder } from 'typeorm';
import { Order } from '../../modules/order/entities/Order';
export const createOrderDetailQuery = (orderRepo: Repository<Order>, orderId: string): SelectQueryBuilder<Order> =>
orderRepo
.createQueryBuilder('order')
.leftJoinAndSelect('order.lines', 'orderLine')
.leftJoinAndSelect('orderLine.autoFulfillmentItems', 'autoFulfillmentItem')
.leftJoinAndSelect('autoFulfillmentItem.attachments', 'autoFulfillmentItemAttachment')
.leftJoinAndSelect('orderLine.manualFulfillment', 'manualFulfillment')
.leftJoinAndSelect('order.discounts', 'orderDiscount')
.leftJoinAndSelect('order.checkoutInvoice', 'checkoutInvoice')
.leftJoinAndSelect('checkoutInvoice.moneroDetails', 'checkoutMoneroDetails')
.leftJoinAndSelect('checkoutInvoice.payments', 'checkoutPayment')
.leftJoinAndSelect('order.shippingInvoice', 'shippingInvoice')
.leftJoinAndSelect('shippingInvoice.moneroDetails', 'shippingMoneroDetails')
.leftJoinAndSelect('shippingInvoice.payments', 'shippingPayment')
.leftJoinAndSelect('order.messages', 'message')
.addSelect('order.accessToken')
.addSelect('autoFulfillmentItem.contentSnapshot')
.addSelect('autoFulfillmentItemAttachment.storageKey')
.orderBy('message.createdAt', 'ASC')
.addOrderBy('autoFulfillmentItem.sortOrder', 'ASC')
.where('order.id = :orderId', { orderId });