@things-factory/accounting 10.1.187 → 10.1.191
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-server/service/account/account-choice.d.ts +51 -0
- package/dist-server/service/account/account-choice.js +81 -0
- package/dist-server/service/account/account-choice.js.map +1 -0
- package/dist-server/service/account/account-query.d.ts +2 -0
- package/dist-server/service/account/account-query.js +15 -9
- package/dist-server/service/account/account-query.js.map +1 -1
- package/dist-server/service/expenditure-request/expenditure-request-mutation.js +2 -2
- package/dist-server/service/expenditure-request/expenditure-request-mutation.js.map +1 -1
- package/dist-server/service/expenditure-request/expenditure-request-query.d.ts +2 -0
- package/dist-server/service/expenditure-request/expenditure-request-query.js +18 -3
- package/dist-server/service/expenditure-request/expenditure-request-query.js.map +1 -1
- package/dist-server/service/expenditure-request/expenditure-request.js +2 -0
- package/dist-server/service/expenditure-request/expenditure-request.js.map +1 -1
- package/dist-server/service/expenditure-request/receipt-reader.d.ts +2 -2
- package/dist-server/service/expenditure-request/receipt-reader.js +2 -2
- package/dist-server/service/expenditure-request/receipt-reader.js.map +1 -1
- package/dist-server/service/index.d.ts +1 -0
- package/dist-server/service/index.js +1 -0
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Repository } from 'typeorm';
|
|
2
|
+
import { ListParam } from '@things-factory/shell';
|
|
3
|
+
import { CashFlowType } from '../cash-flow-type';
|
|
4
|
+
import { Account } from './account';
|
|
5
|
+
/** What the chart's list door searches - the chart keeper's door. */
|
|
6
|
+
export declare const ACCOUNT_SEARCHABLES: string[];
|
|
7
|
+
/** What a choice is searched, filtered and sorted by - the fields it shows. */
|
|
8
|
+
export declare const ACCOUNT_CHOICE_SEARCHABLES: string[];
|
|
9
|
+
export declare const ACCOUNT_CHOICE_FILTERABLES: string[];
|
|
10
|
+
/** A choice door is no way to read the whole chart at once. */
|
|
11
|
+
export declare const ACCOUNT_CHOICE_LIMIT = 50;
|
|
12
|
+
export declare class AccountChoice {
|
|
13
|
+
id: string;
|
|
14
|
+
code: string;
|
|
15
|
+
name: string;
|
|
16
|
+
type: CashFlowType;
|
|
17
|
+
}
|
|
18
|
+
export declare class AccountChoiceList {
|
|
19
|
+
items: AccountChoice[];
|
|
20
|
+
total: number;
|
|
21
|
+
}
|
|
22
|
+
/** What a door lets a list be read by. */
|
|
23
|
+
export interface AccountListRules {
|
|
24
|
+
searchables: string[];
|
|
25
|
+
filterables?: string[];
|
|
26
|
+
sortables?: string[];
|
|
27
|
+
defaultLimit?: number;
|
|
28
|
+
maxLimit?: number;
|
|
29
|
+
}
|
|
30
|
+
/** One page of a domain's account subjects - the list door and the choice door read through this one function. */
|
|
31
|
+
export declare function accountPage(repository: Repository<Account>, domain: {
|
|
32
|
+
id: string;
|
|
33
|
+
}, params: ListParam, rules: AccountListRules): Promise<{
|
|
34
|
+
items: Account[];
|
|
35
|
+
total: number;
|
|
36
|
+
}>;
|
|
37
|
+
/**
|
|
38
|
+
* Subjects to pick from - asked as any list is, answered only by what a choice shows: active ones, searched, filtered
|
|
39
|
+
* and sorted by the shown fields (by code when no order is asked), a capped page at a time.
|
|
40
|
+
*/
|
|
41
|
+
export declare function accountChoicesOf(repository: Repository<Account>, domain: {
|
|
42
|
+
id: string;
|
|
43
|
+
}, params: ListParam | undefined): Promise<{
|
|
44
|
+
items: {
|
|
45
|
+
id: string;
|
|
46
|
+
code: string;
|
|
47
|
+
name: string;
|
|
48
|
+
type: CashFlowType;
|
|
49
|
+
}[];
|
|
50
|
+
total: number;
|
|
51
|
+
}>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AccountChoiceList = exports.AccountChoice = exports.ACCOUNT_CHOICE_LIMIT = exports.ACCOUNT_CHOICE_FILTERABLES = exports.ACCOUNT_CHOICE_SEARCHABLES = exports.ACCOUNT_SEARCHABLES = void 0;
|
|
4
|
+
exports.accountPage = accountPage;
|
|
5
|
+
exports.accountChoicesOf = accountChoicesOf;
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
const type_graphql_1 = require("type-graphql");
|
|
8
|
+
const shell_1 = require("@things-factory/shell");
|
|
9
|
+
const cash_flow_type_1 = require("../cash-flow-type");
|
|
10
|
+
/*
|
|
11
|
+
* Choosing an account subject without reading the chart (ADR-0139, design/published-read-privilege):
|
|
12
|
+
* `accounting-published` opens a subject's code, name and direction, in its own type - nothing to follow.
|
|
13
|
+
*/
|
|
14
|
+
/** What the chart's list door searches - the chart keeper's door. */
|
|
15
|
+
exports.ACCOUNT_SEARCHABLES = ['code', 'name', 'aliases', 'description'];
|
|
16
|
+
/** What a choice is searched, filtered and sorted by - the fields it shows. */
|
|
17
|
+
exports.ACCOUNT_CHOICE_SEARCHABLES = ['code', 'name'];
|
|
18
|
+
/* `active` is the door's own filter; `type` is shown, so one may pick among income or expense subjects. */
|
|
19
|
+
exports.ACCOUNT_CHOICE_FILTERABLES = [...exports.ACCOUNT_CHOICE_SEARCHABLES, 'type', 'active'];
|
|
20
|
+
/** A choice door is no way to read the whole chart at once. */
|
|
21
|
+
exports.ACCOUNT_CHOICE_LIMIT = 50;
|
|
22
|
+
let AccountChoice = class AccountChoice {
|
|
23
|
+
};
|
|
24
|
+
exports.AccountChoice = AccountChoice;
|
|
25
|
+
tslib_1.__decorate([
|
|
26
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID),
|
|
27
|
+
tslib_1.__metadata("design:type", String)
|
|
28
|
+
], AccountChoice.prototype, "id", void 0);
|
|
29
|
+
tslib_1.__decorate([
|
|
30
|
+
(0, type_graphql_1.Field)(),
|
|
31
|
+
tslib_1.__metadata("design:type", String)
|
|
32
|
+
], AccountChoice.prototype, "code", void 0);
|
|
33
|
+
tslib_1.__decorate([
|
|
34
|
+
(0, type_graphql_1.Field)(),
|
|
35
|
+
tslib_1.__metadata("design:type", String)
|
|
36
|
+
], AccountChoice.prototype, "name", void 0);
|
|
37
|
+
tslib_1.__decorate([
|
|
38
|
+
(0, type_graphql_1.Field)(type => cash_flow_type_1.CashFlowType, { description: 'Whether money booked to it comes in or goes out' }),
|
|
39
|
+
tslib_1.__metadata("design:type", String)
|
|
40
|
+
], AccountChoice.prototype, "type", void 0);
|
|
41
|
+
exports.AccountChoice = AccountChoice = tslib_1.__decorate([
|
|
42
|
+
(0, type_graphql_1.ObjectType)({ description: 'An account subject as one picks it: its code, name and whether money booked to it comes in or goes out' })
|
|
43
|
+
], AccountChoice);
|
|
44
|
+
let AccountChoiceList = class AccountChoiceList {
|
|
45
|
+
};
|
|
46
|
+
exports.AccountChoiceList = AccountChoiceList;
|
|
47
|
+
tslib_1.__decorate([
|
|
48
|
+
(0, type_graphql_1.Field)(type => [AccountChoice]),
|
|
49
|
+
tslib_1.__metadata("design:type", Array)
|
|
50
|
+
], AccountChoiceList.prototype, "items", void 0);
|
|
51
|
+
tslib_1.__decorate([
|
|
52
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int),
|
|
53
|
+
tslib_1.__metadata("design:type", Number)
|
|
54
|
+
], AccountChoiceList.prototype, "total", void 0);
|
|
55
|
+
exports.AccountChoiceList = AccountChoiceList = tslib_1.__decorate([
|
|
56
|
+
(0, type_graphql_1.ObjectType)({ description: 'A page of account subjects to pick from' })
|
|
57
|
+
], AccountChoiceList);
|
|
58
|
+
/** One page of a domain's account subjects - the list door and the choice door read through this one function. */
|
|
59
|
+
async function accountPage(repository, domain, params, rules) {
|
|
60
|
+
const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({ domain: domain, params, repository, ...rules });
|
|
61
|
+
const [items, total] = await queryBuilder.getManyAndCount();
|
|
62
|
+
return { items, total };
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Subjects to pick from - asked as any list is, answered only by what a choice shows: active ones, searched, filtered
|
|
66
|
+
* and sorted by the shown fields (by code when no order is asked), a capped page at a time.
|
|
67
|
+
*/
|
|
68
|
+
async function accountChoicesOf(repository, domain, params) {
|
|
69
|
+
const asked = (params ?? {});
|
|
70
|
+
const filters = [...(asked.filters ?? []), { name: 'active', operator: 'eq', value: true }];
|
|
71
|
+
const sortings = asked.sortings?.length ? asked.sortings : [{ name: 'code' }];
|
|
72
|
+
const { items, total } = await accountPage(repository, domain, { ...asked, filters, sortings }, {
|
|
73
|
+
searchables: exports.ACCOUNT_CHOICE_SEARCHABLES,
|
|
74
|
+
filterables: exports.ACCOUNT_CHOICE_FILTERABLES,
|
|
75
|
+
sortables: exports.ACCOUNT_CHOICE_SEARCHABLES,
|
|
76
|
+
defaultLimit: exports.ACCOUNT_CHOICE_LIMIT,
|
|
77
|
+
maxLimit: exports.ACCOUNT_CHOICE_LIMIT
|
|
78
|
+
});
|
|
79
|
+
return { items: items.map(one => ({ id: one.id, code: one.code, name: one.name, type: one.type })), total };
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=account-choice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-choice.js","sourceRoot":"","sources":["../../../server/service/account/account-choice.ts"],"names":[],"mappings":";;;AA8CA,kCAIC;AAMD,4CAYC;;AApED,+CAAyD;AAGzD,iDAAgF;AAEhF,sDAAgD;AAGhD;;;GAGG;AAEH,qEAAqE;AACxD,QAAA,mBAAmB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,CAAC,CAAA;AAC7E,+EAA+E;AAClE,QAAA,0BAA0B,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAC1D,2GAA2G;AAC9F,QAAA,0BAA0B,GAAG,CAAC,GAAG,kCAA0B,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAA;AAC3F,+DAA+D;AAClD,QAAA,oBAAoB,GAAG,EAAE,CAAA;AAG/B,IAAM,aAAa,GAAnB,MAAM,aAAa;CAKzB,CAAA;AALY,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zC,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IAC3F,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAA;IAC7E,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,MAAM,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAe,EAAE;QAC3G,WAAW,EAAE,kCAA0B;QACvC,WAAW,EAAE,kCAA0B;QACvC,SAAS,EAAE,kCAA0B;QACrC,YAAY,EAAE,4BAAoB;QAClC,QAAQ,EAAE,4BAAoB;KAC/B,CAAC,CAAA;IACF,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAA;AAC7G,CAAC","sourcesContent":["import { Field, ID, Int, ObjectType } from 'type-graphql'\nimport { Repository } from 'typeorm'\n\nimport { getQueryBuilderFromListParams, ListParam } from '@things-factory/shell'\n\nimport { CashFlowType } from '../cash-flow-type'\nimport { Account } from './account'\n\n/*\n * Choosing an account subject without reading the chart (ADR-0139, design/published-read-privilege):\n * `accounting-published` opens a subject's code, name and direction, in its own type - nothing to follow.\n */\n\n/** What the chart's list door searches - the chart keeper's door. */\nexport const ACCOUNT_SEARCHABLES = ['code', 'name', 'aliases', 'description']\n/** What a choice is searched, filtered and sorted by - the fields it shows. */\nexport const ACCOUNT_CHOICE_SEARCHABLES = ['code', 'name']\n/* `active` is the door's own filter; `type` is shown, so one may pick among income or expense subjects. */\nexport const ACCOUNT_CHOICE_FILTERABLES = [...ACCOUNT_CHOICE_SEARCHABLES, 'type', 'active']\n/** A choice door is no way to read the whole chart at once. */\nexport const ACCOUNT_CHOICE_LIMIT = 50\n\n@ObjectType({ description: 'An account subject as one picks it: its code, name and whether money booked to it comes in or goes out' })\nexport class AccountChoice {\n @Field(type => ID) id: string\n @Field() code: string\n @Field() name: string\n @Field(type => CashFlowType, { description: 'Whether money booked to it comes in or goes out' }) type: CashFlowType\n}\n\n@ObjectType({ description: 'A page of account subjects to pick from' })\nexport class AccountChoiceList {\n @Field(type => [AccountChoice]) items: AccountChoice[]\n @Field(type => Int) total: number\n}\n\n/** What a door lets a list be read by. */\nexport interface AccountListRules {\n searchables: string[]\n filterables?: string[]\n sortables?: string[]\n defaultLimit?: number\n maxLimit?: number\n}\n\n/** One page of a domain's account subjects - the list door and the choice door read through this one function. */\nexport async function accountPage(repository: Repository<Account>, domain: { id: string }, params: ListParam, rules: AccountListRules) {\n const queryBuilder = getQueryBuilderFromListParams({ domain: domain as any, params, repository, ...rules })\n const [items, total] = await queryBuilder.getManyAndCount()\n return { items, total }\n}\n\n/**\n * Subjects to pick from - asked as any list is, answered only by what a choice shows: active ones, searched, filtered\n * and sorted by the shown fields (by code when no order is asked), a capped page at a time.\n */\nexport async function accountChoicesOf(repository: Repository<Account>, domain: { id: string }, params: ListParam | undefined) {\n const asked = (params ?? {}) as ListParam\n const filters = [...(asked.filters ?? []), { name: 'active', operator: 'eq', value: true }]\n const sortings = asked.sortings?.length ? asked.sortings : [{ name: 'code' }]\n const { items, total } = await accountPage(repository, domain, { ...asked, filters, sortings } as ListParam, {\n searchables: ACCOUNT_CHOICE_SEARCHABLES,\n filterables: ACCOUNT_CHOICE_FILTERABLES,\n sortables: ACCOUNT_CHOICE_SEARCHABLES,\n defaultLimit: ACCOUNT_CHOICE_LIMIT,\n maxLimit: ACCOUNT_CHOICE_LIMIT\n })\n return { items: items.map(one => ({ id: one.id, code: one.code, name: one.name, type: one.type })), total }\n}\n"]}
|
|
@@ -3,9 +3,11 @@ import { User } from '@things-factory/auth-base';
|
|
|
3
3
|
import { AccountingCategory } from '../accounting-category/accounting-category';
|
|
4
4
|
import { Account } from './account';
|
|
5
5
|
import { AccountList } from './account-type';
|
|
6
|
+
import { AccountChoiceList } from './account-choice';
|
|
6
7
|
export declare class AccountQuery {
|
|
7
8
|
account(id: string, context: ResolverContext): Promise<Account>;
|
|
8
9
|
accounts(params: ListParam, context: ResolverContext): Promise<AccountList>;
|
|
10
|
+
accountChoices(params: ListParam, context: ResolverContext): Promise<AccountChoiceList>;
|
|
9
11
|
category(account: Account): Promise<AccountingCategory | null>;
|
|
10
12
|
domain(account: Account): Promise<Domain>;
|
|
11
13
|
updater(account: Account): Promise<User>;
|
|
@@ -8,6 +8,7 @@ const auth_base_1 = require("@things-factory/auth-base");
|
|
|
8
8
|
const accounting_category_1 = require("../accounting-category/accounting-category");
|
|
9
9
|
const account_1 = require("./account");
|
|
10
10
|
const account_type_1 = require("./account-type");
|
|
11
|
+
const account_choice_1 = require("./account-choice");
|
|
11
12
|
let AccountQuery = class AccountQuery {
|
|
12
13
|
async account(id, context) {
|
|
13
14
|
const { domain } = context.state;
|
|
@@ -16,15 +17,11 @@ let AccountQuery = class AccountQuery {
|
|
|
16
17
|
});
|
|
17
18
|
}
|
|
18
19
|
async accounts(params, context) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
searchables: ['code', 'name', 'aliases', 'description']
|
|
25
|
-
});
|
|
26
|
-
const [items, total] = await queryBuilder.getManyAndCount();
|
|
27
|
-
return { items, total };
|
|
20
|
+
return await (0, account_choice_1.accountPage)((0, shell_1.getRepository)(account_1.Account), context.state.domain, params, { searchables: account_choice_1.ACCOUNT_SEARCHABLES });
|
|
21
|
+
}
|
|
22
|
+
/* Picking a subject without reading the chart - every seat may (ADR-0139). */
|
|
23
|
+
async accountChoices(params, context) {
|
|
24
|
+
return (await (0, account_choice_1.accountChoicesOf)((0, shell_1.getRepository)(account_1.Account), context.state.domain, params));
|
|
28
25
|
}
|
|
29
26
|
async category(account) {
|
|
30
27
|
return account.categoryId ? await (0, shell_1.getRepository)(accounting_category_1.AccountingCategory).findOneBy({ id: account.categoryId }) : null;
|
|
@@ -58,6 +55,15 @@ tslib_1.__decorate([
|
|
|
58
55
|
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
59
56
|
tslib_1.__metadata("design:returntype", Promise)
|
|
60
57
|
], AccountQuery.prototype, "accounts", null);
|
|
58
|
+
tslib_1.__decorate([
|
|
59
|
+
(0, type_graphql_1.Directive)('@privilege(category: "accounting-published", privilege: "query", domainOwnerGranted: true)'),
|
|
60
|
+
(0, type_graphql_1.Query)(returns => account_choice_1.AccountChoiceList, { description: 'Account subjects to pick from - code, name and direction; a capped page at a time' }),
|
|
61
|
+
tslib_1.__param(0, (0, type_graphql_1.Args)()),
|
|
62
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
63
|
+
tslib_1.__metadata("design:type", Function),
|
|
64
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
65
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
66
|
+
], AccountQuery.prototype, "accountChoices", null);
|
|
61
67
|
tslib_1.__decorate([
|
|
62
68
|
(0, type_graphql_1.FieldResolver)(type => accounting_category_1.AccountingCategory, { nullable: true }),
|
|
63
69
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-query.js","sourceRoot":"","sources":["../../../server/service/account/account-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAE9F,
|
|
1
|
+
{"version":3,"file":"account-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,mBAAA,IAAA,mBAAI,GAAE,CAAA;IAAqB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAjB,iBAAS;;kDAE7C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,wCAAkB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC9C,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;4CAEtC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;0CAEpC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;2CAErC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;2CAErC;uBA1CU,YAAY;IADxB,IAAA,uBAAQ,EAAC,iBAAO,CAAC;GACL,YAAY,CA2CxB","sourcesContent":["import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'\n\nimport { Domain, getRepository, ListParam } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { AccountingCategory } from '../accounting-category/accounting-category'\nimport { Account } from './account'\nimport { AccountList } from './account-type'\nimport { AccountChoiceList, accountChoicesOf, accountPage, ACCOUNT_SEARCHABLES } from './account-choice'\n\n@Resolver(Account)\nexport class AccountQuery {\n @Directive('@privilege(category: \"accounting-master\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => Account!, { nullable: true, description: 'To fetch a Account' })\n async account(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Account> {\n const { domain } = context.state\n\n return await getRepository(Account).findOne({\n where: { domain: { id: domain.id }, id }\n })\n }\n\n @Directive('@privilege(category: \"accounting-master\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => AccountList, { description: 'To fetch multiple Accounts' })\n async accounts(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<AccountList> {\n return await accountPage(getRepository(Account), context.state.domain, params, { searchables: ACCOUNT_SEARCHABLES })\n }\n\n /* Picking a subject without reading the chart - every seat may (ADR-0139). */\n @Directive('@privilege(category: \"accounting-published\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => AccountChoiceList, { description: 'Account subjects to pick from - code, name and direction; a capped page at a time' })\n async accountChoices(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<AccountChoiceList> {\n return (await accountChoicesOf(getRepository(Account), context.state.domain, params)) as any\n }\n\n @FieldResolver(type => AccountingCategory, { nullable: true })\n async category(@Root() account: Account): Promise<AccountingCategory | null> {\n return account.categoryId ? await getRepository(AccountingCategory).findOneBy({ id: account.categoryId }) : null\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() account: Account): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: account.domainId })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() account: Account): Promise<User> {\n return await getRepository(User).findOneBy({ id: account.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() account: Account): Promise<User> {\n return await getRepository(User).findOneBy({ id: account.creatorId })\n }\n}\n"]}
|
|
@@ -114,7 +114,7 @@ tslib_1.__decorate([
|
|
|
114
114
|
], ExpenditureRequestMutation.prototype, "deleteExpenditureRequest", null);
|
|
115
115
|
tslib_1.__decorate([
|
|
116
116
|
(0, type_graphql_1.Directive)('@transaction'),
|
|
117
|
-
(0, type_graphql_1.Directive)('@privilege(category: "
|
|
117
|
+
(0, type_graphql_1.Directive)('@privilege(category: "expenditure", privilege: "mutation", domainOwnerGranted: true)'),
|
|
118
118
|
(0, type_graphql_1.Mutation)(returns => [expenditure_request_1.ExpenditureRequest], { description: 'Record that approved expenditure requests were paid' }),
|
|
119
119
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
|
|
120
120
|
tslib_1.__param(1, (0, type_graphql_1.Arg)('payment', type => expenditure_request_type_1.ExpenditurePaymentInput)),
|
|
@@ -125,7 +125,7 @@ tslib_1.__decorate([
|
|
|
125
125
|
], ExpenditureRequestMutation.prototype, "payExpenditureRequests", null);
|
|
126
126
|
tslib_1.__decorate([
|
|
127
127
|
(0, type_graphql_1.Directive)('@transaction'),
|
|
128
|
-
(0, type_graphql_1.Directive)('@privilege(category: "
|
|
128
|
+
(0, type_graphql_1.Directive)('@privilege(category: "expenditure", privilege: "mutation", domainOwnerGranted: true)'),
|
|
129
129
|
(0, type_graphql_1.Mutation)(returns => expenditure_request_1.ExpenditureRequest, { description: 'Put a withdrawal already in the books on an approved expenditure request' }),
|
|
130
130
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
131
131
|
tslib_1.__param(1, (0, type_graphql_1.Arg)('transactionId')),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expenditure-request-mutation.js","sourceRoot":"","sources":["../../../server/service/expenditure-request/expenditure-request-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAA4F;AAG5F,+FAA2D;AAE3D,yDAA2D;AAC3D,iDAAqD;AAErD,+DAA0D;AAC1D,yEAAmE;AACnE,+EAA6J;AAC7J,yEAA8I;AAIvI,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IACrC,0HAA0H;IAIpH,AAAN,KAAK,CAAC,sBAAsB,CACuB,OAAgC,EACR,KAAoC,EACtG,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1E,MAAM,WAAW,GAAG,MAAM,IAAA,2BAAe,EAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,MA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AC,eAAe,CAAC,CAAA;IACpB,mBAAA,IAAA,kBAAG,EAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,oBAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;IAChD,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;+EAIP;qCArFU,0BAA0B;IAFtC,IAAA,4BAAa,EAAC,qBAAa,CAAC;IAC5B,IAAA,uBAAQ,EAAC,wCAAkB,CAAC;GAChB,0BAA0B,CAsFtC","sourcesContent":["import { Arg, Ctx, Directive, Float, Mutation, Resolver, UseMiddleware } from 'type-graphql'\n\nimport type { FileUpload } from 'graphql-upload/GraphQLUpload.js'\nimport GraphQLUpload from 'graphql-upload/GraphQLUpload.js'\n\nimport { checkPermission } from '@things-factory/auth-base'\nimport { SpeakRefusals } from '@things-factory/shell'\n\nimport { ExpenditureRequest } from './expenditure-request'\nimport { ExpenditureRequestItem } from './expenditure-request-item'\nimport { addLine, deleteRequest, payRequests, payWithLine, replaceReceipt, saveRequest, submitRequest, withdrawRequest } from './expenditure-request-service'\nimport { ExpenditurePaymentInput, ExpenditureRequestInput, ExpenditureRequestItemPatch, NewExpenditureLine } from './expenditure-request-type'\n\n@UseMiddleware(SpeakRefusals)\n@Resolver(ExpenditureRequest)\nexport class ExpenditureRequestMutation {\n /** Write a request and its lines. A new request is the caller's; an existing one only its requester's, while editable. */\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting-self\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => ExpenditureRequest, { description: 'Save an expenditure request and its lines' })\n async saveExpenditureRequest(\n @Arg('request', type => ExpenditureRequestInput) request: ExpenditureRequestInput,\n @Arg('items', type => [ExpenditureRequestItemPatch], { nullable: true }) items: ExpenditureRequestItemPatch[],\n @Ctx() context: ResolverContext\n ): Promise<ExpenditureRequest> {\n const { domain, user, tx, unsafeIP, prohibitedPrivileges } = context.state\n const taxInvoices = await checkPermission({ category: 'tax-invoice', privilege: 'query', owner: false }, user, domain, unsafeIP, prohibitedPrivileges)\n return await saveRequest(tx, domain, user, request, items ?? [], { taxInvoices })\n }\n\n /** One line from the phone - it joins this month's editable reimbursement, or starts one. */\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting-self\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => ExpenditureRequest, { description: \"Add one expense line to the caller's reimbursement of that month\" })\n async addExpenditureLine(@Arg('line', type => NewExpenditureLine) line: NewExpenditureLine, @Ctx() context: ResolverContext): Promise<ExpenditureRequest> {\n const { domain, user, tx } = context.state\n return await addLine(tx, domain, user, line, context)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting-self\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => ExpenditureRequestItem, { description: 'Put (or replace) the receipt of a line' })\n async attachExpenditureReceipt(\n @Arg('itemId') itemId: string,\n @Arg('file', type => GraphQLUpload) file: FileUpload,\n @Ctx() context: ResolverContext\n ): Promise<ExpenditureRequestItem> {\n const { domain, user, tx } = context.state\n return await replaceReceipt(tx, domain, user, itemId, file, context)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting-self\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => ExpenditureRequest, { description: 'Put an expenditure request up for approval (상신)' })\n async submitExpenditureRequest(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<ExpenditureRequest> {\n const { domain, user, tx } = context.state\n return await submitRequest(tx, domain, user, id, context)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting-self\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => ExpenditureRequest, { description: 'Take a submitted request back from its approvers (회수)' })\n async withdrawExpenditureRequest(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<ExpenditureRequest> {\n const { domain, user, tx } = context.state\n return await withdrawRequest(tx, domain, user, id, context)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting-self\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'Delete an editable expenditure request of the caller' })\n async deleteExpenditureRequest(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, user, tx } = context.state\n return await deleteRequest(tx, domain, user, id)\n }\n\n /** Finance paid approved requests at the bank; each becomes a withdrawal that the next statement import matches. */\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => [ExpenditureRequest], { description: 'Record that approved expenditure requests were paid' })\n async payExpenditureRequests(\n @Arg('ids', type => [String]) ids: string[],\n @Arg('payment', type => ExpenditurePaymentInput) payment: ExpenditurePaymentInput,\n @Ctx() context: ResolverContext\n ): Promise<ExpenditureRequest[]> {\n const { domain, user, tx } = context.state\n return await payRequests(tx, domain, user, ids, payment)\n }\n\n /** Pay a request with a withdrawal already in the books - a bank statement brought it in first. */\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => ExpenditureRequest, { description: 'Put a withdrawal already in the books on an approved expenditure request' })\n async payExpenditureRequestWithLine(\n @Arg('id') id: string,\n @Arg('transactionId') transactionId: string,\n @Arg('amount', type => Float, { nullable: true }) amount: number,\n @Ctx() context: ResolverContext\n ): Promise<ExpenditureRequest> {\n const { domain, user, tx } = context.state\n return await payWithLine(tx, domain, user, id, transactionId, amount)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"expenditure-request-mutation.js","sourceRoot":"","sources":["../../../server/service/expenditure-request/expenditure-request-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAA4F;AAG5F,+FAA2D;AAE3D,yDAA2D;AAC3D,iDAAqD;AAErD,+DAA0D;AAC1D,yEAAmE;AACnE,+EAA6J;AAC7J,yEAA8I;AAIvI,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IACrC,0HAA0H;IAIpH,AAAN,KAAK,CAAC,sBAAsB,CACuB,OAAgC,EAC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oD,kDAAuB;;wEAKlF;AAMK;IAHL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,sFAAsF,CAAC;IACjG,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,wCAAkB,EAAE,EAAE,WAAW,EAAE,0EAA0E,EAAE,CAAC;IAElI,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IACT,mBAAA,IAAA,kBAAG,EAAC,eAAe,CAAC,CAAA;IACpB,mBAAA,IAAA,kBAAG,EAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,oBAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;IAChD,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;+EAIP;qCArFU,0BAA0B;IAFtC,IAAA,4BAAa,EAAC,qBAAa,CAAC;IAC5B,IAAA,uBAAQ,EAAC,wCAAkB,CAAC;GAChB,0BAA0B,CAsFtC","sourcesContent":["import { Arg, Ctx, Directive, Float, Mutation, Resolver, UseMiddleware } from 'type-graphql'\n\nimport type { FileUpload } from 'graphql-upload/GraphQLUpload.js'\nimport GraphQLUpload from 'graphql-upload/GraphQLUpload.js'\n\nimport { checkPermission } from '@things-factory/auth-base'\nimport { SpeakRefusals } from '@things-factory/shell'\n\nimport { ExpenditureRequest } from './expenditure-request'\nimport { ExpenditureRequestItem } from './expenditure-request-item'\nimport { addLine, deleteRequest, payRequests, payWithLine, replaceReceipt, saveRequest, submitRequest, withdrawRequest } from './expenditure-request-service'\nimport { ExpenditurePaymentInput, ExpenditureRequestInput, ExpenditureRequestItemPatch, NewExpenditureLine } from './expenditure-request-type'\n\n@UseMiddleware(SpeakRefusals)\n@Resolver(ExpenditureRequest)\nexport class ExpenditureRequestMutation {\n /** Write a request and its lines. A new request is the caller's; an existing one only its requester's, while editable. */\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting-self\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => ExpenditureRequest, { description: 'Save an expenditure request and its lines' })\n async saveExpenditureRequest(\n @Arg('request', type => ExpenditureRequestInput) request: ExpenditureRequestInput,\n @Arg('items', type => [ExpenditureRequestItemPatch], { nullable: true }) items: ExpenditureRequestItemPatch[],\n @Ctx() context: ResolverContext\n ): Promise<ExpenditureRequest> {\n const { domain, user, tx, unsafeIP, prohibitedPrivileges } = context.state\n const taxInvoices = await checkPermission({ category: 'tax-invoice', privilege: 'query', owner: false }, user, domain, unsafeIP, prohibitedPrivileges)\n return await saveRequest(tx, domain, user, request, items ?? [], { taxInvoices })\n }\n\n /** One line from the phone - it joins this month's editable reimbursement, or starts one. */\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting-self\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => ExpenditureRequest, { description: \"Add one expense line to the caller's reimbursement of that month\" })\n async addExpenditureLine(@Arg('line', type => NewExpenditureLine) line: NewExpenditureLine, @Ctx() context: ResolverContext): Promise<ExpenditureRequest> {\n const { domain, user, tx } = context.state\n return await addLine(tx, domain, user, line, context)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting-self\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => ExpenditureRequestItem, { description: 'Put (or replace) the receipt of a line' })\n async attachExpenditureReceipt(\n @Arg('itemId') itemId: string,\n @Arg('file', type => GraphQLUpload) file: FileUpload,\n @Ctx() context: ResolverContext\n ): Promise<ExpenditureRequestItem> {\n const { domain, user, tx } = context.state\n return await replaceReceipt(tx, domain, user, itemId, file, context)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting-self\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => ExpenditureRequest, { description: 'Put an expenditure request up for approval (상신)' })\n async submitExpenditureRequest(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<ExpenditureRequest> {\n const { domain, user, tx } = context.state\n return await submitRequest(tx, domain, user, id, context)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting-self\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => ExpenditureRequest, { description: 'Take a submitted request back from its approvers (회수)' })\n async withdrawExpenditureRequest(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<ExpenditureRequest> {\n const { domain, user, tx } = context.state\n return await withdrawRequest(tx, domain, user, id, context)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting-self\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'Delete an editable expenditure request of the caller' })\n async deleteExpenditureRequest(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, user, tx } = context.state\n return await deleteRequest(tx, domain, user, id)\n }\n\n /** Finance paid approved requests at the bank; each becomes a withdrawal that the next statement import matches. */\n @Directive('@transaction')\n @Directive('@privilege(category: \"expenditure\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => [ExpenditureRequest], { description: 'Record that approved expenditure requests were paid' })\n async payExpenditureRequests(\n @Arg('ids', type => [String]) ids: string[],\n @Arg('payment', type => ExpenditurePaymentInput) payment: ExpenditurePaymentInput,\n @Ctx() context: ResolverContext\n ): Promise<ExpenditureRequest[]> {\n const { domain, user, tx } = context.state\n return await payRequests(tx, domain, user, ids, payment)\n }\n\n /** Pay a request with a withdrawal already in the books - a bank statement brought it in first. */\n @Directive('@transaction')\n @Directive('@privilege(category: \"expenditure\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => ExpenditureRequest, { description: 'Put a withdrawal already in the books on an approved expenditure request' })\n async payExpenditureRequestWithLine(\n @Arg('id') id: string,\n @Arg('transactionId') transactionId: string,\n @Arg('amount', type => Float, { nullable: true }) amount: number,\n @Ctx() context: ResolverContext\n ): Promise<ExpenditureRequest> {\n const { domain, user, tx } = context.state\n return await payWithLine(tx, domain, user, id, transactionId, amount)\n }\n}\n"]}
|
|
@@ -8,6 +8,8 @@ import { ExpenditureRequest } from './expenditure-request';
|
|
|
8
8
|
import { ExpenditureRequestItem } from './expenditure-request-item';
|
|
9
9
|
import { ExpenditurePayment, ExpenditureQueue, ExpenditureRequestList, ExpenditureSummary } from './expenditure-request-type';
|
|
10
10
|
export declare class ExpenditureRequestQuery {
|
|
11
|
+
/** The last four digits of the account paid into - what the requester and the approvers see (ADR-0139). */
|
|
12
|
+
payeeAccountTail(request: ExpenditureRequest): string | undefined;
|
|
11
13
|
/** The caller's own requests - what an employee sees. */
|
|
12
14
|
myExpenditureRequests(params: ListParam, context: ResolverContext): Promise<ExpenditureRequestList>;
|
|
13
15
|
/** One of the caller's own requests, with its lines. */
|
|
@@ -49,6 +49,10 @@ async function summaryOf(domain, year, month, requesterId) {
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
let ExpenditureRequestQuery = class ExpenditureRequestQuery {
|
|
52
|
+
/** The last four digits of the account paid into - what the requester and the approvers see (ADR-0139). */
|
|
53
|
+
payeeAccountTail(request) {
|
|
54
|
+
return (0, biz_base_1.accountTailOf)(request.payeeAccountNumber);
|
|
55
|
+
}
|
|
52
56
|
/** The caller's own requests - what an employee sees. */
|
|
53
57
|
async myExpenditureRequests(params, context) {
|
|
54
58
|
const { domain, user } = context.state;
|
|
@@ -64,6 +68,10 @@ let ExpenditureRequestQuery = class ExpenditureRequestQuery {
|
|
|
64
68
|
return await (0, shell_1.getRepository)(expenditure_request_1.ExpenditureRequest).findOne({ where: { id, domain: { id: domain.id }, requester: { id: user.id } } });
|
|
65
69
|
}
|
|
66
70
|
/** Every request of the domain - what finance sees. */
|
|
71
|
+
/*
|
|
72
|
+
* Every request, one by one - who spent what, the receipts, the queue to pay - is the paying seat's: `expenditure`
|
|
73
|
+
* (the user, 2026-10-18). The month's summary stays `accounting`, which the executives read.
|
|
74
|
+
*/
|
|
67
75
|
async expenditureRequests(params, context) {
|
|
68
76
|
const { domain } = context.state;
|
|
69
77
|
const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({ domain, params, repository: (0, shell_1.getRepository)(expenditure_request_1.ExpenditureRequest), searchables: ['title', 'notes'], alias: 'request' });
|
|
@@ -146,6 +154,13 @@ let ExpenditureRequestQuery = class ExpenditureRequestQuery {
|
|
|
146
154
|
}
|
|
147
155
|
};
|
|
148
156
|
exports.ExpenditureRequestQuery = ExpenditureRequestQuery;
|
|
157
|
+
tslib_1.__decorate([
|
|
158
|
+
(0, type_graphql_1.FieldResolver)(type => String, { nullable: true, description: "The last four digits of the account paid into" }),
|
|
159
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
160
|
+
tslib_1.__metadata("design:type", Function),
|
|
161
|
+
tslib_1.__metadata("design:paramtypes", [expenditure_request_1.ExpenditureRequest]),
|
|
162
|
+
tslib_1.__metadata("design:returntype", String)
|
|
163
|
+
], ExpenditureRequestQuery.prototype, "payeeAccountTail", null);
|
|
149
164
|
tslib_1.__decorate([
|
|
150
165
|
(0, type_graphql_1.Directive)('@privilege(category: "accounting-self", privilege: "query", domainOwnerGranted: true)'),
|
|
151
166
|
(0, type_graphql_1.Query)(returns => expenditure_request_type_1.ExpenditureRequestList, { description: "The caller's own expenditure requests" }),
|
|
@@ -165,7 +180,7 @@ tslib_1.__decorate([
|
|
|
165
180
|
tslib_1.__metadata("design:returntype", Promise)
|
|
166
181
|
], ExpenditureRequestQuery.prototype, "myExpenditureRequest", null);
|
|
167
182
|
tslib_1.__decorate([
|
|
168
|
-
(0, type_graphql_1.Directive)('@privilege(category: "
|
|
183
|
+
(0, type_graphql_1.Directive)('@privilege(category: "expenditure", privilege: "query", domainOwnerGranted: true)'),
|
|
169
184
|
(0, type_graphql_1.Query)(returns => expenditure_request_type_1.ExpenditureRequestList, { description: 'Every expenditure request of the domain' }),
|
|
170
185
|
tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
|
|
171
186
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
@@ -174,7 +189,7 @@ tslib_1.__decorate([
|
|
|
174
189
|
tslib_1.__metadata("design:returntype", Promise)
|
|
175
190
|
], ExpenditureRequestQuery.prototype, "expenditureRequests", null);
|
|
176
191
|
tslib_1.__decorate([
|
|
177
|
-
(0, type_graphql_1.Directive)('@privilege(category: "
|
|
192
|
+
(0, type_graphql_1.Directive)('@privilege(category: "expenditure", privilege: "query", domainOwnerGranted: true)'),
|
|
178
193
|
(0, type_graphql_1.Query)(returns => expenditure_request_1.ExpenditureRequest, { nullable: true, description: 'One expenditure request of the domain' }),
|
|
179
194
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
180
195
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
@@ -183,7 +198,7 @@ tslib_1.__decorate([
|
|
|
183
198
|
tslib_1.__metadata("design:returntype", Promise)
|
|
184
199
|
], ExpenditureRequestQuery.prototype, "expenditureRequest", null);
|
|
185
200
|
tslib_1.__decorate([
|
|
186
|
-
(0, type_graphql_1.Directive)('@privilege(category: "
|
|
201
|
+
(0, type_graphql_1.Directive)('@privilege(category: "expenditure", privilege: "query", domainOwnerGranted: true)'),
|
|
187
202
|
(0, type_graphql_1.Query)(returns => expenditure_request_type_1.ExpenditureQueue, { description: 'Approved requests still to pay, and paid ones not yet matched to the bank' }),
|
|
188
203
|
tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
|
|
189
204
|
tslib_1.__metadata("design:type", Function),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expenditure-request-query.js","sourceRoot":"","sources":["../../../server/service/expenditure-request/expenditure-request-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAkH;AAClH,qCAA8B;AAE9B,iDAAsH;AACtH,yDAAgD;AAChD,qEAA4D;AAC5D,uDAAgF;AAChF,+DAAyD;AACzD,6DAAwD;AAExD,gDAA4C;AAC5C,+DAAqG;AACrG,yEAAmE;AACnE,2EAAsF;AACtF,2EAA8F;AAC9F,+EAA6F;AAC7F,yEAAkJ;AAElJ,MAAM,IAAI,GAAG,KAAK,EAAK,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CAAA;;6CAAO,iDAAsB;;0DAEjD;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,wBAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACpC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAO,iDAAsB;;6DAEpD;AAIK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAChC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAO,iDAAsB;;6DAGpD;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAO,iDAAsB;;yDAEhD;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAO,iDAAsB;;0DAEjD;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAO,iDAAsB;;0DAEjD;sCApCU,2BAA2B;IADvC,IAAA,uBAAQ,EAAC,iDAAsB,CAAC;GACpB,2BAA2B,CAqCvC","sourcesContent":["import { Arg, Args, Ctx, Directive, FieldResolver, Int, Query, Resolver, Root, UseMiddleware } from 'type-graphql'\nimport { Like } from 'typeorm'\n\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam, SpeakRefusals } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { Attachment } from '@things-factory/attachment-base'\nimport { Counterparty, CounterpartyBankAccount } from '@things-factory/biz-base'\nimport { Department } from '@things-factory/organization'\nimport { TaxInvoice } from '@things-factory/tax-invoice'\n\nimport { Account } from '../account/account'\nimport { ExpenditureKind, ExpenditureRequest, ExpenditureRequestStatus } from './expenditure-request'\nimport { ExpenditureRequestItem } from './expenditure-request-item'\nimport { paymentStatesOf, ExpenditurePaymentState } from './expenditure-payment-state'\nimport { monthlySummary, statusCounts, type RequestStatus } from './expenditure-request-rules'\nimport { approvedWithStates, driftOf, RECEIPT_REF_TYPE } from './expenditure-request-service'\nimport { ExpenditurePayment, ExpenditureQueue, ExpenditureQueueRow, ExpenditureRequestList, ExpenditureSummary } from './expenditure-request-type'\n\nconst byId = async <T>(entity: new () => T, id: string | null | undefined, withDeleted = false): Promise<T | null> =>\n id ? ((await getRepository(entity).findOne({ where: { id } as any, withDeleted })) as T | null) : null\n\nasync function summaryOf(domain: { id: string }, year: number, month: number | undefined, requesterId?: string): Promise<ExpenditureSummary> {\n const period = month ? `${year}-${String(month).padStart(2, '0')}` : `${year}-%`\n const requests = await getRepository(ExpenditureRequest).find({\n where: {\n domain: { id: domain.id },\n kind: ExpenditureKind.REIMBURSEMENT,\n month: month ? period : Like(period),\n ...(requesterId ? { requester: { id: requesterId } } : {})\n } as any,\n relations: ['requester', 'items', 'items.account']\n })\n const shaped = requests.map(one => ({\n month: one.month,\n requesterId: one.requesterId ?? one.requester?.id,\n requesterName: one.requester?.name ?? null,\n status: one.status as RequestStatus,\n /* Summed by 계정과목; a line not yet filed counts under the category written on it. */\n items: (one.items ?? []).filter(item => !item.deletedAt).map(item => ({ ...item, category: item.account?.name ?? item.category }))\n }))\n\n const rows = monthlySummary(shaped)\n const approved = requests.filter(one => one.status === ExpenditureRequestStatus.APPROVED)\n approved.forEach(one => (one.items = (one.items ?? []).filter(item => !item.deletedAt)))\n const states = await paymentStatesOf(getRepository(ExpenditureRequest).manager, domain, approved as any)\n\n return {\n rows,\n statuses: Object.entries(statusCounts(shaped)).map(([status, count]) => ({ status, count })),\n approvedTotal: rows.reduce((sum, one) => sum + one.total, 0),\n unpaid: [...states.values()].reduce((sum, one) => sum + one.outstanding, 0)\n }\n}\n\n@UseMiddleware(SpeakRefusals)\n@Resolver(ExpenditureRequest)\nexport class ExpenditureRequestQuery {\n /** The caller's own requests - what an employee sees. */\n @Directive('@privilege(category: \"accounting-self\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => ExpenditureRequestList, { description: \"The caller's own expenditure requests\" })\n async myExpenditureRequests(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<ExpenditureRequestList> {\n const { domain, user } = context.state\n const queryBuilder = getQueryBuilderFromListParams({ domain, params, repository: getRepository(ExpenditureRequest), searchables: ['title', 'notes'], alias: 'request' })\n queryBuilder.andWhere('request.requester = :requester', { requester: user.id })\n queryBuilder.addOrderBy('request.createdAt', 'DESC')\n const [items, total] = await queryBuilder.getManyAndCount()\n return { items, total }\n }\n\n /** One of the caller's own requests, with its lines. */\n @Directive('@privilege(category: \"accounting-self\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => ExpenditureRequest, { nullable: true, description: \"One of the caller's own expenditure requests\" })\n async myExpenditureRequest(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<ExpenditureRequest | null> {\n const { domain, user } = context.state\n return await getRepository(ExpenditureRequest).findOne({ where: { id, domain: { id: domain.id }, requester: { id: user.id } } as any })\n }\n\n /** Every request of the domain - what finance sees. */\n @Directive('@privilege(category: \"accounting\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => ExpenditureRequestList, { description: 'Every expenditure request of the domain' })\n async expenditureRequests(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<ExpenditureRequestList> {\n const { domain } = context.state\n const queryBuilder = getQueryBuilderFromListParams({ domain, params, repository: getRepository(ExpenditureRequest), searchables: ['title', 'notes'], alias: 'request' })\n queryBuilder.addOrderBy('request.createdAt', 'DESC')\n const [items, total] = await queryBuilder.getManyAndCount()\n return { items, total }\n }\n\n @Directive('@privilege(category: \"accounting\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => ExpenditureRequest, { nullable: true, description: 'One expenditure request of the domain' })\n async expenditureRequest(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<ExpenditureRequest | null> {\n return await getRepository(ExpenditureRequest).findOne({ where: { id, domain: { id: context.state.domain.id } } as any })\n }\n\n /**\n * The payment queue (지급 대기) - approved requests still to pay, by the day they are to be paid, and the paid ones\n * whose bank line no statement has matched yet.\n */\n @Directive('@privilege(category: \"accounting\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => ExpenditureQueue, { description: 'Approved requests still to pay, and paid ones not yet matched to the bank' })\n async expenditureQueue(@Ctx() context: ResolverContext): Promise<ExpenditureQueue> {\n const { domain } = context.state\n const manager = getRepository(ExpenditureRequest).manager\n const { requests, states } = await approvedWithStates(manager, domain)\n\n const rows: ExpenditureQueueRow[] = []\n for (const request of requests) {\n const payment = states.get(request.id)!\n if (payment.state === ExpenditurePaymentState.NOTHING_TO_PAY) continue\n rows.push({\n request,\n payment,\n payeeName: (request.kind === ExpenditureKind.VENDOR ? request.counterparty?.name : request.requester?.name) ?? undefined,\n payeeAccountDrift: payment.outstanding > 0 ? await driftOf(manager, request) : undefined\n })\n }\n const due = (row: ExpenditureQueueRow) => row.request.dueDate ?? '9999-12-31'\n const waiting = rows\n .filter(row => row.payment.outstanding > 0)\n .sort((a, b) => due(a).localeCompare(due(b)) || String(a.request.decidedAt ?? '').localeCompare(String(b.request.decidedAt ?? '')))\n const unreconciled = rows.filter(row => row.payment.outstanding <= 0 && !row.payment.reconciled)\n return { waiting, unreconciled }\n }\n\n @Directive('@privilege(category: \"accounting\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => ExpenditureSummary, { description: 'Approved reimbursements per month, requester and category, with requests per status' })\n async expenditureSummary(\n @Arg('year', type => Int) year: number,\n @Arg('month', type => Int, { nullable: true }) month: number,\n @Ctx() context: ResolverContext\n ): Promise<ExpenditureSummary> {\n return await summaryOf(context.state.domain, year, month || undefined)\n }\n\n @Directive('@privilege(category: \"accounting-self\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => ExpenditureSummary, { description: \"The caller's own monthly summary of reimbursements\" })\n async myExpenditureSummary(\n @Arg('year', type => Int) year: number,\n @Arg('month', type => Int, { nullable: true }) month: number,\n @Ctx() context: ResolverContext\n ): Promise<ExpenditureSummary> {\n return await summaryOf(context.state.domain, year, month || undefined, context.state.user.id)\n }\n\n /** How far it is paid - read from its payments (ADR-0135 §2-4). */\n @FieldResolver(type => ExpenditurePayment, { nullable: true })\n async payment(@Root() request: ExpenditureRequest): Promise<ExpenditurePayment | null> {\n if (request.status !== ExpenditureRequestStatus.APPROVED) return null\n const items = await getRepository(ExpenditureRequestItem).find({ where: { request: { id: request.id } } as any })\n const states = await paymentStatesOf(getRepository(ExpenditureRequest).manager, { id: request.domainId! }, [{ id: request.id, items }])\n return states.get(request.id) ?? null\n }\n\n @FieldResolver(type => [ExpenditureRequestItem])\n async items(@Root() request: ExpenditureRequest): Promise<ExpenditureRequestItem[]> {\n if (request.items) return request.items.filter(item => !item.deletedAt)\n return await getRepository(ExpenditureRequestItem).find({ where: { request: { id: request.id } } as any, order: { spentDate: 'ASC', createdAt: 'ASC' } as any })\n }\n\n @FieldResolver(type => User, { nullable: true })\n async requester(@Root() request: ExpenditureRequest): Promise<User | null> {\n return request.requester ?? (await byId(User, request.requesterId))\n }\n\n @FieldResolver(type => Department, { nullable: true })\n async department(@Root() request: ExpenditureRequest): Promise<Department | null> {\n return request.department ?? (await byId(Department, request.departmentId))\n }\n\n @FieldResolver(type => Counterparty, { nullable: true })\n async counterparty(@Root() request: ExpenditureRequest): Promise<Counterparty | null> {\n return request.counterparty ?? (await byId(Counterparty, request.counterpartyId, true))\n }\n\n @FieldResolver(type => CounterpartyBankAccount, { nullable: true })\n async payeeAccount(@Root() request: ExpenditureRequest): Promise<CounterpartyBankAccount | null> {\n return request.payeeAccount ?? (await byId(CounterpartyBankAccount, request.payeeAccountId, true))\n }\n\n @FieldResolver(type => User, { nullable: true })\n async decidedBy(@Root() request: ExpenditureRequest): Promise<User | null> {\n return request.decidedBy ?? (await byId(User, request.decidedById))\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() request: ExpenditureRequest): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: request.domainId })\n }\n\n @FieldResolver(type => User, { nullable: true })\n async creator(@Root() request: ExpenditureRequest): Promise<User | null> {\n return await byId(User, request.creatorId)\n }\n\n @FieldResolver(type => User, { nullable: true })\n async updater(@Root() request: ExpenditureRequest): Promise<User | null> {\n return await byId(User, request.updaterId)\n }\n}\n\n@Resolver(ExpenditureRequestItem)\nexport class ExpenditureRequestItemQuery {\n @FieldResolver(type => ExpenditureRequest, { nullable: true })\n async request(@Root() item: ExpenditureRequestItem): Promise<ExpenditureRequest | null> {\n return item.request ?? (await byId(ExpenditureRequest, item.requestId))\n }\n\n @FieldResolver(type => Account, { nullable: true })\n async account(@Root() item: ExpenditureRequestItem): Promise<Account | null> {\n return item.account ?? (await byId(Account, item.accountId))\n }\n\n @FieldResolver(type => TaxInvoice, { nullable: true })\n async taxInvoice(@Root() item: ExpenditureRequestItem): Promise<TaxInvoice | null> {\n return item.taxInvoice ?? (await byId(TaxInvoice, item.taxInvoiceId, true))\n }\n\n /** Where the receipt is, or null - so an approver can see what was spent. */\n @FieldResolver(type => String, { nullable: true })\n async receiptUrl(@Root() item: ExpenditureRequestItem): Promise<string | null> {\n const attachment = await getRepository(Attachment).findOne({ where: { refType: RECEIPT_REF_TYPE, refBy: item.id }, order: { createdAt: 'DESC' } as any })\n return attachment?.fullpath ?? null\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() item: ExpenditureRequestItem): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: item.domainId })\n }\n\n @FieldResolver(type => User, { nullable: true })\n async creator(@Root() item: ExpenditureRequestItem): Promise<User | null> {\n return await byId(User, item.creatorId)\n }\n\n @FieldResolver(type => User, { nullable: true })\n async updater(@Root() item: ExpenditureRequestItem): Promise<User | null> {\n return await byId(User, item.updaterId)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"expenditure-request-query.js","sourceRoot":"","sources":["../../../server/service/expenditure-request/expenditure-request-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAkH;AAClH,qCAA8B;AAE9B,iDAAsH;AACtH,yDAAgD;AAChD,qEAA4D;AAC5D,uDAA+F;AAC/F,+DAAyD;AACzD,6DAAwD;AAExD,gDAA4C;AAC5C,+DAAqG;AACrG,yEAAmE;AACnE,2EAAsF;AACtF,2EAA8F;AAC9F,+EAA6F;AAC7F,yEAAkJ;AAElJ,MAAM,IAAI,GAAG,KAAK,EAAK,MAAmB,EAAE,EAA6B,EAAE,WAAW,GAAG,KAAK,EAAqB,EAAE,CACnH,EAAE,CAAC,CAAC,CAAE,CAAC,MAAM,IAAA,qBAAa,EAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAS,EAAE,WAAW,EAAE,CAAC,CAAc,CAAC,CAAC,CAAC,IAAI,CAAA;AAExG,KAAK,UAAU,SAAS,CAAC,MAAsB,EAAE,IAAY,EAAE,KAAyB,EAAE,WAAoB;IAC5G,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,CAAA;IAChF,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAa,EAAC,wCAAkB,CAAC,CAAC,IAAI,CAAC;QAC5D,KAAK,EAAE;YACL,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE;YACzB,IAAI,EAAE,qCAAe,CAAC,aAAa;YACnC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAA,cAAI,EAAC,MAAM,CAAC;YACpC,GAAG,CAAC,WAAW,CAAC,CAAC,CA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L,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAO,iDAAsB;;0DAEjD;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAO,iDAAsB;;0DAEjD;sCApCU,2BAA2B;IADvC,IAAA,uBAAQ,EAAC,iDAAsB,CAAC;GACpB,2BAA2B,CAqCvC","sourcesContent":["import { Arg, Args, Ctx, Directive, FieldResolver, Int, Query, Resolver, Root, UseMiddleware } from 'type-graphql'\nimport { Like } from 'typeorm'\n\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam, SpeakRefusals } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { Attachment } from '@things-factory/attachment-base'\nimport { accountTailOf, Counterparty, CounterpartyBankAccount } from '@things-factory/biz-base'\nimport { Department } from '@things-factory/organization'\nimport { TaxInvoice } from '@things-factory/tax-invoice'\n\nimport { Account } from '../account/account'\nimport { ExpenditureKind, ExpenditureRequest, ExpenditureRequestStatus } from './expenditure-request'\nimport { ExpenditureRequestItem } from './expenditure-request-item'\nimport { paymentStatesOf, ExpenditurePaymentState } from './expenditure-payment-state'\nimport { monthlySummary, statusCounts, type RequestStatus } from './expenditure-request-rules'\nimport { approvedWithStates, driftOf, RECEIPT_REF_TYPE } from './expenditure-request-service'\nimport { ExpenditurePayment, ExpenditureQueue, ExpenditureQueueRow, ExpenditureRequestList, ExpenditureSummary } from './expenditure-request-type'\n\nconst byId = async <T>(entity: new () => T, id: string | null | undefined, withDeleted = false): Promise<T | null> =>\n id ? ((await getRepository(entity).findOne({ where: { id } as any, withDeleted })) as T | null) : null\n\nasync function summaryOf(domain: { id: string }, year: number, month: number | undefined, requesterId?: string): Promise<ExpenditureSummary> {\n const period = month ? `${year}-${String(month).padStart(2, '0')}` : `${year}-%`\n const requests = await getRepository(ExpenditureRequest).find({\n where: {\n domain: { id: domain.id },\n kind: ExpenditureKind.REIMBURSEMENT,\n month: month ? period : Like(period),\n ...(requesterId ? { requester: { id: requesterId } } : {})\n } as any,\n relations: ['requester', 'items', 'items.account']\n })\n const shaped = requests.map(one => ({\n month: one.month,\n requesterId: one.requesterId ?? one.requester?.id,\n requesterName: one.requester?.name ?? null,\n status: one.status as RequestStatus,\n /* Summed by 계정과목; a line not yet filed counts under the category written on it. */\n items: (one.items ?? []).filter(item => !item.deletedAt).map(item => ({ ...item, category: item.account?.name ?? item.category }))\n }))\n\n const rows = monthlySummary(shaped)\n const approved = requests.filter(one => one.status === ExpenditureRequestStatus.APPROVED)\n approved.forEach(one => (one.items = (one.items ?? []).filter(item => !item.deletedAt)))\n const states = await paymentStatesOf(getRepository(ExpenditureRequest).manager, domain, approved as any)\n\n return {\n rows,\n statuses: Object.entries(statusCounts(shaped)).map(([status, count]) => ({ status, count })),\n approvedTotal: rows.reduce((sum, one) => sum + one.total, 0),\n unpaid: [...states.values()].reduce((sum, one) => sum + one.outstanding, 0)\n }\n}\n\n@UseMiddleware(SpeakRefusals)\n@Resolver(ExpenditureRequest)\nexport class ExpenditureRequestQuery {\n /** The last four digits of the account paid into - what the requester and the approvers see (ADR-0139). */\n @FieldResolver(type => String, { nullable: true, description: \"The last four digits of the account paid into\" })\n payeeAccountTail(@Root() request: ExpenditureRequest): string | undefined {\n return accountTailOf(request.payeeAccountNumber)\n }\n\n /** The caller's own requests - what an employee sees. */\n @Directive('@privilege(category: \"accounting-self\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => ExpenditureRequestList, { description: \"The caller's own expenditure requests\" })\n async myExpenditureRequests(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<ExpenditureRequestList> {\n const { domain, user } = context.state\n const queryBuilder = getQueryBuilderFromListParams({ domain, params, repository: getRepository(ExpenditureRequest), searchables: ['title', 'notes'], alias: 'request' })\n queryBuilder.andWhere('request.requester = :requester', { requester: user.id })\n queryBuilder.addOrderBy('request.createdAt', 'DESC')\n const [items, total] = await queryBuilder.getManyAndCount()\n return { items, total }\n }\n\n /** One of the caller's own requests, with its lines. */\n @Directive('@privilege(category: \"accounting-self\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => ExpenditureRequest, { nullable: true, description: \"One of the caller's own expenditure requests\" })\n async myExpenditureRequest(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<ExpenditureRequest | null> {\n const { domain, user } = context.state\n return await getRepository(ExpenditureRequest).findOne({ where: { id, domain: { id: domain.id }, requester: { id: user.id } } as any })\n }\n\n /** Every request of the domain - what finance sees. */\n /*\n * Every request, one by one - who spent what, the receipts, the queue to pay - is the paying seat's: `expenditure`\n * (the user, 2026-10-18). The month's summary stays `accounting`, which the executives read.\n */\n @Directive('@privilege(category: \"expenditure\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => ExpenditureRequestList, { description: 'Every expenditure request of the domain' })\n async expenditureRequests(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<ExpenditureRequestList> {\n const { domain } = context.state\n const queryBuilder = getQueryBuilderFromListParams({ domain, params, repository: getRepository(ExpenditureRequest), searchables: ['title', 'notes'], alias: 'request' })\n queryBuilder.addOrderBy('request.createdAt', 'DESC')\n const [items, total] = await queryBuilder.getManyAndCount()\n return { items, total }\n }\n\n @Directive('@privilege(category: \"expenditure\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => ExpenditureRequest, { nullable: true, description: 'One expenditure request of the domain' })\n async expenditureRequest(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<ExpenditureRequest | null> {\n return await getRepository(ExpenditureRequest).findOne({ where: { id, domain: { id: context.state.domain.id } } as any })\n }\n\n /**\n * The payment queue (지급 대기) - approved requests still to pay, by the day they are to be paid, and the paid ones\n * whose bank line no statement has matched yet.\n */\n @Directive('@privilege(category: \"expenditure\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => ExpenditureQueue, { description: 'Approved requests still to pay, and paid ones not yet matched to the bank' })\n async expenditureQueue(@Ctx() context: ResolverContext): Promise<ExpenditureQueue> {\n const { domain } = context.state\n const manager = getRepository(ExpenditureRequest).manager\n const { requests, states } = await approvedWithStates(manager, domain)\n\n const rows: ExpenditureQueueRow[] = []\n for (const request of requests) {\n const payment = states.get(request.id)!\n if (payment.state === ExpenditurePaymentState.NOTHING_TO_PAY) continue\n rows.push({\n request,\n payment,\n payeeName: (request.kind === ExpenditureKind.VENDOR ? request.counterparty?.name : request.requester?.name) ?? undefined,\n payeeAccountDrift: payment.outstanding > 0 ? await driftOf(manager, request) : undefined\n })\n }\n const due = (row: ExpenditureQueueRow) => row.request.dueDate ?? '9999-12-31'\n const waiting = rows\n .filter(row => row.payment.outstanding > 0)\n .sort((a, b) => due(a).localeCompare(due(b)) || String(a.request.decidedAt ?? '').localeCompare(String(b.request.decidedAt ?? '')))\n const unreconciled = rows.filter(row => row.payment.outstanding <= 0 && !row.payment.reconciled)\n return { waiting, unreconciled }\n }\n\n @Directive('@privilege(category: \"accounting\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => ExpenditureSummary, { description: 'Approved reimbursements per month, requester and category, with requests per status' })\n async expenditureSummary(\n @Arg('year', type => Int) year: number,\n @Arg('month', type => Int, { nullable: true }) month: number,\n @Ctx() context: ResolverContext\n ): Promise<ExpenditureSummary> {\n return await summaryOf(context.state.domain, year, month || undefined)\n }\n\n @Directive('@privilege(category: \"accounting-self\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => ExpenditureSummary, { description: \"The caller's own monthly summary of reimbursements\" })\n async myExpenditureSummary(\n @Arg('year', type => Int) year: number,\n @Arg('month', type => Int, { nullable: true }) month: number,\n @Ctx() context: ResolverContext\n ): Promise<ExpenditureSummary> {\n return await summaryOf(context.state.domain, year, month || undefined, context.state.user.id)\n }\n\n /** How far it is paid - read from its payments (ADR-0135 §2-4). */\n @FieldResolver(type => ExpenditurePayment, { nullable: true })\n async payment(@Root() request: ExpenditureRequest): Promise<ExpenditurePayment | null> {\n if (request.status !== ExpenditureRequestStatus.APPROVED) return null\n const items = await getRepository(ExpenditureRequestItem).find({ where: { request: { id: request.id } } as any })\n const states = await paymentStatesOf(getRepository(ExpenditureRequest).manager, { id: request.domainId! }, [{ id: request.id, items }])\n return states.get(request.id) ?? null\n }\n\n @FieldResolver(type => [ExpenditureRequestItem])\n async items(@Root() request: ExpenditureRequest): Promise<ExpenditureRequestItem[]> {\n if (request.items) return request.items.filter(item => !item.deletedAt)\n return await getRepository(ExpenditureRequestItem).find({ where: { request: { id: request.id } } as any, order: { spentDate: 'ASC', createdAt: 'ASC' } as any })\n }\n\n @FieldResolver(type => User, { nullable: true })\n async requester(@Root() request: ExpenditureRequest): Promise<User | null> {\n return request.requester ?? (await byId(User, request.requesterId))\n }\n\n @FieldResolver(type => Department, { nullable: true })\n async department(@Root() request: ExpenditureRequest): Promise<Department | null> {\n return request.department ?? (await byId(Department, request.departmentId))\n }\n\n @FieldResolver(type => Counterparty, { nullable: true })\n async counterparty(@Root() request: ExpenditureRequest): Promise<Counterparty | null> {\n return request.counterparty ?? (await byId(Counterparty, request.counterpartyId, true))\n }\n\n @FieldResolver(type => CounterpartyBankAccount, { nullable: true })\n async payeeAccount(@Root() request: ExpenditureRequest): Promise<CounterpartyBankAccount | null> {\n return request.payeeAccount ?? (await byId(CounterpartyBankAccount, request.payeeAccountId, true))\n }\n\n @FieldResolver(type => User, { nullable: true })\n async decidedBy(@Root() request: ExpenditureRequest): Promise<User | null> {\n return request.decidedBy ?? (await byId(User, request.decidedById))\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() request: ExpenditureRequest): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: request.domainId })\n }\n\n @FieldResolver(type => User, { nullable: true })\n async creator(@Root() request: ExpenditureRequest): Promise<User | null> {\n return await byId(User, request.creatorId)\n }\n\n @FieldResolver(type => User, { nullable: true })\n async updater(@Root() request: ExpenditureRequest): Promise<User | null> {\n return await byId(User, request.updaterId)\n }\n}\n\n@Resolver(ExpenditureRequestItem)\nexport class ExpenditureRequestItemQuery {\n @FieldResolver(type => ExpenditureRequest, { nullable: true })\n async request(@Root() item: ExpenditureRequestItem): Promise<ExpenditureRequest | null> {\n return item.request ?? (await byId(ExpenditureRequest, item.requestId))\n }\n\n @FieldResolver(type => Account, { nullable: true })\n async account(@Root() item: ExpenditureRequestItem): Promise<Account | null> {\n return item.account ?? (await byId(Account, item.accountId))\n }\n\n @FieldResolver(type => TaxInvoice, { nullable: true })\n async taxInvoice(@Root() item: ExpenditureRequestItem): Promise<TaxInvoice | null> {\n return item.taxInvoice ?? (await byId(TaxInvoice, item.taxInvoiceId, true))\n }\n\n /** Where the receipt is, or null - so an approver can see what was spent. */\n @FieldResolver(type => String, { nullable: true })\n async receiptUrl(@Root() item: ExpenditureRequestItem): Promise<string | null> {\n const attachment = await getRepository(Attachment).findOne({ where: { refType: RECEIPT_REF_TYPE, refBy: item.id }, order: { createdAt: 'DESC' } as any })\n return attachment?.fullpath ?? null\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() item: ExpenditureRequestItem): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: item.domainId })\n }\n\n @FieldResolver(type => User, { nullable: true })\n async creator(@Root() item: ExpenditureRequestItem): Promise<User | null> {\n return await byId(User, item.creatorId)\n }\n\n @FieldResolver(type => User, { nullable: true })\n async updater(@Root() item: ExpenditureRequestItem): Promise<User | null> {\n return await byId(User, item.updaterId)\n }\n}\n"]}
|
|
@@ -108,11 +108,13 @@ tslib_1.__decorate([
|
|
|
108
108
|
], ExpenditureRequest.prototype, "payeeBankName", void 0);
|
|
109
109
|
tslib_1.__decorate([
|
|
110
110
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
111
|
+
(0, type_graphql_1.Directive)('@privilege(category: "bank", privilege: "query", domainOwnerGranted: false)'),
|
|
111
112
|
(0, type_graphql_1.Field)({ nullable: true, description: 'The account paid into, as approvers saw it - written at submission' }),
|
|
112
113
|
tslib_1.__metadata("design:type", String)
|
|
113
114
|
], ExpenditureRequest.prototype, "payeeAccountNumber", void 0);
|
|
114
115
|
tslib_1.__decorate([
|
|
115
116
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
117
|
+
(0, type_graphql_1.Directive)('@privilege(category: "bank", privilege: "query", domainOwnerGranted: false)'),
|
|
116
118
|
(0, type_graphql_1.Field)({ nullable: true, description: 'The holder of the account paid into, as approvers saw it' }),
|
|
117
119
|
tslib_1.__metadata("design:type", String)
|
|
118
120
|
], ExpenditureRequest.prototype, "payeeHolderName", void 0);
|