feat(core-flows, types): calculated shipping in RMA flows (#11533)
* wip: calculated SO pricing in RMA flows * fix: types * chore: small refactor * feat: caluclated shipping in return flow * fix: module integrations * fix: array containing * feat: refresh shipping on update item quantity * rm: log * rm: log2 * feat: update interface, remove flag * fix: revert change on OE for now * fix: import * feat: refactor flwos, cleanup cacluation cotext data model, wip exchanges * feat: refreshing inbound/outbound shipping on items change * feat: refresh exchange shipping on return item add, test * feat: refresh shipping on exchange/return item remove * fix: check optional * feat: test recalculation on quantity update * feat: calculated shipping on claims * fix: comment * wip: address comments * fix: more remote query, fix build * refactor: claim refresh workflow * fix: remove throw option * fix: deconstruct param --------- Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
import { ModuleProvider, Modules } from "@medusajs/framework/utils"
|
||||
import { ManualFulfillmentService } from "./services/manual-fulfillment"
|
||||
|
||||
const services = [ManualFulfillmentService]
|
||||
|
||||
export default ModuleProvider(Modules.FULFILLMENT, {
|
||||
services,
|
||||
})
|
||||
@@ -0,0 +1,80 @@
|
||||
import { AbstractFulfillmentProviderService } from "@medusajs/framework/utils"
|
||||
|
||||
export class ManualFulfillmentService extends AbstractFulfillmentProviderService {
|
||||
static identifier = "manual-calculated"
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
}
|
||||
|
||||
async getFulfillmentOptions() {
|
||||
return [
|
||||
{
|
||||
id: "manual-fulfillment-calculated",
|
||||
},
|
||||
{
|
||||
id: "manual-fulfillment-return-calculated",
|
||||
is_return: true,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
async validateFulfillmentData(optionData, data, context) {
|
||||
return data
|
||||
}
|
||||
|
||||
async calculatePrice(optionData, data, context) {
|
||||
if (context.exchange_id) {
|
||||
return {
|
||||
calculated_amount:
|
||||
context.exchange_items.reduce((acc, i) => acc + i.quantity, 0) * 2.5, // mock return cost as 2 per item
|
||||
is_calculated_price_tax_inclusive: false,
|
||||
}
|
||||
}
|
||||
if (context.claim_id) {
|
||||
return {
|
||||
calculated_amount:
|
||||
context.claim_items.reduce((acc, i) => acc + i.quantity, 0) * 2.5, // mock return cost as 2 per item
|
||||
is_calculated_price_tax_inclusive: false,
|
||||
}
|
||||
}
|
||||
|
||||
if (context.return_id) {
|
||||
return {
|
||||
calculated_amount:
|
||||
context.return_items.reduce((acc, i) => acc + i.quantity, 0) * 2, // mock return cost as 2 per item
|
||||
is_calculated_price_tax_inclusive: false,
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
calculated_amount:
|
||||
context.items.reduce((acc, i) => acc + i.quantity, 0) * 1.5, // mock caluclation as 1.5 per item
|
||||
is_calculated_price_tax_inclusive: false,
|
||||
}
|
||||
}
|
||||
|
||||
async canCalculate() {
|
||||
return true
|
||||
}
|
||||
|
||||
async validateOption(data) {
|
||||
return true
|
||||
}
|
||||
|
||||
async createFulfillment() {
|
||||
// No data is being sent anywhere
|
||||
return {
|
||||
data: {},
|
||||
labels: [],
|
||||
}
|
||||
}
|
||||
|
||||
async cancelFulfillment() {
|
||||
return {}
|
||||
}
|
||||
|
||||
async createReturnFulfillment() {
|
||||
return { data: {}, labels: [] }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user