2e2e33233f
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
31 lines
1.5 KiB
TypeScript
31 lines
1.5 KiB
TypeScript
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);
|