Files
butcem/src/models/reconciliation.ts
T

31 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { model, models, Schema, type InferSchemaType, type Model } from "mongoose";
/**
* Mutabakat kaydı (Bölüm 6.1): kullanıcı ekstre bakiyesini girdi, uygulama bakiyesiyle
* karşılaştırıldı, fark varsa düzeltme işlemi oluşturuldu ve o tarihe kadarki işlemler işaretlendi.
*/
const reconciliationSchema = new Schema(
{
householdId: { type: Schema.Types.ObjectId, required: true },
accountId: { type: Schema.Types.ObjectId, required: true },
/** İstanbul gününün başlangıç anı (UTC); o günün sonuna kadarki işlemler dahil. */
statementDate: { type: Date, required: true },
/** Uygulamadaki işaretle (kredi kartında eksi = borç). */
statementBalanceMinor: { type: Number, required: true },
appBalanceMinor: { type: Number, required: true },
differenceMinor: { type: Number, required: true },
adjustmentTransactionId: { type: Schema.Types.ObjectId, default: null },
markedCount: { type: Number, default: 0 },
createdBy: { type: Schema.Types.ObjectId, required: true },
},
{ timestamps: { createdAt: true, updatedAt: false }, collection: "reconciliations" },
);
reconciliationSchema.index({ householdId: 1, accountId: 1, statementDate: -1, createdAt: -1 });
export type Reconciliation = InferSchemaType<typeof reconciliationSchema>;
export const ReconciliationModel: Model<Reconciliation> =
(models.Reconciliation as Model<Reconciliation> | undefined) ??
model<Reconciliation>("Reconciliation", reconciliationSchema);