Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marketplace: Create and Update TaxRate #1186

Merged
merged 4 commits into from
Mar 7, 2023

Conversation

zspencer
Copy link
Member

@zspencer zspencer commented Mar 5, 2023

Slaps some update and create actions together for setting TaxRates.

That said, I don't know that an integer or a float is better, since I suppose there could be a partial tax?

Also, I tried to set it up so tax rates applied across all spaces; but then I ran into some weirdness... if y'all have ideas happy to hear.

@zspencer zspencer force-pushed the marketplace/creating-tax-rates branch from da2d35d to 71b7a3a Compare March 5, 2023 03:20
@zspencer zspencer requested review from anaulin, KellyAH and a team March 5, 2023 03:34
@zspencer zspencer added the ✨ feature Reduces Client's Burden or Grants them Benefits label Mar 5, 2023
Copy link
Member

@anaulin anaulin left a comment

Choose a reason for hiding this comment

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

🚕

Looks good, but see below for my question re: taxes on products.

<h3>Tax Rates</h3>
<%= render policy_scope(marketplace.tax_rates) %>


Copy link
Member

Choose a reason for hiding this comment

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

Extra blank line. </high value comment>

Copy link
Member Author

Choose a reason for hiding this comment

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

Allegedly, prettier has an erb linter... allegedly

class Marketplace
class TaxRate < Record
self.table_name = "marketplace_tax_rates"
belongs_to :marketplace
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I think it might be a bit more scannable to have the self.... lines grouped, and the belongs_to in a separate "block" (i.e. separated by a blank line). (Unless they have to be declared in this order?)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point.

router.resources :orders, only: [:show]
router.resources :products
router.resources :products do
router.resources :tax_rates, only: [:create, :destroy, :index, :show]
Copy link
Member

Choose a reason for hiding this comment

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

I only see code to edit and display the Marketplace Tax Rates, but there is this products/tax_rates set of routes, and also a reference from the marketplace products table to tax rates, although the TaxRate model merely belongs_to :marketplace -- maybe you are missing the has_many :marketplace_products on TaxRate and the belongs_to :tax_rate, optional: true on MarketplaceProduct?

I'm not sure if the Tax Rates on Products are left over from a previous version, or if you intend to use those somehow differently?

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 should get rid of this since I haven't started the associating TaxRates to Products yet.

class CreateMarketplaceTaxRates < ActiveRecord::Migration[7.0]
def change
create_table :marketplace_tax_rates, id: :uuid do |t|
t.float :tax_rate
Copy link
Member

Choose a reason for hiding this comment

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

Float feels correct to me, since I agree that it could be a percent, or a fractional amount, or an integer fixed amount. (Maybe eventually we'll end up with an enum here to say if it is %age or "fixed".)

zspencer added 3 commits March 6, 2023 18:37
- #1137

This throws together the basic `CRUD` operations for `TaxRate`. Going to
do a bit of tidying and add some tests, then record a video of the use
case.

I may decide I want to add in the setting of the `TaxRate` on the
`Product`, but maybe I'll wait and add that independently...
I think mayyybeeeeeeee it's better to support decimals.
@zspencer zspencer force-pushed the marketplace/creating-tax-rates branch from 2e96cb9 to da72da4 Compare March 7, 2023 02:37
This also addresses Ana's comments re: Tidying
@zspencer zspencer merged commit e846e87 into main Mar 7, 2023
@zspencer zspencer deleted the marketplace/creating-tax-rates branch March 7, 2023 02:59
@zspencer zspencer added this to the 1.0 - Andromeda milestone May 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ feature Reduces Client's Burden or Grants them Benefits
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants