Skip to content

function: total static price#21

Open
codeicey wants to merge 11 commits intomainfrom
feat/prices
Open

function: total static price#21
codeicey wants to merge 11 commits intomainfrom
feat/prices

Conversation

@codeicey
Copy link
Member

No description provided.

@codeicey codeicey requested a review from codynhat December 27, 2022 16:45
@codeicey codeicey linked an issue Dec 27, 2022 that may be closed by this pull request
Copy link
Contributor

@codynhat codynhat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overall structure of the package looks good. Additional test cases can be:

  • A "base" price with custom prices overriding certain days
  • A per mile/kilometer price for driving further than a specified distance

Copy link
Contributor

@codynhat codynhat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! I think just adding some test assertions for the actual prices would be good. All these cases look good.


const ligoAgreementState: LigoAgreementState = {
startOdometer: {
value: 1000,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should include some specific distance unit. The case 2 PriceSpecification has a price per km, but what if the odometer reading is in miles?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For km, this can just be

{
  value: 1000,
  unitCode: "KMT"
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added "SMI" for Statute Mile.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test case for "SMI" as well? And also add either unit code to this agreement state?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment about the _totalPriceKM function. This LigoAgreementState needs to specify some unitCode and there should be test cases for both SMI and KMT

return (await this._dateDiffInDays(a, b)) * _priceSpecification.price;
}

private async _totalPriceKM(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this function assuming that the unitCode for the startOdometer and endOdometer is the same as the PriceSpecification? This isn't a safe assumption. What should be done if the units are not the same?

To keep it simple, I think a per distance fee should only be charged if there is a PriceSpecification for the correct unit and leave it up to the host to published a per distance fee for each unit separately.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added conversion for SMI to KMT. Let me know your thoughts on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create "prices" package

2 participants