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

Đang mở
#4,916 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
75/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
backend, database

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
TypeScript
Star
30
Fork
10
Merge trung bình
2 ngày 12 giờ
Pull request đã merge (30 ngày)
276

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Urigo/accounter-fullstack

Tất cả issue của Urigo/accounter-fullstack

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.