All files / src/web/schemas transaction.ts

100% Statements 8/8
100% Branches 0/0
100% Functions 1/1
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103  7x 7x   7x 14x                                                                               7x                                                             7x                                                   7x
import { Schema } from "swagger-jsdoc"
import { EntryTypeExtensions } from "../../core/extensions/entryTypeExtensions"
import { TransactionTypeExtensions } from "../../core/extensions/transactionTypeExtensions"
 
const createTransactionSchema = (type: Schema, paymentDetails: Schema): Schema => {
    return {
        type: "object",
        properties: {
            id: {
                type: "string",
                description: "Global unique transaction ID across all transaction source providers.",
                example: "1773e8e6b4cff981"
            },
            date: {
                type: "string",
                description: "The datetime when the transaction was processed by the bank.",
                example: "Fri May 19th 2023 12:24:24 PM"
            },
            reference: {
                type: "string",
                description: "The reference for this transaction. Unique when coupled with the transaction type.",
                example: "403BATM230900160"
            },
            value_date: {
                type: "string",
                description: "The date when the transaction took place.",
                example: "Wed May 17th 2023"
            },
            sum: {
                type: "number",
                description: "The amount that was credited / debited from the bank account.",
                example: "12.34"
            },
            entry_type: {
                type: "string",
                enum: EntryTypeExtensions.keys(),
                description: "The entry type of the transaction.",
                example: "DEBIT"
            },
            type: type,
            paymentDetails: paymentDetails
        }
    };
};
 
const cardOperationTransaction = createTransactionSchema({
        type: "string",
        enum: TransactionTypeExtensions.keys(),
        description: "The type of transaction based on its payment details.",
        example: "CARD_OPERATION"
    }, {
        type: "object",
        properties: {
            recipient: {
                type: "string",
                description: "The receiving party of the transaction.",
                example: "Netflix"
            },
            instrument: {
                type: "string",
                description: "The payment mechanism used to facilitate the transaction.",
                example: "ПОС"
            },
            sum: {
                type: "string",
                description: "The sum of the transaction in the original currency it was executed.",
                example: "19.99"
            },
            currency: {
                type: "string",
                description: "The currency in which the transaction was executed.",
                example: "EUR"
            },
        }
    });
 
const standardTransferTransaction = createTransactionSchema({
        type: "string",
        enum: TransactionTypeExtensions.keys(),
        description: "The type of transaction based on its payment details.",
        example: "UTILITY_PAYMENT"
    }, {
        type: "object",
        properties: {
            recipient: {
                type: "string",
                description: "The receiving party of the transaction.",
                example: "ЧЕЗ ЕЛЕКТРО БЪЛГАРИЯ АД"
            },
            recipientIban: {
                type: "string",
                description: "The IBAN of the recipient of the transaction.",
                example: "BG81UNCR763044444CEZEL"
            },
            description: {
                type: "string",
                description: "Any additional description of the transaction.",
                example: "ЧЕЗ единични плащания 310123456795 271234596/09.04.2020/09.04.2020"
            }
        }
    });
 
export { cardOperationTransaction, standardTransferTransaction };