Merge branch 'hotfix/1.36.2' into develop
This commit is contained in:
@@ -213,7 +213,7 @@ export const updateOrAddBill = withUser(async (user:AuthenticatedUser, locationI
|
|||||||
if (addToSubsequentMonths && billYear && billMonth) {
|
if (addToSubsequentMonths && billYear && billMonth) {
|
||||||
// Get the current location to find its name
|
// Get the current location to find its name
|
||||||
const currentLocation = await dbClient.collection<BillingLocation>("lokacije")
|
const currentLocation = await dbClient.collection<BillingLocation>("lokacije")
|
||||||
.findOne({ _id: locationId, userId }, { projection: { bills: 0 } });
|
.findOne({ _id: locationId, userId }, { projection: { name: 1 } });
|
||||||
|
|
||||||
if (currentLocation) {
|
if (currentLocation) {
|
||||||
// Find all subsequent months that have the same location name
|
// Find all subsequent months that have the same location name
|
||||||
@@ -228,7 +228,7 @@ export const updateOrAddBill = withUser(async (user:AuthenticatedUser, locationI
|
|||||||
"yearMonth.month": { $gt: billMonth }
|
"yearMonth.month": { $gt: billMonth }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}, { projection: { bills: 0 } })
|
}, { projection: { _id: 1 } })
|
||||||
.toArray();
|
.toArray();
|
||||||
|
|
||||||
// For each subsequent location, check if bill with same name already exists
|
// For each subsequent location, check if bill with same name already exists
|
||||||
@@ -239,11 +239,8 @@ export const updateOrAddBill = withUser(async (user:AuthenticatedUser, locationI
|
|||||||
_id: location._id,
|
_id: location._id,
|
||||||
"bills.name": billName
|
"bills.name": billName
|
||||||
}, {
|
}, {
|
||||||
projection: {
|
// We only need to know if a matching bill exists; avoid conflicting projections
|
||||||
"bills.$": 1,
|
projection: { _id: 1 }
|
||||||
"bills.attachment": 0,
|
|
||||||
"bills.barcodeImage": 0
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Only add if bill with same name doesn't already exist
|
// Only add if bill with same name doesn't already exist
|
||||||
@@ -371,8 +368,9 @@ export const deleteBillById = withUser(async (user:AuthenticatedUser, locationID
|
|||||||
const location = await dbClient.collection<BillingLocation>("lokacije")
|
const location = await dbClient.collection<BillingLocation>("lokacije")
|
||||||
.findOne({ _id: locationID, userId }, {
|
.findOne({ _id: locationID, userId }, {
|
||||||
projection: {
|
projection: {
|
||||||
"bills.attachment.fileContentsBase64": 0,
|
"name": 1,
|
||||||
"bills.barcodeImage": 0
|
"bills._id": 1,
|
||||||
|
"bills.name": 1
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -393,7 +391,7 @@ export const deleteBillById = withUser(async (user:AuthenticatedUser, locationID
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"bills.name": bill.name
|
"bills.name": bill.name
|
||||||
}, { projection: { bills: 0 } })
|
}, { projection: { _id: 1 } })
|
||||||
.toArray();
|
.toArray();
|
||||||
|
|
||||||
// Delete the bill from all subsequent locations (by name)
|
// Delete the bill from all subsequent locations (by name)
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ const FormSchema = (t:IntlTemplateFn) => z.object({
|
|||||||
_id: z.string(),
|
_id: z.string(),
|
||||||
locationName: z.coerce.string().min(1, t("location-name-required")),
|
locationName: z.coerce.string().min(1, t("location-name-required")),
|
||||||
locationNotes: z.string(),
|
locationNotes: z.string(),
|
||||||
addToSubsequentMonths: z.boolean().optional(),
|
addToSubsequentMonths: z.boolean().optional().nullable(),
|
||||||
updateScope: z.enum(["current", "subsequent", "all"]).optional(),
|
updateScope: z.enum(["current", "subsequent", "all"]).optional().nullable(),
|
||||||
})
|
})
|
||||||
// dont include the _id field in the response
|
// dont include the _id field in the response
|
||||||
.omit({ _id: true });
|
.omit({ _id: true });
|
||||||
@@ -369,7 +369,7 @@ export const deleteLocationById = withUser(async (user:AuthenticatedUser, locati
|
|||||||
if (deleteInSubsequentMonths) {
|
if (deleteInSubsequentMonths) {
|
||||||
// Get the location name first to find all locations with the same name
|
// Get the location name first to find all locations with the same name
|
||||||
const location = await dbClient.collection<BillingLocation>("lokacije")
|
const location = await dbClient.collection<BillingLocation>("lokacije")
|
||||||
.findOne({ _id: locationID, userId }, { projection: { bills: 0 } });
|
.findOne({ _id: locationID, userId }, { projection: { name: 1 } });
|
||||||
|
|
||||||
if (location) {
|
if (location) {
|
||||||
// Delete all locations with the same name in current and subsequent months
|
// Delete all locations with the same name in current and subsequent months
|
||||||
|
|||||||
Reference in New Issue
Block a user