Fix some for production
This commit is contained in:
+80
@@ -0,0 +1,80 @@
|
||||
/** Standard purity the ledger normalizes all gold weights to (18k, per-mille). */
|
||||
export declare const STANDARD_KARAT_PER_MILLE = 750;
|
||||
/** Grams per traditional Iranian "mesghal" unit, used for cash<->gram conversion. */
|
||||
export declare const GRAMS_PER_MESGHAL = 4.331802;
|
||||
export declare enum LedgerCurrency {
|
||||
GOLD_GRAM = "GOLD_GRAM",
|
||||
RIAL = "RIAL"
|
||||
}
|
||||
export declare enum LedgerDirection {
|
||||
DEBIT = "DEBIT",// increases what the customer owes
|
||||
CREDIT = "CREDIT"
|
||||
}
|
||||
/** What generated a ledger entry. Mirrors legacy Cash.type + Order debt postings. */
|
||||
export declare enum LedgerSourceType {
|
||||
ORDER_STOCK = "ORDER_STOCK",
|
||||
ORDER_PRE_ORDER = "ORDER_PRE_ORDER",
|
||||
REPAYMENT_MELTED_GOLD = "REPAYMENT_MELTED_GOLD",// legacy Cash.type=1, ayar-normalized
|
||||
REPAYMENT_TRANSFER = "REPAYMENT_TRANSFER",// legacy Cash.type=2
|
||||
REPAYMENT_CHEQUE = "REPAYMENT_CHEQUE",// legacy Cash.type=3
|
||||
REPAYMENT_CASH = "REPAYMENT_CASH",// legacy Cash.type=4, price/gram-normalized
|
||||
WALLET_BONUS = "WALLET_BONUS",// cashback gold bonus, time-limited
|
||||
ADJUSTMENT = "ADJUSTMENT"
|
||||
}
|
||||
/** Stock order status flow. Debt is only posted once status reaches DELIVERED_TO_AGENT (mirrors legacy sts>4, which first becomes true at sts=5, not sts=6/DELIVERED_TO_CUSTOMER). */
|
||||
export declare enum OrderStatus {
|
||||
SUSPENDED = "SUSPENDED",// credit limit (gram_level) exceeded at placement
|
||||
PLACED = "PLACED",
|
||||
ADMIN_APPROVED = "ADMIN_APPROVED",
|
||||
SOURCING = "SOURCING",
|
||||
PREPARING = "PREPARING",
|
||||
DELIVERED_TO_AGENT = "DELIVERED_TO_AGENT",
|
||||
DELIVERED_TO_CUSTOMER = "DELIVERED_TO_CUSTOMER",
|
||||
CANCELLED = "CANCELLED"
|
||||
}
|
||||
/** Pre-order (custom manufacturing) status flow — distinct from stock orders; no debt posts until priced/converted. */
|
||||
export declare enum PreOrderStatus {
|
||||
PLACED = "PLACED",
|
||||
ADMIN_APPROVED = "ADMIN_APPROVED",
|
||||
WORKSHOP_APPROVED = "WORKSHOP_APPROVED",
|
||||
READY_TO_SHIP = "READY_TO_SHIP",
|
||||
DELIVERED = "DELIVERED",
|
||||
CANCELLED = "CANCELLED"
|
||||
}
|
||||
export interface CreateOrderItemDto {
|
||||
productVariantId: string;
|
||||
quantity: number;
|
||||
/** Making-charge percentage negotiated for this order (rash weight is looked up server-side from the variant, never trusted from the client). */
|
||||
wagePercent: number;
|
||||
/** Promotional discount percentage deducted from wagePercent. */
|
||||
discountPercent?: number;
|
||||
/** Flat Rial charge on this item independent of gold weight (e.g. stones). */
|
||||
flatRialCharge?: number;
|
||||
}
|
||||
export interface CreateOrderDto {
|
||||
customerId: string;
|
||||
branchId?: string;
|
||||
items: CreateOrderItemDto[];
|
||||
}
|
||||
export interface LedgerEntryDto {
|
||||
id: string;
|
||||
customerId: string;
|
||||
currency: LedgerCurrency;
|
||||
direction: LedgerDirection;
|
||||
sourceType: LedgerSourceType;
|
||||
amount: string;
|
||||
/** Karat purity of the instrument, when applicable (melted gold repayments). */
|
||||
karatPerMille?: number;
|
||||
/** Gold price per gram at time of a cash-instrument conversion, when applicable. */
|
||||
pricePerGramAtEntry?: string;
|
||||
confirmed: boolean;
|
||||
orderId?: string;
|
||||
note?: string;
|
||||
createdAt: string;
|
||||
}
|
||||
export interface CustomerBalanceDto {
|
||||
customerId: string;
|
||||
goldDebtGrams: string;
|
||||
fiatDebtRial: string;
|
||||
goldCreditLimitGrams: string;
|
||||
}
|
||||
Vendored
+54
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
// Core domain constants and DTOs shared across api / admin-panel / user-app.
|
||||
// Ported from the legacy Laravel "System A" gram-ledger (henza_server), the
|
||||
// authoritative debt model per the migration decision.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PreOrderStatus = exports.OrderStatus = exports.LedgerSourceType = exports.LedgerDirection = exports.LedgerCurrency = exports.GRAMS_PER_MESGHAL = exports.STANDARD_KARAT_PER_MILLE = void 0;
|
||||
/** Standard purity the ledger normalizes all gold weights to (18k, per-mille). */
|
||||
exports.STANDARD_KARAT_PER_MILLE = 750;
|
||||
/** Grams per traditional Iranian "mesghal" unit, used for cash<->gram conversion. */
|
||||
exports.GRAMS_PER_MESGHAL = 4.331802;
|
||||
var LedgerCurrency;
|
||||
(function (LedgerCurrency) {
|
||||
LedgerCurrency["GOLD_GRAM"] = "GOLD_GRAM";
|
||||
LedgerCurrency["RIAL"] = "RIAL";
|
||||
})(LedgerCurrency || (exports.LedgerCurrency = LedgerCurrency = {}));
|
||||
var LedgerDirection;
|
||||
(function (LedgerDirection) {
|
||||
LedgerDirection["DEBIT"] = "DEBIT";
|
||||
LedgerDirection["CREDIT"] = "CREDIT";
|
||||
})(LedgerDirection || (exports.LedgerDirection = LedgerDirection = {}));
|
||||
/** What generated a ledger entry. Mirrors legacy Cash.type + Order debt postings. */
|
||||
var LedgerSourceType;
|
||||
(function (LedgerSourceType) {
|
||||
LedgerSourceType["ORDER_STOCK"] = "ORDER_STOCK";
|
||||
LedgerSourceType["ORDER_PRE_ORDER"] = "ORDER_PRE_ORDER";
|
||||
LedgerSourceType["REPAYMENT_MELTED_GOLD"] = "REPAYMENT_MELTED_GOLD";
|
||||
LedgerSourceType["REPAYMENT_TRANSFER"] = "REPAYMENT_TRANSFER";
|
||||
LedgerSourceType["REPAYMENT_CHEQUE"] = "REPAYMENT_CHEQUE";
|
||||
LedgerSourceType["REPAYMENT_CASH"] = "REPAYMENT_CASH";
|
||||
LedgerSourceType["WALLET_BONUS"] = "WALLET_BONUS";
|
||||
LedgerSourceType["ADJUSTMENT"] = "ADJUSTMENT";
|
||||
})(LedgerSourceType || (exports.LedgerSourceType = LedgerSourceType = {}));
|
||||
/** Stock order status flow. Debt is only posted once status reaches DELIVERED_TO_AGENT (mirrors legacy sts>4, which first becomes true at sts=5, not sts=6/DELIVERED_TO_CUSTOMER). */
|
||||
var OrderStatus;
|
||||
(function (OrderStatus) {
|
||||
OrderStatus["SUSPENDED"] = "SUSPENDED";
|
||||
OrderStatus["PLACED"] = "PLACED";
|
||||
OrderStatus["ADMIN_APPROVED"] = "ADMIN_APPROVED";
|
||||
OrderStatus["SOURCING"] = "SOURCING";
|
||||
OrderStatus["PREPARING"] = "PREPARING";
|
||||
OrderStatus["DELIVERED_TO_AGENT"] = "DELIVERED_TO_AGENT";
|
||||
OrderStatus["DELIVERED_TO_CUSTOMER"] = "DELIVERED_TO_CUSTOMER";
|
||||
OrderStatus["CANCELLED"] = "CANCELLED";
|
||||
})(OrderStatus || (exports.OrderStatus = OrderStatus = {}));
|
||||
/** Pre-order (custom manufacturing) status flow — distinct from stock orders; no debt posts until priced/converted. */
|
||||
var PreOrderStatus;
|
||||
(function (PreOrderStatus) {
|
||||
PreOrderStatus["PLACED"] = "PLACED";
|
||||
PreOrderStatus["ADMIN_APPROVED"] = "ADMIN_APPROVED";
|
||||
PreOrderStatus["WORKSHOP_APPROVED"] = "WORKSHOP_APPROVED";
|
||||
PreOrderStatus["READY_TO_SHIP"] = "READY_TO_SHIP";
|
||||
PreOrderStatus["DELIVERED"] = "DELIVERED";
|
||||
PreOrderStatus["CANCELLED"] = "CANCELLED";
|
||||
})(PreOrderStatus || (exports.PreOrderStatus = PreOrderStatus = {}));
|
||||
Reference in New Issue
Block a user