Skip to content

Commit

Permalink
Orders status bug Active -> Activated (#485)
Browse files Browse the repository at this point in the history
* order status should be Activated not Active

* get activeOrder from contract not contract_data

* update package.json version

* add start and end date check for active order

* remove optional chaining

* change date now variable name
  • Loading branch information
emortong authored Feb 7, 2024
1 parent da831e1 commit fed12b9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ft-next-syndication-api",
"description": "Next Syndication API",
"version": "2.0.4",
"version": "2.0.5",
"private": true,
"dependencies": {
"@dotcom-reliability-kit/crash-handler": "^2.1.1",
Expand Down
5 changes: 3 additions & 2 deletions server/controllers/get-contract-by-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ module.exports = exports = async (req, res, next) => {
if (req.query.save !== '0') {
let contract_data = reformatSalesforceContract(JSON.parse(JSON.stringify(contract)));
contract_data.last_updated = new Date();
if (contract_data.orders) {
const activeOrder = contract_data.orders.find(order => order.status === 'Active');
if (contract.orders) {
const currentTimeInMilliseconds = new Date();
const activeOrder = contract.orders.find(order => order.status === 'Activated' && new Date(order.startDate) <= currentTimeInMilliseconds && new Date(order.endDate) >= currentTimeInMilliseconds);
contract_data.current_start_date = new Date(activeOrder.startDate);
contract_data.current_end_date = new Date(activeOrder.endDate);
}
Expand Down
3 changes: 2 additions & 1 deletion server/lib/get-contract-by-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ module.exports = exports = async (contractId, locals = {}) => {
contract = reformatSalesforceContract(contract);
contract.last_updated = new Date();
if (contract.orders) {
const activeOrder = contract.orders.find(order => order.status === 'Active');
const currentTimeInMilliseconds = new Date();
const activeOrder = contract.orders.find(order => order.status === 'Activated' && new Date(order.startDate) <= currentTimeInMilliseconds && new Date(order.endDate) >= currentTimeInMilliseconds);
contract.current_start_date = new Date(activeOrder.startDate);
contract.current_end_date = new Date(activeOrder.endDate);
}
Expand Down

0 comments on commit fed12b9

Please sign in to comment.