fix(server): date format of filtering transactions by date range

This commit is contained in:
Ahmed Bouhuolia
2023-08-29 02:41:40 +02:00
parent 75d8864aae
commit 84445d4bac
4 changed files with 6 additions and 13 deletions

View File

@@ -59,15 +59,9 @@ export default class AccountTransaction extends TenantModel {
} }
}, },
filterDateRange(query, startDate, endDate, type = 'day') { filterDateRange(query, startDate, endDate, type = 'day') {
const dateFormat = 'YYYY-MM-DD HH:mm:ss'; const dateFormat = 'YYYY-MM-DD';
const fromDate = moment(startDate) const fromDate = moment(startDate).startOf(type).format(dateFormat);
.utcOffset(0) const toDate = moment(endDate).endOf(type).format(dateFormat);
.startOf(type)
.format(dateFormat);
const toDate = moment(endDate)
.utcOffset(0)
.endOf(type)
.format(dateFormat);
if (startDate) { if (startDate) {
query.where('date', '>=', fromDate); query.where('date', '>=', fromDate);
@@ -111,7 +105,6 @@ export default class AccountTransaction extends TenantModel {
query.modify('filterDateRange', null, toDate); query.modify('filterDateRange', null, toDate);
query.modify('sumationCreditDebit'); query.modify('sumationCreditDebit');
}, },
contactsOpeningBalance( contactsOpeningBalance(
query, query,
openingDate, openingDate,

View File

@@ -33,7 +33,7 @@ export default class InventoryCostLotTracker extends TenantModel {
query.groupBy('item_id'); query.groupBy('item_id');
}, },
filterDateRange(query, startDate, endDate, type = 'day') { filterDateRange(query, startDate, endDate, type = 'day') {
const dateFormat = 'YYYY-MM-DD HH:mm:ss'; const dateFormat = 'YYYY-MM-DD';
const fromDate = moment(startDate).startOf(type).format(dateFormat); const fromDate = moment(startDate).startOf(type).format(dateFormat);
const toDate = moment(endDate).endOf(type).format(dateFormat); const toDate = moment(endDate).endOf(type).format(dateFormat);

View File

@@ -36,7 +36,7 @@ export default class InventoryTransaction extends TenantModel {
static get modifiers() { static get modifiers() {
return { return {
filterDateRange(query, startDate, endDate, type = 'day') { filterDateRange(query, startDate, endDate, type = 'day') {
const dateFormat = 'YYYY-MM-DD HH:mm:ss'; const dateFormat = 'YYYY-MM-DD';
const fromDate = moment(startDate).startOf(type).format(dateFormat); const fromDate = moment(startDate).startOf(type).format(dateFormat);
const toDate = moment(endDate).endOf(type).format(dateFormat); const toDate = moment(endDate).endOf(type).format(dateFormat);

View File

@@ -176,7 +176,7 @@ export default class SaleInvoice extends mixin(TenantModel, [
* Filters the invoices between the given date range. * Filters the invoices between the given date range.
*/ */
filterDateRange(query, startDate, endDate, type = 'day') { filterDateRange(query, startDate, endDate, type = 'day') {
const dateFormat = 'YYYY-MM-DD HH:mm:ss'; const dateFormat = 'YYYY-MM-DD';
const fromDate = moment(startDate).startOf(type).format(dateFormat); const fromDate = moment(startDate).startOf(type).format(dateFormat);
const toDate = moment(endDate).endOf(type).format(dateFormat); const toDate = moment(endDate).endOf(type).format(dateFormat);