Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:a-finocchiaro/medusa into feat/a…
Browse files Browse the repository at this point in the history
…dd_user_role_to_create_user_cmd
  • Loading branch information
a-finocchiaro committed Nov 28, 2022
2 parents d777721 + e18b59d commit 42d1a62
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/moody-ravens-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---

fix(medusa): Order service legacy decorate totals should still apply the totals to the items
5 changes: 5 additions & 0 deletions .changeset/nervous-insects-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"medusa-payment-stripe": patch
---

fix(medusa-plugin-stripe): Correct hooks import
5 changes: 5 additions & 0 deletions .changeset/real-rockets-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---

chore: update awilix to v8
Original file line number Diff line number Diff line change
Expand Up @@ -432,17 +432,21 @@ Object {
"claim_order_id": null,
"created_at": Any<Date>,
"description": "",
"discount_total": 0,
"fulfilled_quantity": 2,
"has_shipping": null,
"id": Any<String>,
"is_giftcard": false,
"is_return": false,
"metadata": null,
"order_id": Any<String>,
"original_tax_total": 400,
"original_total": 2400,
"quantity": 2,
"returned_quantity": 1,
"shipped_quantity": 2,
"should_merge": true,
"subtotal": 2000,
"swap_id": null,
"tax_lines": Array [
Object {
Expand All @@ -456,8 +460,10 @@ Object {
"updated_at": Any<Date>,
},
],
"tax_total": 400,
"thumbnail": "",
"title": "Intelligent Plastic Chips",
"total": 2400,
"unit_price": 1000,
"updated_at": Any<Date>,
"variant": Object {
Expand Down Expand Up @@ -768,18 +774,22 @@ Object {
"claim_order_id": null,
"created_at": Any<Date>,
"description": "",
"discount_total": 0,
"fulfilled_quantity": null,
"has_shipping": null,
"id": "test-item",
"is_giftcard": false,
"is_return": false,
"metadata": null,
"order_id": Any<String>,
"original_tax_total": 400,
"original_total": 2400,
"price": "10.00 USD",
"quantity": 2,
"returned_quantity": null,
"shipped_quantity": null,
"should_merge": true,
"subtotal": 2000,
"swap_id": null,
"tax_lines": Array [
Object {
Expand All @@ -793,8 +803,10 @@ Object {
"updated_at": Any<Date>,
},
],
"tax_total": 400,
"thumbnail": null,
"title": "Intelligent Plastic Chips",
"total": 2400,
"unit_price": 1000,
"updated_at": Any<Date>,
"variant": Object {
Expand Down Expand Up @@ -991,6 +1003,7 @@ Object {
"claim_order_id": null,
"created_at": Any<Date>,
"description": "",
"discount_total": 0,
"discounted_price": "12.00 USD",
"fulfilled_quantity": 2,
"has_shipping": null,
Expand All @@ -999,11 +1012,14 @@ Object {
"is_return": false,
"metadata": null,
"order_id": Any<String>,
"original_tax_total": 400,
"original_total": 2400,
"price": "12.00 USD",
"quantity": 2,
"returned_quantity": null,
"shipped_quantity": 2,
"should_merge": true,
"subtotal": 2000,
"swap_id": null,
"tax_lines": Array [
Object {
Expand All @@ -1017,8 +1033,10 @@ Object {
"updated_at": Any<Date>,
},
],
"tax_total": 400,
"thumbnail": null,
"title": "Intelligent Plastic Chips",
"total": 2400,
"totals": Object {
"discount_total": 0,
"original_tax_total": 400,
Expand Down Expand Up @@ -1258,17 +1276,21 @@ Object {
"claim_order_id": null,
"created_at": Any<Date>,
"description": "",
"discount_total": 0,
"fulfilled_quantity": 2,
"has_shipping": null,
"id": "test-item",
"is_giftcard": false,
"is_return": false,
"metadata": null,
"order_id": Any<String>,
"original_tax_total": 400,
"original_total": 2400,
"quantity": 2,
"returned_quantity": null,
"shipped_quantity": 2,
"should_merge": true,
"subtotal": 2000,
"swap_id": null,
"tax_lines": Array [
Object {
Expand All @@ -1282,8 +1304,10 @@ Object {
"updated_at": Any<Date>,
},
],
"tax_total": 400,
"thumbnail": "",
"title": "Intelligent Plastic Chips",
"total": 2400,
"unit_price": 1000,
"updated_at": Any<Date>,
"variant": Object {
Expand Down Expand Up @@ -1579,17 +1603,21 @@ Object {
"claim_order_id": null,
"created_at": Any<Date>,
"description": "",
"discount_total": 0,
"fulfilled_quantity": 2,
"has_shipping": null,
"id": Any<String>,
"is_giftcard": false,
"is_return": false,
"metadata": null,
"order_id": Any<String>,
"original_tax_total": 400,
"original_total": 2400,
"quantity": 2,
"returned_quantity": null,
"shipped_quantity": 2,
"should_merge": true,
"subtotal": 2000,
"swap_id": null,
"tax_lines": Array [
Object {
Expand All @@ -1603,8 +1631,10 @@ Object {
"updated_at": Any<Date>,
},
],
"tax_total": 400,
"thumbnail": "",
"title": "Intelligent Plastic Chips",
"total": 2400,
"unit_price": 1000,
"updated_at": Any<Date>,
"variant": Object {
Expand Down Expand Up @@ -2446,4 +2476,4 @@ Object {
"tracking_links": Array [],
"tracking_number": "",
}
`;
`;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PostgresError } from "@medusajs/medusa/src/utils"
import { PostgresError } from "@medusajs/medusa/dist/utils"

export default async (req, res) => {
const signature = req.headers["stripe-signature"]
Expand Down
2 changes: 1 addition & 1 deletion packages/medusa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@medusajs/medusa-cli": "^1.3.5",
"@types/ioredis": "^4.28.10",
"@types/lodash": "^4.14.168",
"awilix": "^4.2.3",
"awilix": "^8.0.0",
"body-parser": "^1.19.0",
"bull": "^3.12.1",
"chokidar": "^3.4.2",
Expand Down
23 changes: 22 additions & 1 deletion packages/medusa/src/services/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,27 @@ class OrderService extends TransactionBaseService {
order: Order,
totalsFields: string[] = []
): Promise<Order> {
if (totalsFields.some((field) => ["subtotal", "total"].includes(field))) {
const calculationContext =
await this.totalsService_.getCalculationContext(order, {
exclude_shipping: true,
})
order.items = await Promise.all(
(order.items || []).map(async (item) => {
const itemTotals = await this.totalsService_.getLineItemTotals(
item,
order,
{
include_tax: true,
calculation_context: calculationContext,
}
)

return Object.assign(item, itemTotals)
})
)
}

for (const totalField of totalsFields) {
switch (totalField) {
case "shipping_total": {
Expand Down Expand Up @@ -1603,9 +1624,9 @@ class OrderService extends TransactionBaseService {
}

/**
* Calculate and attach the different total fields on the object
* @param order
* @param totalsFieldsOrConfig
* @protected
*/
async decorateTotals(
order: Order,
Expand Down
25 changes: 19 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4347,7 +4347,7 @@ __metadata:
"@types/jsonwebtoken": ^8.5.5
"@types/lodash": ^4.14.168
"@types/multer": ^1.4.7
awilix: ^4.2.3
awilix: ^8.0.0
babel-preset-medusa-package: ^1.1.19
body-parser: ^1.19.0
bull: ^3.12.1
Expand Down Expand Up @@ -10143,13 +10143,13 @@ __metadata:
languageName: node
linkType: hard

"awilix@npm:^4.2.3":
version: 4.3.4
resolution: "awilix@npm:4.3.4"
"awilix@npm:^8.0.0":
version: 8.0.0
resolution: "awilix@npm:8.0.0"
dependencies:
camel-case: ^4.1.2
glob: ^7.1.6
checksum: 636f887be095d1f3dbd245bb2189965b6214b9cc19050a963c22a2f30aaea0039ba7d7df235a2d5ba725550230a98a44daf21971bd32ece3e5a88e91cbbe102f
fast-glob: ^3.2.12
checksum: 29a6b05d651635c240d5a22ea7d463330e5aab262e25a4043c39ca5a52d5e7ff691fcd6e1f0d6565b5bbd095c1fbc3240f6686e4db657bcb3155fe84d16c7f1a
languageName: node
linkType: hard

Expand Down Expand Up @@ -16194,6 +16194,19 @@ __metadata:
languageName: node
linkType: hard

"fast-glob@npm:^3.2.12":
version: 3.2.12
resolution: "fast-glob@npm:3.2.12"
dependencies:
"@nodelib/fs.stat": ^2.0.2
"@nodelib/fs.walk": ^1.2.3
glob-parent: ^5.1.2
merge2: ^1.3.0
micromatch: ^4.0.4
checksum: 08604fb8ef6442ce74068bef3c3104382bb1f5ab28cf75e4ee904662778b60ad620e1405e692b7edea598ef445f5d387827a965ba034e1892bf54b1dfde97f26
languageName: node
linkType: hard

"fast-json-parse@npm:^1.0.3":
version: 1.0.3
resolution: "fast-json-parse@npm:1.0.3"
Expand Down

0 comments on commit 42d1a62

Please sign in to comment.