fix(medusa): Fix order service linting issues (#5071)

* style(medusa): Fix order service linting issues

* Create short-ligers-pull.md
This commit is contained in:
Adrien de Peretti
2023-09-15 10:58:30 +02:00
committed by GitHub
parent dc94f053d3
commit 60360d2fd2
2 changed files with 56 additions and 50 deletions

View File

@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---
style(medusa): Fix order service linting issues

View File

@@ -1,63 +1,63 @@
import { IInventoryService } from "@medusajs/types"
import {
buildRelations,
buildSelects,
FlagRouter,
isDefined,
MedusaError,
buildRelations,
buildSelects,
FlagRouter,
isDefined,
MedusaError,
} from "@medusajs/utils"
import {
EntityManager,
FindManyOptions,
FindOptionsWhere,
ILike,
IsNull,
Not,
Raw,
EntityManager,
FindManyOptions,
FindOptionsWhere,
ILike,
IsNull,
Not,
Raw,
} from "typeorm"
import {
CartService,
CustomerService,
DiscountService,
DraftOrderService,
FulfillmentProviderService,
FulfillmentService,
GiftCardService,
LineItemService,
NewTotalsService,
PaymentProviderService,
ProductVariantInventoryService,
RegionService,
ShippingOptionService,
ShippingProfileService,
TaxProviderService,
TotalsService,
CartService,
CustomerService,
DiscountService,
DraftOrderService,
FulfillmentProviderService,
FulfillmentService,
GiftCardService,
LineItemService,
NewTotalsService,
PaymentProviderService,
ProductVariantInventoryService,
RegionService,
ShippingOptionService,
ShippingProfileService,
TaxProviderService,
TotalsService,
} from "."
import { TransactionBaseService } from "../interfaces"
import SalesChannelFeatureFlag from "../loaders/feature-flags/sales-channels"
import {
Address,
Cart,
ClaimOrder,
Fulfillment,
FulfillmentItem,
FulfillmentStatus,
GiftCard,
LineItem,
Order,
OrderStatus,
Payment,
PaymentStatus,
Return,
Swap,
TrackingLink,
Address,
Cart,
ClaimOrder,
Fulfillment,
FulfillmentItem,
FulfillmentStatus,
GiftCard,
LineItem,
Order,
OrderStatus,
Payment,
PaymentStatus,
Return,
Swap,
TrackingLink,
} from "../models"
import { AddressRepository } from "../repositories/address"
import { OrderRepository } from "../repositories/order"
import { FindConfig, QuerySelector, Selector } from "../types/common"
import {
CreateFulfillmentOrder,
FulFillmentItemType,
CreateFulfillmentOrder,
FulFillmentItemType,
} from "../types/fulfillment"
import { TotalsContext, UpdateOrderInput } from "../types/orders"
import { CreateShippingMethodDto } from "../types/shipping-options"
@@ -733,10 +733,10 @@ class OrderService extends TransactionBaseService {
let giftCardableAmountBalance = giftCardableAmount
const giftCardService = this.giftCardService_.withTransaction(manager)
//Order the gift cards by first ends_at date, then remaining amount. To ensure largest possible amount left, for longest possible time.
// Order the gift cards by first ends_at date, then remaining amount. To ensure largest possible amount left, for longest possible time.
const orderedGiftCards = cart.gift_cards.sort((a, b) => {
let aEnd = a.ends_at ?? new Date(2100, 1, 1)
let bEnd = b.ends_at ?? new Date(2100, 1, 1)
const aEnd = a.ends_at ?? new Date(2100, 1, 1)
const bEnd = b.ends_at ?? new Date(2100, 1, 1)
return aEnd.getTime() - bEnd.getTime() || a.balance - b.balance
})
for (const giftCard of orderedGiftCards) {
@@ -762,8 +762,9 @@ class OrderService extends TransactionBaseService {
giftCardableAmountBalance =
giftCardableAmountBalance - giftCardBalanceUsed
if (giftCardableAmountBalance == 0)
break;
if (giftCardableAmountBalance == 0) {
break
}
}
const shippingOptionServiceTx =