Shareholder T&S credit: taxable / max-taxable look swapped; a shareholder at the cap gets a 0-amount expense

Open
#4,916 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
backend, database

Research direction

Read packages/server/src/modules/business-trips/resolvers/credit-shareholders-business-trip-travel-and-subsistence.resolver.ts and trace how the summary row’s maxTaxableForeignCurrency and taxableForeignCurrency fields are defined and used. Check the related tests, then add coverage for the available amount calculation and a repeat run at the cap; done means the correct amount is distributed and no zero-amount expense or charge is created.

Written by the indexing model from the issue text.

Description

In packages/server/src/modules/business-trips/resolvers/credit-shareholders-business-trip-travel-and-subsistence.resolver.ts:

1. Possible swap (lines 121-124). The destructured names look reversed relative to the fields they read:

const [{ raw: taxableAmount }, { raw: maxTaxableAmount }] = await Promise.all([
  travelAndSubsistenceRow.maxTaxableForeignCurrency,
  travelAndSubsistenceRow.taxableForeignCurrency,
]);
const availableAmountToDistribute = Math.max(maxTaxableAmount - taxableAmount, 0);

If the fields mean what their names say, availableAmountToDistribute is taxable - maxTaxable. That is usually ≤ 0, so creditShareholdersBusinessTripTravelAndSubsistence credits nothing. It is the opposite only if the summary row's field names are themselves inverted. Confirm which way round is correct and fix whichever side is wrong.

2. 0-amount expenses at the cap (line 305). if (payedAmount > maxTaxableAmount) return; uses a strict >. A shareholder paid exactly up to the cap gets a potential of 0, and the final map still creates a travel-and-subsistence expense with amount: 0 for them, along with its charge. Running the mutation again after a full credit therefore adds a zero expense and charge per shareholder. Use >=, or filter out zero amounts before creating expenses.

Done when: the available amount is computed from the right fields, a repeated run after a full credit creates nothing, and a test covers both cases.


Generated by Claude Code

Dominant language
TypeScript
Stars
30
Forks
10
Avg merge
2d 12h
Merged PRs (30d)
276

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Urigo/accounter-fullstack

All issues in Urigo/accounter-fullstack

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.