feat(751-2): 원화 꼴 공용 한 벌 — common_util_money.ts · master_fmt.py 짝 · 거울 시험
- formatMoney(정수) · formatLineMoney(소수 1 · 끝 0 없음) · formatPrice(단가 소수 3 · 200 미만 유효숫자 넷) · formatNumber(수량 · 율 유효숫자 넷) - M01 Logic_Money · Logic_Edit 는 다시 내보내기만(부르는 쪽 그대로) - 파이썬 짝 master_fmt.py(절반 올림 · 은행가 반올림 어긋남 해소) · master_text 갈아 끼움은 받기 뒤 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,7 @@ import { tx } from "./M01_MasterData_UI_Logic_Text";
|
||||
import { createBadge } from "@ui/ui_template_badge";
|
||||
import { createText } from "@ui/ui_template_text";
|
||||
import { createIconButton } from "@ui/ui_template_button";
|
||||
import { formatNumber } from "../common_util/common_util_money";
|
||||
|
||||
export type PickMode = "element" | "table";
|
||||
export type PickDone = (item: ElementBrief, column?: string) => void;
|
||||
@@ -53,11 +54,7 @@ const groupOf = (key: string): string =>
|
||||
const COSTS = ["노무비", "재료비", "경비"];
|
||||
const COST_OF: Record<string, string> = { 인력: "노무비", 재료: "재료비", 기계: "경비" };
|
||||
|
||||
export function formatNumber(value: unknown): string {
|
||||
if (typeof value === "number") return value.toLocaleString("ko-KR", { maximumFractionDigits: 4 });
|
||||
if (value === null || value === undefined) return "";
|
||||
return typeof value === "object" ? JSON.stringify(value) : String(value);
|
||||
}
|
||||
export { formatNumber };
|
||||
|
||||
function textBox(value: unknown, onInput: (v: string) => void, className = ""): HTMLInputElement {
|
||||
const input = el("input", {
|
||||
|
||||
@@ -1,19 +1,11 @@
|
||||
/* =============================================================================
|
||||
* M01_MasterData_UI_Logic_Money.ts
|
||||
* 돈 모양 한 벌 — 원 단위 정수(반올림). 단가·금액·소계·계 자리만 씀 · 수량·비율은 `formatNumber` 그대로
|
||||
* 돈 모양 — 공용 꼴 한 벌(`common_util/common_util_money.ts`)을 다시 내보냄. 부르는 쪽은 그대로.
|
||||
* ========================================================================== */
|
||||
|
||||
import { formatNumber } from "./M01_MasterData_UI_Logic_Edit";
|
||||
|
||||
export const formatMoney = (value: unknown): string =>
|
||||
typeof value === "number"
|
||||
? value.toLocaleString("ko-KR", { maximumFractionDigits: 0 })
|
||||
: formatNumber(value);
|
||||
|
||||
/** 단가 모양 — 정수로 보이되 200 원 미만은 반올림 오차가 커서 소수 넷째 자리·유효숫자 4 자리 중 많은 쪽(뒤 0 뗌) */
|
||||
export const formatPrice = (value: unknown): string =>
|
||||
typeof value === "number" && value !== 0 && Math.abs(value) < 200
|
||||
? value.toLocaleString("ko-KR", {
|
||||
maximumFractionDigits: Math.max(4, 3 - Math.floor(Math.log10(Math.abs(value)))),
|
||||
})
|
||||
: formatMoney(value);
|
||||
export {
|
||||
formatLineMoney,
|
||||
formatMoney,
|
||||
formatNumber,
|
||||
formatPrice,
|
||||
} from "../common_util/common_util_money";
|
||||
|
||||
Reference in New Issue
Block a user