removed plan script
This commit is contained in:
@@ -1,94 +0,0 @@
|
|||||||
(() => {
|
|
||||||
const dbName = (typeof process !== "undefined" && process.env.MONGO_DB) ? process.env.MONGO_DB : db.getName();
|
|
||||||
const targetDb = db.getSiblingDB(dbName);
|
|
||||||
const collection = targetDb.getCollection("payment_plan_templates");
|
|
||||||
const now = new Date();
|
|
||||||
|
|
||||||
const templates = [
|
|
||||||
{
|
|
||||||
fromRail: "CRYPTO",
|
|
||||||
toRail: "LEDGER",
|
|
||||||
network: "",
|
|
||||||
isEnabled: true,
|
|
||||||
steps: [
|
|
||||||
{ stepId: "crypto_send", rail: "CRYPTO", operation: "payout.crypto" },
|
|
||||||
{ stepId: "crypto_fee", rail: "CRYPTO", operation: "fee.send", dependsOn: ["crypto_send"] },
|
|
||||||
{ stepId: "settlement_send", rail: "PROVIDER_SETTLEMENT", operation: "send", dependsOn: ["crypto_send"] },
|
|
||||||
{ stepId: "settlement_observe", rail: "PROVIDER_SETTLEMENT", operation: "observe.confirm", dependsOn: ["settlement_send"] },
|
|
||||||
{ stepId: "ledger_credit", rail: "LEDGER", operation: "ledger.credit", dependsOn: ["settlement_observe"] },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fromRail: "LEDGER",
|
|
||||||
toRail: "CARD_PAYOUT",
|
|
||||||
network: "",
|
|
||||||
isEnabled: true,
|
|
||||||
steps: [
|
|
||||||
{ stepId: "ledger_block", rail: "LEDGER", operation: "ledger.block" },
|
|
||||||
{ stepId: "card_payout", rail: "CARD_PAYOUT", operation: "payout.card", dependsOn: ["ledger_block"] },
|
|
||||||
{
|
|
||||||
stepId: "ledger_debit",
|
|
||||||
rail: "LEDGER",
|
|
||||||
operation: "ledger.debit",
|
|
||||||
dependsOn: ["card_payout"],
|
|
||||||
commitPolicy: "AFTER_SUCCESS",
|
|
||||||
commitAfter: ["card_payout"],
|
|
||||||
},
|
|
||||||
{ stepId: "ledger_release", rail: "LEDGER", operation: "ledger.release", dependsOn: ["card_payout"] },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fromRail: "CRYPTO",
|
|
||||||
toRail: "CARD_PAYOUT",
|
|
||||||
network: "",
|
|
||||||
isEnabled: true,
|
|
||||||
steps: [
|
|
||||||
{ stepId: "crypto_send", rail: "CRYPTO", operation: "payout.crypto" },
|
|
||||||
{ stepId: "crypto_fee", rail: "CRYPTO", operation: "fee.send", dependsOn: ["crypto_send"] },
|
|
||||||
{ stepId: "settlement_send", rail: "PROVIDER_SETTLEMENT", operation: "send", dependsOn: ["crypto_send"] },
|
|
||||||
{ stepId: "settlement_observe", rail: "PROVIDER_SETTLEMENT", operation: "observe.confirm", dependsOn: ["settlement_send"] },
|
|
||||||
{ stepId: "ledger_credit", rail: "LEDGER", operation: "ledger.credit", dependsOn: ["settlement_observe"] },
|
|
||||||
{ stepId: "ledger_block", rail: "LEDGER", operation: "ledger.block", dependsOn: ["ledger_credit"] },
|
|
||||||
{ stepId: "card_payout", rail: "CARD_PAYOUT", operation: "payout.card", dependsOn: ["ledger_block"] },
|
|
||||||
{
|
|
||||||
stepId: "ledger_debit",
|
|
||||||
rail: "LEDGER",
|
|
||||||
operation: "ledger.debit",
|
|
||||||
dependsOn: ["card_payout"],
|
|
||||||
commitPolicy: "AFTER_SUCCESS",
|
|
||||||
commitAfter: ["card_payout"],
|
|
||||||
},
|
|
||||||
{ stepId: "ledger_release", rail: "LEDGER", operation: "ledger.release", dependsOn: ["card_payout"] },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const ops = templates.map((tpl) => ({
|
|
||||||
updateOne: {
|
|
||||||
filter: {
|
|
||||||
fromRail: tpl.fromRail,
|
|
||||||
toRail: tpl.toRail,
|
|
||||||
network: tpl.network,
|
|
||||||
},
|
|
||||||
update: {
|
|
||||||
$set: {
|
|
||||||
fromRail: tpl.fromRail,
|
|
||||||
toRail: tpl.toRail,
|
|
||||||
network: tpl.network,
|
|
||||||
isEnabled: tpl.isEnabled,
|
|
||||||
steps: tpl.steps,
|
|
||||||
updatedAt: now,
|
|
||||||
},
|
|
||||||
$setOnInsert: {
|
|
||||||
_id: new ObjectId(),
|
|
||||||
createdAt: now,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
upsert: true,
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
const result = collection.bulkWrite(ops);
|
|
||||||
print("Payment plan templates upserted");
|
|
||||||
printjson(result);
|
|
||||||
})();
|
|
||||||
Reference in New Issue
Block a user