-
Notifications
You must be signed in to change notification settings - Fork 9
fix: added dash when an invoice is not using our format #78
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
fix: added dash when an invoice is not using our format #78
Conversation
MantisClone
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Please resolve the questions and merge when ready. 👍
| <td | ||
| >{formatUnits(item.unitPrice, currency?.decimals ?? 18)}</td | ||
| > | ||
| <td>{formatUnits(item.discount, currency?.decimals ?? 18)}</td | ||
| > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need || "-" on item.unitPrice and item.discount too?
Also, what's up with the formatting on these two lines?
| <td>{formatUnits(item.unitPrice, currency?.decimals ?? 18)}</td> | ||
| <td>{formatUnits(item.discount, currency?.decimals ?? 18)}</td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need || "-" here too?
…75-do-not-render-or-render---if-invoice-element-is-undefined
WalkthroughThe recent changes in the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Files selected for processing (1)
- packages/invoice-dashboard/src/lib/dashboard/invoice-view.svelte (5 hunks)
Additional comments not posted (8)
packages/invoice-dashboard/src/lib/dashboard/invoice-view.svelte (8)
215-218: LGTM! Handling missing dates gracefully.The fallback values for
creationDateanddueDateensure that the date fields are displayed as"-"if they are undefined.
221-221: LGTM! Handling missing invoice numbers gracefully.The fallback value for
invoiceNumberensures that the invoice number is displayed as"-"if it is undefined.
228-228: LGTM! Handling missing payee values gracefully.The fallback value for
payeeensures that the payee value is displayed as"-"if it is undefined.
234-235: LGTM! Handling missing seller information gracefully.The fallback values for
labelandvalueensure that the seller information fields are displayed as"-"if they are undefined.
243-243: LGTM! Handling missing payer values gracefully.The fallback value for
payerensures that the payer value is displayed as"-"if it is undefined.
249-250: LGTM! Handling missing buyer information gracefully.The fallback values for
labelandvalueensure that the buyer information fields are displayed as"-"if they are undefined.
258-262: LGTM! Handling missing currency information gracefully.The fallback values for
networkandsymbolensure that the currency information fields are displayed as"-"if they are undefined.
Line range hint
324-369:
LGTM! Handling missing invoice item and additional information gracefully.The fallback values for
name,quantity,tax.amount,note, andlabelensure that the respective fields are displayed as"-"if they are undefined.Consider adding fallback values for
unitPriceanddiscount.As suggested in the existing comments, adding fallback values for
unitPriceanddiscountwould ensure consistency.
| <p class="truncate description-text">{item.name || "-"}</p> | ||
| </th> | ||
| <td>{item.quantity}</td> | ||
| <td>{item.quantity || "-"}</td> | ||
| <td>{formatUnits(item.unitPrice, currency?.decimals ?? 18)}</td> | ||
| <td>{formatUnits(item.discount, currency?.decimals ?? 18)}</td> | ||
| <td>{Number(item.tax.amount)}</td> | ||
| <td>{Number(item.tax.amount || "-")}</td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
Codebase Verification
Consider adding fallback values for unitPrice and discount.
The search results indicate that unitPrice and discount fields are used without fallback values in several parts of the codebase. To ensure consistency and prevent potential runtime errors or display issues, it is recommended to add fallback values for these fields.
packages/invoice-dashboard/src/lib/dashboard/invoice-view.sveltepackages/create-invoice-form/src/lib/create-invoice-form.sveltepackages/create-invoice-form/src/lib/invoice/form-view.sveltepackages/create-invoice-form/src/lib/invoice/form.svelte
Analysis chain
LGTM! Handling missing invoice item information gracefully.
The fallback values for name, quantity, and tax.amount ensure that the invoice item fields are displayed as "-" if they are undefined.
Consider adding fallback values for unitPrice and discount.
As suggested in the existing comments, adding fallback values for unitPrice and discount would ensure consistency.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify if `unitPrice` and `discount` fields need fallback values.
# Test: Search for the usage of `unitPrice` and `discount`. Expect: Consistent handling of missing data.
rg --type svelte -A 5 $'item.unitPrice' | rg -v 'formatUnits'
rg --type svelte -A 5 $'item.discount' | rg -v 'formatUnits'
Length of output: 178
Script:
#!/bin/bash
# Description: Verify if `unitPrice` and `discount` fields need fallback values.
# Test: Search for the usage of `unitPrice` and `discount` in .svelte files and check if fallback values are applied.
# Search for the usage of `unitPrice` and exclude lines with `formatUnits`
rg 'item\.unitPrice' --glob '*.svelte' -A 5 | rg -v 'formatUnits'
# Search for the usage of `discount` and exclude lines with `formatUnits`
rg 'item\.discount' --glob '*.svelte' -A 5 | rg -v 'formatUnits'
Length of output: 4858
| <td>{formatUnits(item.unitPrice, currency?.decimals ?? 18)}</td> | ||
| <td>{formatUnits(item.discount, currency?.decimals ?? 18)}</td> | ||
| <td>{Number(item.tax.amount)}</td> | ||
| <td>{Number(item.tax.amount || "-")}</td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also make sure to add here and in the discount and such, these might now be available in some requests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Files selected for processing (1)
- packages/invoice-dashboard/src/lib/dashboard/invoice-view.svelte (5 hunks)
Additional comments not posted (10)
packages/invoice-dashboard/src/lib/dashboard/invoice-view.svelte (10)
215-215: LGTM! Fallback value forcreationDateadded.The fallback value ensures that the date is displayed as "-" if
creationDateis undefined.
217-217: LGTM! Fallback value fordueDateadded.The fallback value ensures that the date is displayed as "-" if
dueDateis undefined.
221-221: LGTM! Fallback value forinvoiceNumberadded.The fallback value ensures that the invoice number is displayed as "-" if
invoiceNumberis undefined.
228-228: LGTM! Fallback value forpayee.valueadded.The fallback value ensures that the payee value is displayed as "-" if
payee.valueis undefined.
234-234: LGTM! Fallback value forlabeladded.The fallback value ensures that the label is displayed as "-" if
labelis undefined.
235-235: LGTM! Fallback value forvalueadded.The fallback value ensures that the value is displayed as "-" if
valueis undefined.
243-243: LGTM! Fallback value forpayer.valueadded.The fallback value ensures that the payer value is displayed as "-" if
payer.valueis undefined.
258-258: LGTM! Fallback value forcurrency.networkadded.The fallback value ensures that the currency network is displayed as "-" if
currency.networkis undefined.
262-262: LGTM! Fallback value forcurrency.symboladded.The fallback value ensures that the currency symbol is displayed as "-" if
currency.symbolis undefined.
284-297: LGTM! Fallback values for item details added.The fallback values ensure that the item details are displayed as "-" if they are undefined.
Consider adding fallback values for
unitPriceanddiscountin other parts of the codebase.As suggested in the existing comments, adding fallback values for
unitPriceanddiscountwould ensure consistency.
Fixes #75
Summary by CodeRabbit