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

Commit

Permalink
if no start is passed, default to year end review (#259)
Browse files Browse the repository at this point in the history
* if no start is passed, default to year end review

* update snapshot
  • Loading branch information
James Baxley committed Jan 1, 2017
1 parent 5484238 commit ea49d50
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ Array [
accountName: String
gateway: String = \"NMI Gateway\",
): SavePaymentMutationResponse",
"updateSavedPayment(
entityId: Int
name: String!
): SavePaymentMutationResponse",
"cancelSchedule(
id: ID
entityId: Int
Expand Down
6 changes: 5 additions & 1 deletion src/rock/models/finances/__tests__/resolver.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import moment from "moment";
import resolver from "../resolver";

import render from "../util/statement";
Expand Down Expand Up @@ -391,7 +392,10 @@ describe("Mutation", () => {
null, { people: [1,2], start: "", end: "" }, { models, person }
)

expect(models.Transaction.getStatement).toBeCalledWith({ start: "", end: "", "givingGroupId": 1, "people": [1, 2] });


const defaultStart = moment().startOf("year");
expect(models.Transaction.getStatement).toBeCalledWith({ start: defaultStart, end: "", "givingGroupId": 1, "people": [1, 2] });
expect(models.Person.getHomesFromId).toBeCalledWith(1);
expect(render).toBeCalledWith({home: 1, person: person, total: 0, transactions: []});
});
Expand Down
5 changes: 5 additions & 0 deletions src/rock/models/finances/resolver.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { flatten } from "lodash";
import moment from "moment";

import { createGlobalId } from "../../../util";
import renderStatement from "./util/statement";
Expand Down Expand Up @@ -132,6 +133,10 @@ export default {
transactionStatement: async (_, { people, start, end }, { models, person }) => {
if (!person) return ({ success: false, error: "You must be logged in" });

// default to start of current year if not passed
// eslint-disable-next-line
if (!start) start = moment().startOf("year");

const homeLookup = models.Person.getHomesFromId(person.Id).then(x => x[0]);

const transactionLookup = models.Transaction.getStatement({
Expand Down

0 comments on commit ea49d50

Please sign in to comment.