"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TRANSACTION_COLUMNS = void 0;
exports.formatTransactionRows = formatTransactionRows;
exports.TRANSACTION_COLUMNS = [
    { header: 'No', key: 'no', width: 6 },
    { header: 'Tanggal', key: 'date', width: 14 },
    { header: 'Trx Code', key: 'trxCode', width: 22 },
    { header: 'Branch', key: 'branch', width: 16 },
    { header: 'Cust Code', key: 'custCode', width: 14 },
    { header: 'Item Code', key: 'itemCode', width: 22 },
    { header: 'Nama Customer', key: 'custName', width: 26 },
    { header: 'Type', key: 'itemType', width: 10 },
    { header: 'Berat Kotor (g)', key: 'grossWeight', width: 16 },
    { header: 'Berat Bersih (g)', key: 'netWeight', width: 16 },
    { header: 'Karat', key: 'karat', width: 10 },
    { header: 'Kadar (%)', key: 'kadar', width: 12, isPercent: true },
    { header: 'Total Harga (Rp)', key: 'totalPrice', width: 18 },
    { header: 'Harga/gram (Rp)', key: 'pricePerGram', width: 18 },
    { header: 'Bank', key: 'bank', width: 22 },
    { header: 'No Rekening', key: 'bankAccountNo', width: 18 },
    { header: 'Nama Rekening', key: 'bankAccountName', width: 22 },
    { header: 'Frontliner', key: 'frontliner', width: 20 },
    { header: 'Head Store', key: 'headStore', width: 20 },
    { header: 'Status', key: 'status', width: 16 },
    { header: 'Tanggal Selesai', key: 'completedAt', width: 18 },
];
function formatTransactionRows(transactions) {
    const rows = [];
    let no = 1;
    for (const trx of transactions) {
        for (const item of trx.items) {
            rows.push({
                no: no++,
                date: new Date(trx.createdAt).toLocaleDateString('id-ID'),
                trxCode: trx.trxCode,
                branch: trx.branch?.name,
                custCode: trx.customer?.code,
                itemCode: item.itemCode,
                custName: trx.customer?.fullName,
                itemType: item.itemType?.name,
                grossWeight: Number(item.grossWeight),
                netWeight: Number(item.netWeight),
                karat: item.caratId,
                kadar: item.purityPercent != null
                    ? Number(item.purityPercent) / 100
                    : null,
                totalPrice: Number(item.totalPrice),
                pricePerGram: Number(item.pricePerGram),
                bank: trx.bank?.name,
                bankAccountNo: trx.bankAccountNo,
                bankAccountName: trx.bankAccountName,
                frontliner: trx.createdByUser
                    ? `${trx.createdByUser.firstName} ${trx.createdByUser.lastName}`
                    : null,
                headStore: trx.headStoreUser
                    ? `${trx.headStoreUser.firstName} ${trx.headStoreUser.lastName}`
                    : null,
                status: trx.status,
                completedAt: trx.completedAt
                    ? new Date(trx.completedAt).toLocaleDateString('id-ID')
                    : null,
            });
        }
    }
    return rows;
}
//# sourceMappingURL=transaction.formatter.js.map