feat(quantity): ④ 전체 합계에 교량 전체 집계 표를 추가
- 교각 목록의 "전체"를 "전체 합계 (N기)"로 표시 - 전체를 고르고 2기 이상이면 강종·직경별 교량 전체 집계를 맨 위에 표시 (소계, 합계, 할증 포함, 커플러) - 집계 규칙을 core/quantity-total.ts로 분리하고 테스트 3건 추가. 교각별 표는 그대로 Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7861bc3fdf
commit
1ecd7542ee
4 files changed
+133
-10
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { aggregateQuantities } from '../src/core/quantity-total';
|
||||
import type { Quantity } from '../src/core/rebar/quantity';
|
||||
|
||||
/** A 재료표 with one 강종·직경 line; only the fields the aggregate reads are filled. */
|
||||
function quantity(grade: number, size: string, count: number, totalM: number, kg: number, extra: Partial<Quantity> = {}): Quantity {
|
||||
return {
|
||||
groups: [{ grade, kg, diameters: [{ size, dMm: 19, lines: [{ count } as never], totalM, kg }] }],
|
||||
couplers: [],
|
||||
missing: [],
|
||||
kg,
|
||||
wastePercent: 0,
|
||||
kgWithWaste: kg,
|
||||
ton: kg / 1000,
|
||||
...extra,
|
||||
};
|
||||
}
|
||||
|
||||
describe('aggregateQuantities (교량 전체 집계)', () => {
|
||||
it('sums the same 강종·직경 over the piers', () => {
|
||||
const total = aggregateQuantities([quantity(400, 'H19', 10, 100, 225), quantity(400, 'H19', 5, 50, 112.5)]);
|
||||
expect(total.rows).toEqual([{ grade: 400, size: 'H19', count: 15, totalM: 150, kg: 337.5 }]);
|
||||
expect(total.kg).toBe(337.5);
|
||||
});
|
||||
|
||||
it('keeps different 강종 and 직경 apart and orders them by 강종 then 직경', () => {
|
||||
const total = aggregateQuantities([quantity(500, 'S19', 4, 40, 90), quantity(400, 'H25', 2, 20, 50), quantity(400, 'H19', 1, 10, 22.5)]);
|
||||
expect(total.rows.map((r) => `${r.grade}|${r.size}`)).toEqual(['400|H19', '400|H25', '500|S19']);
|
||||
expect(total.gradeKg).toEqual([{ grade: 400, kg: 72.5 }, { grade: 500, kg: 90 }]);
|
||||
});
|
||||
|
||||
it('adds the 할증 total and the couplers across the piers', () => {
|
||||
const total = aggregateQuantities([
|
||||
{ ...quantity(400, 'H19', 1, 1, 100, { kgWithWaste: 110, couplers: [{ name: '커플러 H19', count: 3 }] }) },
|
||||
{ ...quantity(400, 'H19', 1, 1, 200, { kgWithWaste: 220, couplers: [{ name: '커플러 H19', count: 2 }] }) },
|
||||
]);
|
||||
expect(total.kgWithWaste).toBe(330);
|
||||
expect(total.ton).toBeCloseTo(0.33, 6);
|
||||
expect(total.couplers).toEqual([{ name: '커플러 H19', count: 5 }]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user