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:
committed by
GitHub
parent
dc94f053d3
commit
60360d2fd2
5
.changeset/short-ligers-pull.md
Normal file
5
.changeset/short-ligers-pull.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/medusa": patch
|
||||
---
|
||||
|
||||
style(medusa): Fix order service linting issues
|
||||
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user