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

Show 3 decimals tax rates in tax summary section of order in admin UI #3051

Closed
OlivierPineau-qc opened this issue Sep 9, 2024 · 5 comments
Closed
Labels
type: bug 🐛 Something isn't working

Comments

@OlivierPineau-qc
Copy link

Describe the bug
It is not a bug but a simple fix can help me greatly. I have a store in the province of Quebec, Canada and in Quebec we have two tax rates, 9.975% and 5%.

I already implemented a plugin to handle all of this on my orders and showing the three decimals in the admin UI in the tax-rates page.

This is how it looks in the admin UI tax rate page.
image

The problem is in the order detail page, specifically in the tax summary section. See below
image

I think I already know how to fix this. The tax summary table uses the percentPipe from Angular. The percentPipe supports adding up to three decimals if value provided has three decimals.

The code that needs to be changed is here.

Here is the path for the monorepo if you don't want to click the link : packages/admin-ui/src/lib/order/src/components/order-detail/order-detail.component.html at line 176.

The fix would simply be to replace percent : '0.0-2' to percent : '0.0-3' and Angular percentPipe will handle the rest :)

Should I create a pull request for this ?

Thanks

@OlivierPineau-qc OlivierPineau-qc added the type: bug 🐛 Something isn't working label Sep 9, 2024
@michaelbromley
Copy link
Member

Hi, thanks for the report and analysis.
I'm currently doing some work for a new release I want to get out today so since it's such a small fix I'll take care of it 👍

@michaelbromley
Copy link
Member

In attempting to reproduce this, I noticed that I was unable to even set a TaxRate to 9.975 - it would get rounded to 9.98.

On investigation this is because the TaxRate.value column is set with a precision of 2.

Have you modified this column (eg via an EntityMetadataModifier) in order to increase the precision?

@OlivierPineau-qc
Copy link
Author

OlivierPineau-qc commented Sep 11, 2024

In attempting to reproduce this, I noticed that I was unable to even set a TaxRate to 9.975 - it would get rounded to 9.98.

On investigation this is because the TaxRate.value column is set with a precision of 2.

Have you modified this column (eg via an EntityMetadataModifier) in order to increase the precision?

Yes sorry I forgot to mention this. Below is my code to modify the precision of the value column to 3.

import { EntityMetadataModifier } from "@vendure/core";
import { TaxRate } from "@vendure/core";
import { DecimalTransformer } from "@vendure/core/dist/entity/value-transformers";
import { Column } from "typeorm";

export const taxRateNumericModifier: EntityMetadataModifier = (metadata) => {
	const taxRateIndex = metadata.columns.findIndex(
		(col) => col.propertyName === "value" && col.target === TaxRate
	);
	if (-1 < taxRateIndex) {
		// Remove the existing column definition from the metadata
		metadata.columns.splice(taxRateIndex, 1);

		// Add a new column definition with the updated scale
		// Any database migration might
		// require manual adjustment to avoid data loss or issues.
		const instance = new TaxRate();
		Column({
			type: "decimal",
			precision: 5,
			scale: 3,
			transformer: new DecimalTransformer(),
		})(instance, "value");
	}
};

@michaelbromley
Copy link
Member

Alright thanks, that now makes total sense. OK the fix was just published in v3.0.3, enjoy!

@OlivierPineau-qc
Copy link
Author

Alright thanks, that now makes total sense. OK the fix was just published in v3.0.3, enjoy!

Thank you so much !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants