chore: fix problem of transcation beeing commited throw update the "

category variant
This commit is contained in:
mahyargdz
2025-09-21 11:45:24 +03:30
parent 3d1aa01f2e
commit 79f597cc90
23 changed files with 52 additions and 97 deletions
-15
View File
@@ -1720,10 +1720,8 @@ class OrderItemRepo extends BaseRepository<IOrderItem> {
async getDailyShipmentSalesReport() {
const today = new Date();
today.setHours(0, 0, 0, 0);
console.log(today);
const startOfDay = new Date(today.getFullYear(), today.getMonth(), today.getDate());
const endOfDay = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 23, 59, 59, 999);
console.log({ today, startOfDay, endOfDay });
const salesData = await this.model.aggregate([
{
$match: {
@@ -1752,7 +1750,6 @@ class OrderItemRepo extends BaseRepository<IOrderItem> {
itemsSold: 0,
totalOrders: 0,
};
console.log(salesData);
return salesData.length > 0 ? salesData[0] : defaultData;
}
@@ -1763,7 +1760,6 @@ class OrderItemRepo extends BaseRepository<IOrderItem> {
startOfWeek.setDate(today.getDate() - 6); // 7 days ago
const endOfWeek = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 23, 59, 59, 999);
console.log({ today, startOfWeek, endOfWeek });
const salesData = await this.model.aggregate([
{
$match: {
@@ -1792,7 +1788,6 @@ class OrderItemRepo extends BaseRepository<IOrderItem> {
itemsSold: 0,
totalOrders: 0,
};
console.log(salesData);
return salesData.length > 0 ? salesData[0] : defaultData;
}
@@ -1801,7 +1796,6 @@ class OrderItemRepo extends BaseRepository<IOrderItem> {
const startOfMonth = new Date(today.getFullYear(), today.getMonth(), 1);
const endOfMonth = new Date(today.getFullYear(), today.getMonth() + 1, 1);
console.log({ today, startOfMonth, endOfMonth });
const salesData = await this.model.aggregate([
{
$match: {
@@ -1830,7 +1824,6 @@ class OrderItemRepo extends BaseRepository<IOrderItem> {
itemsSold: 0,
totalOrders: 0,
};
console.log(salesData);
return salesData.length > 0 ? salesData[0] : defaultData;
}
@@ -1839,7 +1832,6 @@ class OrderItemRepo extends BaseRepository<IOrderItem> {
const startOfYear = new Date(today.getFullYear(), 0, 1);
const endOfYear = new Date(today.getFullYear() + 1, 0, 1);
console.log({ today, startOfYear, endOfYear });
const salesData = await this.model.aggregate([
{
$match: {
@@ -1868,17 +1860,14 @@ class OrderItemRepo extends BaseRepository<IOrderItem> {
itemsSold: 0,
totalOrders: 0,
};
console.log(salesData);
return salesData.length > 0 ? salesData[0] : defaultData;
}
async getDailySalesReport() {
const today = new Date();
today.setHours(0, 0, 0, 0);
console.log(today);
const startOfDay = new Date(today.getFullYear(), today.getMonth(), today.getDate());
const endOfDay = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 23, 59, 59, 999);
console.log({ today, startOfDay, endOfDay });
const salesData = await this.model.aggregate([
{
$match: {
@@ -1909,7 +1898,6 @@ class OrderItemRepo extends BaseRepository<IOrderItem> {
itemsSold: 0,
totalOrders: 0,
};
console.log(salesData);
return salesData.length > 0 ? salesData[0] : defaultData;
}
@@ -1920,8 +1908,6 @@ class OrderItemRepo extends BaseRepository<IOrderItem> {
startOfWeek.setDate(today.getDate() - 6); // 7 days ago
const endOfWeek = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 23, 59, 59, 999);
console.log({ today, startOfWeek, endOfWeek });
const salesData = await this.model.aggregate([
{
$match: {
@@ -1952,7 +1938,6 @@ class OrderItemRepo extends BaseRepository<IOrderItem> {
itemsSold: 0,
totalOrders: 0,
};
console.log(salesData);
return salesData.length > 0 ? salesData[0] : defaultData;
}