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

オープン
#4,916 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
75/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
backend, database

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
TypeScript
スター
30
フォーク
10
平均マージ
2日 12時間
マージ済み PR(30日)
276

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Urigo/accounter-fullstack のほかの issue

Urigo/accounter-fullstack の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。