Skip to content
This repository has been archived by the owner on Jan 10, 2020. It is now read-only.

Commit

Permalink
allow any kind of date in search
Browse files Browse the repository at this point in the history
  • Loading branch information
James Baxley committed Dec 15, 2016
1 parent e5df93c commit c10df37
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/rock/models/finances/models/Transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ export default class Transaction extends Rock {

let TransactionDateTime;
if (start || end) TransactionDateTime = {};
if (start) TransactionDateTime.$gt = Moment(start, "MM/YY");
if (end) TransactionDateTime.$lt = Moment(end, "MM/YY");
if (start) TransactionDateTime.$gt = Moment(start);
if (end) TransactionDateTime.$lt = Moment(end);

let ParentAccount = await FinancialAccount.find({
where: { ParentAccountId: id }
Expand Down Expand Up @@ -157,8 +157,8 @@ export default class Transaction extends Rock {

let TransactionDateTime;
if (start || end) TransactionDateTime = {};
if (start) TransactionDateTime.$gt = Moment(start, "MM/YY");
if (end) TransactionDateTime.$lt = Moment(end, "MM/YY");
if (start) TransactionDateTime.$gt = Moment(start);
if (end) TransactionDateTime.$lt = Moment(end);

return this.cache.get(
this.cache.encode(query, "findByGivingGroup"), () => TransactionTable.find({
Expand Down
4 changes: 2 additions & 2 deletions src/rock/models/finances/models/__tests__/Transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jest.mock("xml2js", () => ({
jest.mock("isomorphic-fetch", () => jest.fn(() => Promise.resolve()));
jest.mock("../../util/formatTransaction");

moment.mockImplementation((date, format) => `${date} formatted as ${format}`);
moment.mockImplementation((date) => `${date}`);

const jobAdd = jest.fn();

Expand Down Expand Up @@ -655,7 +655,7 @@ describe("findByAccountType", () => {
$in: [10, 11],
},
TransactionDateTime: {
$gt: "10/13 formatted as MM/YY", $lt: "10/15 formatted as MM/YY",
$gt: "10/13", $lt: "10/15",
},
},
include: [
Expand Down

0 comments on commit c10df37

Please sign in to comment.