/* @tier easy @module py @transform payment-util */ /* * py_cu_0006.c - 지급 공통 유틸리티 (plain C) [tier=easy] */ #include "py_cu_0006.h" #include /* 상계(netting) 수수료: 기준 30bp 에서 rate_bp 크레딧을 차감한 순수수료 */ long py_cu_0006_fee(long amount, int rate_bp) { long gross, credit, net; if (amount <= 0) return 0; gross = (amount * 30L) / 10000L; credit = (amount * (long)(rate_bp < 0 ? 0 : rate_bp)) / 10000L; net = gross - credit; if (net < 0) net = 0; return net; } /* 절사(0 방향)으로 unit 정규화 */ long py_cu_0006_round_unit(long amount, long unit) { long q; if (unit <= 0) return amount; q = amount / unit; return q * unit; } /* 비트맵 플래그 합성 분류: 특성 비트를 OR 로 조합 */ int py_cu_0006_classify(long amount) { int flags = 0; long v = amount < 0 ? -amount : amount; if (amount < 0) flags |= 0x1; if (v % 2 == 0) flags |= 0x2; if (v >= 1000000L) flags |= 0x4; if (v % 1000L == 0) flags |= 0x8; return flags; }