Skip to content

Commit

Permalink
Merge pull request #231 from bigcapitalhq/fix-filter-transactions-dat…
Browse files Browse the repository at this point in the history
…e-format

fix(server): date format of filtering transactions by date range
  • Loading branch information
abouolia authored Aug 29, 2023
2 parents 75d8864 + 84445d4 commit f9d5a3c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
13 changes: 3 additions & 10 deletions packages/server/src/models/AccountTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,9 @@ export default class AccountTransaction extends TenantModel {
}
},
filterDateRange(query, startDate, endDate, type = 'day') {
const dateFormat = 'YYYY-MM-DD HH:mm:ss';
const fromDate = moment(startDate)
.utcOffset(0)
.startOf(type)
.format(dateFormat);
const toDate = moment(endDate)
.utcOffset(0)
.endOf(type)
.format(dateFormat);
const dateFormat = 'YYYY-MM-DD';
const fromDate = moment(startDate).startOf(type).format(dateFormat);
const toDate = moment(endDate).endOf(type).format(dateFormat);

if (startDate) {
query.where('date', '>=', fromDate);
Expand Down Expand Up @@ -111,7 +105,6 @@ export default class AccountTransaction extends TenantModel {
query.modify('filterDateRange', null, toDate);
query.modify('sumationCreditDebit');
},

contactsOpeningBalance(
query,
openingDate,
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/models/InventoryCostLotTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class InventoryCostLotTracker extends TenantModel {
query.groupBy('item_id');
},
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 toDate = moment(endDate).endOf(type).format(dateFormat);

Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/models/InventoryTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default class InventoryTransaction extends TenantModel {
static get modifiers() {
return {
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 toDate = moment(endDate).endOf(type).format(dateFormat);

Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/models/SaleInvoice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export default class SaleInvoice extends mixin(TenantModel, [
* Filters the invoices between the given date range.
*/
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 toDate = moment(endDate).endOf(type).format(dateFormat);

Expand Down

0 comments on commit f9d5a3c

Please sign in to comment.