bcgov / range-web

The Range Mobile Pathfinder project is developing a suite of applications to support the sustainable management of cattle range on crown lands in British Columbia.
https://myrangebc.gov.bc.ca
Apache License 2.0
9 stars 11 forks source link

Status of original plan after replacement #1171

Closed brijesh-amin closed 3 weeks ago

brijesh-amin commented 3 weeks ago

What happens to the original plan after replacement? What status will it be?

brijesh-amin commented 3 weeks ago

Original plan status is not updated. However, extension status is updated to PLAN_EXTENSION_STATUS.REPLACEMENT_PLAN_CREATED

    if (
      result.extension_status === PLAN_EXTENSION_STATUS.REPLACEMENT_PLAN_CREATED
    ) {
      try {
        console.log(
          `Replacing planId: ${result.id} with the replacement plan ${result.replacement_plan_id}`,
        );
        await Plan.update(
          trx,
          { id: result.id },
          {
            extension_status:
              PLAN_EXTENSION_STATUS.REPLACED_WITH_REPLACEMENT_PLAN,
          },
        );
        await Plan.update(
          trx,
          { id: result.replacement_plan_id },
          {
            extension_status: PLAN_EXTENSION_STATUS.ACTIVE_REPLACEMENT_PLAN,
          },
        );
        continue;
      } catch (error) {
        console.log(error.stack);
      }
    }

More changes will be done to this when expired plan status changes are done.