@things-factory/accounting 10.1.134 → 10.1.135
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-client/route.d.ts +1 -1
- package/dist-client/route.js +0 -12
- package/dist-client/route.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/index.d.ts +0 -1
- package/dist-server/index.js +0 -1
- package/dist-server/index.js.map +1 -1
- package/dist-server/service/account/account-history.d.ts +13 -6
- package/dist-server/service/account/account-history.js +44 -17
- package/dist-server/service/account/account-history.js.map +1 -1
- package/dist-server/service/account/account-mutation.js +2 -2
- package/dist-server/service/account/account-mutation.js.map +1 -1
- package/dist-server/service/account/account-type.d.ts +16 -0
- package/dist-server/service/account/account-type.js +71 -13
- package/dist-server/service/account/account-type.js.map +1 -1
- package/dist-server/service/account/account.d.ts +9 -3
- package/dist-server/service/account/account.js +34 -8
- package/dist-server/service/account/account.js.map +1 -1
- package/dist-server/service/accounting-category/accounting-category-mutation.js +2 -2
- package/dist-server/service/accounting-category/accounting-category-mutation.js.map +1 -1
- package/dist-server/service/accounting-document/accounting-document-mutation.js +12 -3
- package/dist-server/service/accounting-document/accounting-document-mutation.js.map +1 -1
- package/dist-server/service/accounting-document/accounting-document-query.js +2 -0
- package/dist-server/service/accounting-document/accounting-document-query.js.map +1 -1
- package/dist-server/service/bank-account/bank-account-history.d.ts +11 -14
- package/dist-server/service/bank-account/bank-account-history.js +46 -59
- package/dist-server/service/bank-account/bank-account-history.js.map +1 -1
- package/dist-server/service/bank-account/bank-account-mutation.d.ts +1 -2
- package/dist-server/service/bank-account/bank-account-mutation.js +25 -69
- package/dist-server/service/bank-account/bank-account-mutation.js.map +1 -1
- package/dist-server/service/bank-account/bank-account-query.js +2 -0
- package/dist-server/service/bank-account/bank-account-query.js.map +1 -1
- package/dist-server/service/bank-account/bank-account-service.d.ts +5 -0
- package/dist-server/service/bank-account/bank-account-service.js +21 -0
- package/dist-server/service/bank-account/bank-account-service.js.map +1 -0
- package/dist-server/service/bank-account/bank-account-type.d.ts +13 -19
- package/dist-server/service/bank-account/bank-account-type.js +45 -69
- package/dist-server/service/bank-account/bank-account-type.js.map +1 -1
- package/dist-server/service/bank-account/bank-account.d.ts +14 -17
- package/dist-server/service/bank-account/bank-account.js +45 -57
- package/dist-server/service/bank-account/bank-account.js.map +1 -1
- package/dist-server/service/bank-statement/bank-statement-query.d.ts +14 -0
- package/dist-server/service/bank-statement/bank-statement-query.js +92 -0
- package/dist-server/service/bank-statement/bank-statement-query.js.map +1 -0
- package/dist-server/service/bank-statement/bank-statement.d.ts +26 -0
- package/dist-server/service/bank-statement/bank-statement.js +109 -0
- package/dist-server/service/bank-statement/bank-statement.js.map +1 -0
- package/dist-server/service/bank-statement/index.d.ts +5 -0
- package/dist-server/service/bank-statement/index.js +9 -0
- package/dist-server/service/bank-statement/index.js.map +1 -0
- package/dist-server/service/cash-flow-type.d.ts +5 -0
- package/dist-server/service/cash-flow-type.js +15 -0
- package/dist-server/service/cash-flow-type.js.map +1 -0
- package/dist-server/service/financial-institution/financial-institution-mutation.js +10 -1
- package/dist-server/service/financial-institution/financial-institution-mutation.js.map +1 -1
- package/dist-server/service/financial-institution/financial-institution-query.js +14 -6
- package/dist-server/service/financial-institution/financial-institution-query.js.map +1 -1
- package/dist-server/service/financial-institution/index.d.ts +1 -1
- package/dist-server/service/financial-statement/financial-statement-history.d.ts +11 -9
- package/dist-server/service/financial-statement/financial-statement-history.js +47 -36
- package/dist-server/service/financial-statement/financial-statement-history.js.map +1 -1
- package/dist-server/service/financial-statement/financial-statement-line.d.ts +24 -0
- package/dist-server/service/financial-statement/financial-statement-line.js +108 -0
- package/dist-server/service/financial-statement/financial-statement-line.js.map +1 -0
- package/dist-server/service/financial-statement/financial-statement-mutation.d.ts +1 -8
- package/dist-server/service/financial-statement/financial-statement-mutation.js +10 -135
- package/dist-server/service/financial-statement/financial-statement-mutation.js.map +1 -1
- package/dist-server/service/financial-statement/financial-statement-query.d.ts +8 -7
- package/dist-server/service/financial-statement/financial-statement-query.js +40 -30
- package/dist-server/service/financial-statement/financial-statement-query.js.map +1 -1
- package/dist-server/service/financial-statement/financial-statement-service.d.ts +33 -0
- package/dist-server/service/financial-statement/financial-statement-service.js +44 -0
- package/dist-server/service/financial-statement/financial-statement-service.js.map +1 -0
- package/dist-server/service/financial-statement/financial-statement.d.ts +19 -11
- package/dist-server/service/financial-statement/financial-statement.js +73 -65
- package/dist-server/service/financial-statement/financial-statement.js.map +1 -1
- package/dist-server/service/financial-statement/index.d.ts +3 -2
- package/dist-server/service/financial-statement/index.js +2 -2
- package/dist-server/service/financial-statement/index.js.map +1 -1
- package/dist-server/service/index.d.ts +15 -3
- package/dist-server/service/index.js +30 -13
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/payment/index.d.ts +1 -0
- package/dist-server/service/payment/index.js +1 -0
- package/dist-server/service/payment/index.js.map +1 -1
- package/dist-server/service/payment/payment-history.d.ts +9 -16
- package/dist-server/service/payment/payment-history.js +36 -70
- package/dist-server/service/payment/payment-history.js.map +1 -1
- package/dist-server/service/payment/payment-mutation.d.ts +0 -1
- package/dist-server/service/payment/payment-mutation.js +14 -79
- package/dist-server/service/payment/payment-mutation.js.map +1 -1
- package/dist-server/service/payment/payment-query.d.ts +3 -0
- package/dist-server/service/payment/payment-query.js +30 -1
- package/dist-server/service/payment/payment-query.js.map +1 -1
- package/dist-server/service/payment/payment-service.d.ts +16 -0
- package/dist-server/service/payment/payment-service.js +140 -0
- package/dist-server/service/payment/payment-service.js.map +1 -0
- package/dist-server/service/payment/payment-targets.d.ts +31 -0
- package/dist-server/service/payment/payment-targets.js +19 -0
- package/dist-server/service/payment/payment-targets.js.map +1 -0
- package/dist-server/service/payment/payment-type.d.ts +13 -17
- package/dist-server/service/payment/payment-type.js +35 -51
- package/dist-server/service/payment/payment-type.js.map +1 -1
- package/dist-server/service/payment/payment.d.ts +23 -22
- package/dist-server/service/payment/payment.js +66 -94
- package/dist-server/service/payment/payment.js.map +1 -1
- package/dist-server/service/payment/transfer-target.d.ts +1 -0
- package/dist-server/service/payment/transfer-target.js +43 -0
- package/dist-server/service/payment/transfer-target.js.map +1 -0
- package/dist-server/service/recurring-cash-item/index.d.ts +6 -0
- package/dist-server/service/recurring-cash-item/index.js +10 -0
- package/dist-server/service/recurring-cash-item/index.js.map +1 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item-mutation.d.ts +7 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item-mutation.js +63 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item-mutation.js.map +1 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item-query.d.ts +15 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item-query.js +101 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item-query.js.map +1 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item-service.d.ts +23 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item-service.js +91 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item-service.js.map +1 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item-type.d.ts +23 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item-type.js +85 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item-type.js.map +1 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item.d.ts +35 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item.js +142 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item.js.map +1 -0
- package/dist-server/service/recurring-cash-item/recurring-schedule.d.ts +36 -0
- package/dist-server/service/recurring-cash-item/recurring-schedule.js +41 -0
- package/dist-server/service/recurring-cash-item/recurring-schedule.js.map +1 -0
- package/dist-server/service/transaction/transaction-history.d.ts +42 -15
- package/dist-server/service/transaction/transaction-history.js +160 -54
- package/dist-server/service/transaction/transaction-history.js.map +1 -1
- package/dist-server/service/transaction/transaction-mutation.d.ts +0 -1
- package/dist-server/service/transaction/transaction-mutation.js +13 -78
- package/dist-server/service/transaction/transaction-mutation.js.map +1 -1
- package/dist-server/service/transaction/transaction-period.d.ts +16 -0
- package/dist-server/service/transaction/transaction-period.js +49 -0
- package/dist-server/service/transaction/transaction-period.js.map +1 -0
- package/dist-server/service/transaction/transaction-query.d.ts +12 -0
- package/dist-server/service/transaction/transaction-query.js +84 -2
- package/dist-server/service/transaction/transaction-query.js.map +1 -1
- package/dist-server/service/transaction/transaction-service.d.ts +30 -0
- package/dist-server/service/transaction/transaction-service.js +130 -0
- package/dist-server/service/transaction/transaction-service.js.map +1 -0
- package/dist-server/service/transaction/transaction-type.d.ts +39 -7
- package/dist-server/service/transaction/transaction-type.js +145 -23
- package/dist-server/service/transaction/transaction-type.js.map +1 -1
- package/dist-server/service/transaction/transaction.d.ts +58 -31
- package/dist-server/service/transaction/transaction.js +216 -102
- package/dist-server/service/transaction/transaction.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -3
- package/things-factory.config.js +0 -4
- package/translations/en.json +34 -2
- package/translations/ja.json +0 -1
- package/translations/ko.json +34 -2
- package/translations/ms.json +0 -1
- package/translations/zh.json +0 -1
- package/dist-client/pages/account/account-importer.d.ts +0 -22
- package/dist-client/pages/account/account-importer.js +0 -99
- package/dist-client/pages/account/account-importer.js.map +0 -1
- package/dist-client/pages/account/account-list-page.d.ts +0 -57
- package/dist-client/pages/account/account-list-page.js +0 -306
- package/dist-client/pages/account/account-list-page.js.map +0 -1
- package/dist-client/pages/bank-account/bank-account-importer.d.ts +0 -23
- package/dist-client/pages/bank-account/bank-account-importer.js +0 -92
- package/dist-client/pages/bank-account/bank-account-importer.js.map +0 -1
- package/dist-client/pages/bank-account/bank-account-list-page.d.ts +0 -60
- package/dist-client/pages/bank-account/bank-account-list-page.js +0 -317
- package/dist-client/pages/bank-account/bank-account-list-page.js.map +0 -1
- package/dist-client/pages/financial-statement/financial-statement-importer.d.ts +0 -22
- package/dist-client/pages/financial-statement/financial-statement-importer.js +0 -99
- package/dist-client/pages/financial-statement/financial-statement-importer.js.map +0 -1
- package/dist-client/pages/financial-statement/financial-statement-list-page.d.ts +0 -57
- package/dist-client/pages/financial-statement/financial-statement-list-page.js +0 -280
- package/dist-client/pages/financial-statement/financial-statement-list-page.js.map +0 -1
- package/dist-client/pages/income-statement/income-statement-importer.d.ts +0 -22
- package/dist-client/pages/income-statement/income-statement-importer.js +0 -99
- package/dist-client/pages/income-statement/income-statement-importer.js.map +0 -1
- package/dist-client/pages/income-statement/income-statement-list-page.d.ts +0 -57
- package/dist-client/pages/income-statement/income-statement-list-page.js +0 -280
- package/dist-client/pages/income-statement/income-statement-list-page.js.map +0 -1
- package/dist-client/pages/payment/payment-importer.d.ts +0 -23
- package/dist-client/pages/payment/payment-importer.js +0 -92
- package/dist-client/pages/payment/payment-importer.js.map +0 -1
- package/dist-client/pages/payment/payment-list-page.d.ts +0 -60
- package/dist-client/pages/payment/payment-list-page.js +0 -317
- package/dist-client/pages/payment/payment-list-page.js.map +0 -1
- package/dist-client/pages/transaction/transaction-importer.d.ts +0 -22
- package/dist-client/pages/transaction/transaction-importer.js +0 -99
- package/dist-client/pages/transaction/transaction-importer.js.map +0 -1
- package/dist-client/pages/transaction/transaction-list-page.d.ts +0 -57
- package/dist-client/pages/transaction/transaction-list-page.js +0 -280
- package/dist-client/pages/transaction/transaction-list-page.js.map +0 -1
- package/dist-server/controllers/index.d.ts +0 -1
- package/dist-server/controllers/index.js +0 -5
- package/dist-server/controllers/index.js.map +0 -1
- package/dist-server/controllers/summary-statements.d.ts +0 -4
- package/dist-server/controllers/summary-statements.js +0 -149
- package/dist-server/controllers/summary-statements.js.map +0 -1
- package/dist-server/migrations/1725201567284-seed-country-codes.d.ts +0 -5
- package/dist-server/migrations/1725201567284-seed-country-codes.js +0 -255
- package/dist-server/migrations/1725201567284-seed-country-codes.js.map +0 -1
- package/dist-server/service/financial-statement/financial-statement-line-item.d.ts +0 -19
- package/dist-server/service/financial-statement/financial-statement-line-item.js +0 -95
- package/dist-server/service/financial-statement/financial-statement-line-item.js.map +0 -1
- package/dist-server/service/financial-statement/financial-statement-type.d.ts +0 -20
- package/dist-server/service/financial-statement/financial-statement-type.js +0 -77
- package/dist-server/service/financial-statement/financial-statement-type.js.map +0 -1
- package/dist-server/service/income-statement/event-subscriber.d.ts +0 -7
- package/dist-server/service/income-statement/event-subscriber.js +0 -21
- package/dist-server/service/income-statement/event-subscriber.js.map +0 -1
- package/dist-server/service/income-statement/income-statement-history.d.ts +0 -28
- package/dist-server/service/income-statement/income-statement-history.js +0 -146
- package/dist-server/service/income-statement/income-statement-history.js.map +0 -1
- package/dist-server/service/income-statement/income-statement-line-item.d.ts +0 -19
- package/dist-server/service/income-statement/income-statement-line-item.js +0 -97
- package/dist-server/service/income-statement/income-statement-line-item.js.map +0 -1
- package/dist-server/service/income-statement/income-statement-mutation.d.ts +0 -10
- package/dist-server/service/income-statement/income-statement-mutation.js +0 -159
- package/dist-server/service/income-statement/income-statement-mutation.js.map +0 -1
- package/dist-server/service/income-statement/income-statement-query.d.ts +0 -11
- package/dist-server/service/income-statement/income-statement-query.js +0 -81
- package/dist-server/service/income-statement/income-statement-query.js.map +0 -1
- package/dist-server/service/income-statement/income-statement-type.d.ts +0 -20
- package/dist-server/service/income-statement/income-statement-type.js +0 -77
- package/dist-server/service/income-statement/income-statement-type.js.map +0 -1
- package/dist-server/service/income-statement/income-statement.d.ts +0 -28
- package/dist-server/service/income-statement/income-statement.js +0 -137
- package/dist-server/service/income-statement/income-statement.js.map +0 -1
- package/dist-server/service/income-statement/index.d.ts +0 -8
- package/dist-server/service/income-statement/index.js +0 -13
- package/dist-server/service/income-statement/index.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"financial-statement-line.js","sourceRoot":"","sources":["../../../server/service/financial-statement/financial-statement-line.ts"],"names":[],"mappings":";;;;AAAA,qCAUgB;AAChB,+CAAgE;AAEhE,iDAA2D;AAC3D,yDAAgD;AAEhD,+DAA0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I,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC;sCAC9D,gBAAI;uDAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,IAA4B,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;;yDACzC;AAIlB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;sCAClE,gBAAI;uDAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,IAA4B,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;;yDACzC;iCAnEP,sBAAsB;IANlC,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,+BAA+B,EAAE,CAAC,IAA4B,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE;QACrG,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,sBAAsB;KAC9B,CAAC;IACD,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,yCAAyC,EAAE,CAAC;GAC1D,sBAAsB,CAoElC","sourcesContent":["import {\n Column,\n CreateDateColumn,\n DeleteDateColumn,\n Entity,\n Index,\n ManyToOne,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\nimport { Field, Float, ID, Int, ObjectType } from 'type-graphql'\n\nimport { Domain, moneyColumn } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\n\nimport { FinancialStatement } from './financial-statement'\n\n/** One line of a filed statement - an account or a total, under the code of the standard it was filed in. */\n@Entity()\n@Index('ix_financial_statement_line_0', (line: FinancialStatementLine) => [line.statement, line.code], {\n unique: true,\n where: '\"deleted_at\" IS NULL'\n})\n@ObjectType({ description: 'One line of a filed financial statement' })\nexport class FinancialStatementLine {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier' })\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true, description: 'The domain' })\n domain?: Domain\n\n @RelationId((line: FinancialStatementLine) => line.domain)\n domainId?: string\n\n @ManyToOne(type => FinancialStatement, statement => statement.lines, { nullable: false })\n @Field(type => FinancialStatement, { nullable: true, description: 'The statement it is a line of' })\n statement?: FinancialStatement\n\n @RelationId((line: FinancialStatementLine) => line.statement)\n statementId?: string\n\n @Column()\n @Field({ description: \"The standard's code - the order of the statement\" })\n code: string\n\n @Column()\n @Field({ description: 'The account as the statement writes it' })\n name: string\n\n @Column(moneyColumn())\n @Field(type => Float, { description: 'Amount' })\n amount: number\n\n @Column({ type: 'int', default: 3 })\n @Field(type => Int, { description: '0 total, 1 section, 2 group, 3 item, 4 breakdown' })\n rank: number\n\n @Column({ type: 'int', default: 0 })\n @Field(type => Int, { description: 'Indentation - how many lines above contain this one' })\n level: number\n\n @Column({ default: false })\n @Field({ description: 'A contra account - the item above less this' })\n contra: boolean\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'When it was recorded' })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'When it last changed' })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true, description: 'When it was replaced or deleted' })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Who recorded it' })\n creator?: User\n\n @RelationId((line: FinancialStatementLine) => line.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Who last changed it' })\n updater?: User\n\n @RelationId((line: FinancialStatementLine) => line.updater)\n updaterId?: string\n}\n"]}
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import { FinancialStatement } from './financial-statement';
|
|
2
|
-
import { NewFinancialStatement, FinancialStatementPatch } from './financial-statement-type';
|
|
3
1
|
export declare class FinancialStatementMutation {
|
|
4
|
-
|
|
5
|
-
updateFinancialStatement(id: string, patch: FinancialStatementPatch, context: ResolverContext): Promise<FinancialStatement>;
|
|
6
|
-
updateMultipleFinancialStatement(patches: FinancialStatementPatch[], context: ResolverContext): Promise<FinancialStatement[]>;
|
|
7
|
-
deleteFinancialStatement(id: string, context: ResolverContext): Promise<boolean>;
|
|
8
|
-
deleteFinancialStatements(ids: string[], context: ResolverContext): Promise<boolean>;
|
|
9
|
-
importFinancialStatements(financialStatements: FinancialStatementPatch[], context: ResolverContext): Promise<boolean>;
|
|
2
|
+
deleteFinancialStatements(fiscalYear: number, context: ResolverContext): Promise<boolean>;
|
|
10
3
|
}
|
|
@@ -3,91 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FinancialStatementMutation = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
|
6
|
-
const typeorm_1 = require("typeorm");
|
|
7
6
|
const shell_1 = require("@things-factory/shell");
|
|
8
7
|
const financial_statement_1 = require("./financial-statement");
|
|
9
|
-
const
|
|
8
|
+
const financial_statement_service_1 = require("./financial-statement-service");
|
|
10
9
|
let FinancialStatementMutation = class FinancialStatementMutation {
|
|
11
|
-
async
|
|
12
|
-
const { domain, user, tx } = context.state;
|
|
13
|
-
const result = await (0, shell_1.getRepository)(financial_statement_1.FinancialStatement, tx).save({
|
|
14
|
-
...financialStatement,
|
|
15
|
-
domain,
|
|
16
|
-
creator: user,
|
|
17
|
-
updater: user
|
|
18
|
-
});
|
|
19
|
-
return result;
|
|
20
|
-
}
|
|
21
|
-
async updateFinancialStatement(id, patch, context) {
|
|
22
|
-
const { domain, user, tx } = context.state;
|
|
23
|
-
const repository = (0, shell_1.getRepository)(financial_statement_1.FinancialStatement, tx);
|
|
24
|
-
const financialStatement = await repository.findOne({
|
|
25
|
-
where: { domain: { id: domain.id }, id }
|
|
26
|
-
});
|
|
27
|
-
const result = await repository.save({
|
|
28
|
-
...financialStatement,
|
|
29
|
-
...patch,
|
|
30
|
-
updater: user
|
|
31
|
-
});
|
|
32
|
-
return result;
|
|
33
|
-
}
|
|
34
|
-
async updateMultipleFinancialStatement(patches, context) {
|
|
35
|
-
const { domain, user, tx } = context.state;
|
|
36
|
-
let results = [];
|
|
37
|
-
const _createRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === '+');
|
|
38
|
-
const _updateRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === 'M');
|
|
39
|
-
const financialStatementRepo = (0, shell_1.getRepository)(financial_statement_1.FinancialStatement, tx);
|
|
40
|
-
if (_createRecords.length > 0) {
|
|
41
|
-
for (let i = 0; i < _createRecords.length; i++) {
|
|
42
|
-
const newRecord = _createRecords[i];
|
|
43
|
-
const result = await financialStatementRepo.save({
|
|
44
|
-
...newRecord,
|
|
45
|
-
domain,
|
|
46
|
-
creator: user,
|
|
47
|
-
updater: user
|
|
48
|
-
});
|
|
49
|
-
results.push({ ...result, cuFlag: '+' });
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (_updateRecords.length > 0) {
|
|
53
|
-
for (let i = 0; i < _updateRecords.length; i++) {
|
|
54
|
-
const updateRecord = _updateRecords[i];
|
|
55
|
-
const financialStatement = await financialStatementRepo.findOne({
|
|
56
|
-
where: { domain: { id: domain.id }, id: updateRecord.id }
|
|
57
|
-
});
|
|
58
|
-
if (!financialStatement) {
|
|
59
|
-
throw new Error(`failed to find financialStatement to update: ${updateRecord.id}`);
|
|
60
|
-
}
|
|
61
|
-
const result = await financialStatementRepo.save({
|
|
62
|
-
...financialStatement,
|
|
63
|
-
...updateRecord,
|
|
64
|
-
updater: user
|
|
65
|
-
});
|
|
66
|
-
results.push({ ...result, cuFlag: 'M' });
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return results;
|
|
70
|
-
}
|
|
71
|
-
async deleteFinancialStatement(id, context) {
|
|
10
|
+
async deleteFinancialStatements(fiscalYear, context) {
|
|
72
11
|
const { domain, tx } = context.state;
|
|
73
|
-
await (0, shell_1.getRepository)(financial_statement_1.FinancialStatement, tx).
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
async deleteFinancialStatements(ids, context) {
|
|
77
|
-
const { domain, tx } = context.state;
|
|
78
|
-
await (0, shell_1.getRepository)(financial_statement_1.FinancialStatement, tx).delete({
|
|
79
|
-
domain: { id: domain.id },
|
|
80
|
-
id: (0, typeorm_1.In)(ids)
|
|
12
|
+
const statements = await (0, shell_1.getRepository)(financial_statement_1.FinancialStatement, tx).find({
|
|
13
|
+
where: { domain: { id: domain.id }, fiscalYear }
|
|
81
14
|
});
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
async importFinancialStatements(financialStatements, context) {
|
|
85
|
-
const { domain, tx } = context.state;
|
|
86
|
-
await Promise.all(financialStatements.map(async (financialStatement) => {
|
|
87
|
-
const createdFinancialStatement = await tx
|
|
88
|
-
.getRepository(financial_statement_1.FinancialStatement)
|
|
89
|
-
.save({ domain, ...financialStatement });
|
|
90
|
-
}));
|
|
15
|
+
await (0, financial_statement_service_1.deleteStatements)(tx, statements);
|
|
91
16
|
return true;
|
|
92
17
|
}
|
|
93
18
|
};
|
|
@@ -95,65 +20,15 @@ exports.FinancialStatementMutation = FinancialStatementMutation;
|
|
|
95
20
|
tslib_1.__decorate([
|
|
96
21
|
(0, type_graphql_1.Directive)('@transaction'),
|
|
97
22
|
(0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation", domainOwnerGranted: true)'),
|
|
98
|
-
(0, type_graphql_1.Mutation)(returns =>
|
|
99
|
-
tslib_1.__param(0, (0, type_graphql_1.Arg)('
|
|
23
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'Delete the statements of a fiscal year' }),
|
|
24
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('fiscalYear', type => type_graphql_1.Int)),
|
|
100
25
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
101
26
|
tslib_1.__metadata("design:type", Function),
|
|
102
|
-
tslib_1.__metadata("design:paramtypes", [
|
|
103
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
104
|
-
], FinancialStatementMutation.prototype, "createFinancialStatement", null);
|
|
105
|
-
tslib_1.__decorate([
|
|
106
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
107
|
-
(0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation", domainOwnerGranted: true)'),
|
|
108
|
-
(0, type_graphql_1.Mutation)(returns => financial_statement_1.FinancialStatement, { description: 'To modify FinancialStatement information' }),
|
|
109
|
-
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
110
|
-
tslib_1.__param(1, (0, type_graphql_1.Arg)('patch')),
|
|
111
|
-
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
112
|
-
tslib_1.__metadata("design:type", Function),
|
|
113
|
-
tslib_1.__metadata("design:paramtypes", [String, financial_statement_type_1.FinancialStatementPatch, Object]),
|
|
114
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
115
|
-
], FinancialStatementMutation.prototype, "updateFinancialStatement", null);
|
|
116
|
-
tslib_1.__decorate([
|
|
117
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
118
|
-
(0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation", domainOwnerGranted: true)'),
|
|
119
|
-
(0, type_graphql_1.Mutation)(returns => [financial_statement_1.FinancialStatement], { description: "To modify multiple FinancialStatements' information" }),
|
|
120
|
-
tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [financial_statement_type_1.FinancialStatementPatch])),
|
|
121
|
-
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
122
|
-
tslib_1.__metadata("design:type", Function),
|
|
123
|
-
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
124
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
125
|
-
], FinancialStatementMutation.prototype, "updateMultipleFinancialStatement", null);
|
|
126
|
-
tslib_1.__decorate([
|
|
127
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
128
|
-
(0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation", domainOwnerGranted: true)'),
|
|
129
|
-
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete FinancialStatement' }),
|
|
130
|
-
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
131
|
-
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
132
|
-
tslib_1.__metadata("design:type", Function),
|
|
133
|
-
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
134
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
135
|
-
], FinancialStatementMutation.prototype, "deleteFinancialStatement", null);
|
|
136
|
-
tslib_1.__decorate([
|
|
137
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
138
|
-
(0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation", domainOwnerGranted: true)'),
|
|
139
|
-
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple FinancialStatements' }),
|
|
140
|
-
tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
|
|
141
|
-
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
142
|
-
tslib_1.__metadata("design:type", Function),
|
|
143
|
-
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
27
|
+
tslib_1.__metadata("design:paramtypes", [Number, Object]),
|
|
144
28
|
tslib_1.__metadata("design:returntype", Promise)
|
|
145
29
|
], FinancialStatementMutation.prototype, "deleteFinancialStatements", null);
|
|
146
|
-
tslib_1.__decorate([
|
|
147
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
148
|
-
(0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation", domainOwnerGranted: true)'),
|
|
149
|
-
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To import multiple FinancialStatements' }),
|
|
150
|
-
tslib_1.__param(0, (0, type_graphql_1.Arg)('financialStatements', type => [financial_statement_type_1.FinancialStatementPatch])),
|
|
151
|
-
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
152
|
-
tslib_1.__metadata("design:type", Function),
|
|
153
|
-
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
154
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
155
|
-
], FinancialStatementMutation.prototype, "importFinancialStatements", null);
|
|
156
30
|
exports.FinancialStatementMutation = FinancialStatementMutation = tslib_1.__decorate([
|
|
157
|
-
(0, type_graphql_1.Resolver)(financial_statement_1.FinancialStatement)
|
|
31
|
+
(0, type_graphql_1.Resolver)(financial_statement_1.FinancialStatement),
|
|
32
|
+
(0, type_graphql_1.UseMiddleware)(shell_1.SpeakRefusals)
|
|
158
33
|
], FinancialStatementMutation);
|
|
159
34
|
//# sourceMappingURL=financial-statement-mutation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"financial-statement-mutation.js","sourceRoot":"","sources":["../../../server/service/financial-statement/financial-statement-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,iDAAqD;AAErD,+DAA0D;AAC1D,yEAA2F;AAGpF,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAI/B,AAAN,KAAK,CAAC,wBAAwB,CACD,kBAAyC,EAC7D,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAa,EAAC,wCAAkB,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC;YAC9D,GAAG,kBAAkB;YACrB,MAAM;YACN,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI;SACd,CAAC,CAAA;QAEF,OAAO,MAAM,CAAA;IACf,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,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,qFAAqF,CAAC;IAChG,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,wCAAwC,EAAE,CAAC;IAErF,mBAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2EAUP;AAKK;IAHL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,qFAAqF,CAAC;IAChG,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,wCAAwC,EAAE,CAAC;IAErF,mBAAA,IAAA,kBAAG,EAAC,qBAAqB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,kDAAuB,CAAC,CAAC,CAAA;IAC7D,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2EAaP;qCA/IU,0BAA0B;IADtC,IAAA,uBAAQ,EAAC,wCAAkB,CAAC;GAChB,0BAA0B,CAgJtC","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { FinancialStatement } from './financial-statement'\nimport { NewFinancialStatement, FinancialStatementPatch } from './financial-statement-type'\n\n@Resolver(FinancialStatement)\nexport class FinancialStatementMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => FinancialStatement, { description: 'To create new FinancialStatement' })\n async createFinancialStatement(\n @Arg('financialStatement') financialStatement: NewFinancialStatement,\n @Ctx() context: ResolverContext\n ): Promise<FinancialStatement> {\n const { domain, user, tx } = context.state\n\n const result = await getRepository(FinancialStatement, tx).save({\n ...financialStatement,\n domain,\n creator: user,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => FinancialStatement, { description: 'To modify FinancialStatement information' })\n async updateFinancialStatement(\n @Arg('id') id: string,\n @Arg('patch') patch: FinancialStatementPatch,\n @Ctx() context: ResolverContext\n ): Promise<FinancialStatement> {\n const { domain, user, tx } = context.state\n\n const repository = getRepository(FinancialStatement, tx)\n const financialStatement = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n const result = await repository.save({\n ...financialStatement,\n ...patch,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => [FinancialStatement], { description: \"To modify multiple FinancialStatements' information\" })\n async updateMultipleFinancialStatement(\n @Arg('patches', type => [FinancialStatementPatch]) patches: FinancialStatementPatch[],\n @Ctx() context: ResolverContext\n ): Promise<FinancialStatement[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const financialStatementRepo = getRepository(FinancialStatement, tx)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await financialStatementRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const updateRecord = _updateRecords[i]\n const financialStatement = await financialStatementRepo.findOne({\n where: { domain: { id: domain.id }, id: updateRecord.id }\n })\n\n if (!financialStatement) {\n throw new Error(`failed to find financialStatement to update: ${updateRecord.id}`)\n }\n\n const result = await financialStatementRepo.save({\n ...financialStatement,\n ...updateRecord,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete FinancialStatement' })\n async deleteFinancialStatement(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await getRepository(FinancialStatement, tx).delete({ domain: { id: domain.id }, id })\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete multiple FinancialStatements' })\n async deleteFinancialStatements(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await getRepository(FinancialStatement, tx).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To import multiple FinancialStatements' })\n async importFinancialStatements(\n @Arg('financialStatements', type => [FinancialStatementPatch]) financialStatements: FinancialStatementPatch[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await Promise.all(\n financialStatements.map(async (financialStatement: FinancialStatementPatch) => {\n const createdFinancialStatement: FinancialStatement = await tx\n .getRepository(FinancialStatement)\n .save({ domain, ...financialStatement })\n })\n )\n\n return true\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"financial-statement-mutation.js","sourceRoot":"","sources":["../../../server/service/financial-statement/financial-statement-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAA0F;AAE1F,iDAAoE;AAEpE,+DAA0D;AAC1D,+EAAgE;AAIzD,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAI/B,AAAN,KAAK,CAAC,yBAAyB,CACG,UAAkB,EAC3C,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QACpC,MAAM,UAAU,GAAG,MAAM,IAAA,qBAAa,EAAC,wCAAkB,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC;YAClE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE;SACjD,CAAC,CAAA;QACF,MAAM,IAAA,8CAAgB,EAAC,EAAE,EAAE,UAAU,CAAC,CAAA;QAEtC,OAAO,IAAI,CAAA;IACb,CAAC;CACF,CAAA;AAhBY,gEAA0B;AAI/B;IAHL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,qFAAqF,CAAC;IAChG,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,wCAAwC,EAAE,CAAC;IAErF,mBAAA,IAAA,kBAAG,EAAC,YAAY,EAAE,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC,CAAA;IAC9B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2EASP;qCAfU,0BAA0B;IAFtC,IAAA,uBAAQ,EAAC,wCAAkB,CAAC;IAC5B,IAAA,4BAAa,EAAC,qBAAa,CAAC;GAChB,0BAA0B,CAgBtC","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive, Int, UseMiddleware } from 'type-graphql'\n\nimport { getRepository, SpeakRefusals } from '@things-factory/shell'\n\nimport { FinancialStatement } from './financial-statement'\nimport { deleteStatements } from './financial-statement-service'\n\n@Resolver(FinancialStatement)\n@UseMiddleware(SpeakRefusals)\nexport class FinancialStatementMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'Delete the statements of a fiscal year' })\n async deleteFinancialStatements(\n @Arg('fiscalYear', type => Int) fiscalYear: number,\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n const statements = await getRepository(FinancialStatement, tx).find({\n where: { domain: { id: domain.id }, fiscalYear }\n })\n await deleteStatements(tx, statements)\n\n return true\n }\n}\n"]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { Domain
|
|
1
|
+
import { Domain } from '@things-factory/shell';
|
|
2
2
|
import { User } from '@things-factory/auth-base';
|
|
3
3
|
import { FinancialStatement } from './financial-statement';
|
|
4
|
-
import {
|
|
4
|
+
import { FinancialStatementLine } from './financial-statement-line';
|
|
5
5
|
export declare class FinancialStatementQuery {
|
|
6
|
-
|
|
7
|
-
financialStatements(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
creator(
|
|
6
|
+
financialStatementYears(context: ResolverContext): Promise<number[]>;
|
|
7
|
+
financialStatements(fiscalYear: number, context: ResolverContext): Promise<FinancialStatement[]>;
|
|
8
|
+
lines(statement: FinancialStatement): Promise<FinancialStatementLine[]>;
|
|
9
|
+
domain(statement: FinancialStatement): Promise<Domain>;
|
|
10
|
+
creator(statement: FinancialStatement): Promise<User | null>;
|
|
11
|
+
updater(statement: FinancialStatement): Promise<User | null>;
|
|
11
12
|
}
|
|
@@ -6,54 +6,64 @@ const type_graphql_1 = require("type-graphql");
|
|
|
6
6
|
const shell_1 = require("@things-factory/shell");
|
|
7
7
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
8
8
|
const financial_statement_1 = require("./financial-statement");
|
|
9
|
-
const
|
|
9
|
+
const financial_statement_line_1 = require("./financial-statement-line");
|
|
10
10
|
let FinancialStatementQuery = class FinancialStatementQuery {
|
|
11
|
-
async
|
|
11
|
+
async financialStatementYears(context) {
|
|
12
12
|
const { domain } = context.state;
|
|
13
|
-
|
|
14
|
-
where: { domain: { id: domain.id }
|
|
13
|
+
const rows = await (0, shell_1.getRepository)(financial_statement_1.FinancialStatement).find({
|
|
14
|
+
where: { domain: { id: domain.id } },
|
|
15
|
+
select: ['fiscalYear']
|
|
15
16
|
});
|
|
17
|
+
return [...new Set(rows.map(row => row.fiscalYear))].sort((a, b) => b - a);
|
|
16
18
|
}
|
|
17
|
-
async financialStatements(
|
|
19
|
+
async financialStatements(fiscalYear, context) {
|
|
18
20
|
const { domain } = context.state;
|
|
19
|
-
|
|
20
|
-
domain,
|
|
21
|
-
|
|
22
|
-
repository: await (0, shell_1.getRepository)(financial_statement_1.FinancialStatement),
|
|
23
|
-
searchables: ['name', 'description']
|
|
21
|
+
return await (0, shell_1.getRepository)(financial_statement_1.FinancialStatement).find({
|
|
22
|
+
where: { domain: { id: domain.id }, fiscalYear },
|
|
23
|
+
order: { kind: 'ASC' }
|
|
24
24
|
});
|
|
25
|
-
const [items, total] = await queryBuilder.getManyAndCount();
|
|
26
|
-
return { items, total };
|
|
27
25
|
}
|
|
28
|
-
async
|
|
29
|
-
return await (0, shell_1.getRepository)(
|
|
26
|
+
async lines(statement) {
|
|
27
|
+
return await (0, shell_1.getRepository)(financial_statement_line_1.FinancialStatementLine).find({
|
|
28
|
+
where: { statement: { id: statement.id } },
|
|
29
|
+
order: { code: 'ASC' }
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
async domain(statement) {
|
|
33
|
+
return await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: statement.domainId });
|
|
30
34
|
}
|
|
31
|
-
async
|
|
32
|
-
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id:
|
|
35
|
+
async creator(statement) {
|
|
36
|
+
return statement.creatorId ? await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: statement.creatorId }) : null;
|
|
33
37
|
}
|
|
34
|
-
async
|
|
35
|
-
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id:
|
|
38
|
+
async updater(statement) {
|
|
39
|
+
return statement.updaterId ? await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: statement.updaterId }) : null;
|
|
36
40
|
}
|
|
37
41
|
};
|
|
38
42
|
exports.FinancialStatementQuery = FinancialStatementQuery;
|
|
39
43
|
tslib_1.__decorate([
|
|
40
44
|
(0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "query", domainOwnerGranted: true)'),
|
|
41
|
-
(0, type_graphql_1.Query)(returns =>
|
|
42
|
-
tslib_1.__param(0, (0, type_graphql_1.
|
|
43
|
-
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
45
|
+
(0, type_graphql_1.Query)(returns => [type_graphql_1.Int], { description: 'The fiscal years with a filed statement, the latest first' }),
|
|
46
|
+
tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
|
|
44
47
|
tslib_1.__metadata("design:type", Function),
|
|
45
|
-
tslib_1.__metadata("design:paramtypes", [
|
|
48
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
46
49
|
tslib_1.__metadata("design:returntype", Promise)
|
|
47
|
-
], FinancialStatementQuery.prototype, "
|
|
50
|
+
], FinancialStatementQuery.prototype, "financialStatementYears", null);
|
|
48
51
|
tslib_1.__decorate([
|
|
49
52
|
(0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "query", domainOwnerGranted: true)'),
|
|
50
|
-
(0, type_graphql_1.Query)(returns =>
|
|
51
|
-
tslib_1.__param(0, (0, type_graphql_1.
|
|
53
|
+
(0, type_graphql_1.Query)(returns => [financial_statement_1.FinancialStatement], { description: 'The statements filed for a fiscal year' }),
|
|
54
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('fiscalYear', type => type_graphql_1.Int)),
|
|
52
55
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
53
56
|
tslib_1.__metadata("design:type", Function),
|
|
54
|
-
tslib_1.__metadata("design:paramtypes", [
|
|
57
|
+
tslib_1.__metadata("design:paramtypes", [Number, Object]),
|
|
55
58
|
tslib_1.__metadata("design:returntype", Promise)
|
|
56
59
|
], FinancialStatementQuery.prototype, "financialStatements", null);
|
|
60
|
+
tslib_1.__decorate([
|
|
61
|
+
(0, type_graphql_1.FieldResolver)(type => [financial_statement_line_1.FinancialStatementLine]),
|
|
62
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
63
|
+
tslib_1.__metadata("design:type", Function),
|
|
64
|
+
tslib_1.__metadata("design:paramtypes", [financial_statement_1.FinancialStatement]),
|
|
65
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
66
|
+
], FinancialStatementQuery.prototype, "lines", null);
|
|
57
67
|
tslib_1.__decorate([
|
|
58
68
|
(0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
|
|
59
69
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
@@ -62,19 +72,19 @@ tslib_1.__decorate([
|
|
|
62
72
|
tslib_1.__metadata("design:returntype", Promise)
|
|
63
73
|
], FinancialStatementQuery.prototype, "domain", null);
|
|
64
74
|
tslib_1.__decorate([
|
|
65
|
-
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
|
|
75
|
+
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User, { nullable: true }),
|
|
66
76
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
67
77
|
tslib_1.__metadata("design:type", Function),
|
|
68
78
|
tslib_1.__metadata("design:paramtypes", [financial_statement_1.FinancialStatement]),
|
|
69
79
|
tslib_1.__metadata("design:returntype", Promise)
|
|
70
|
-
], FinancialStatementQuery.prototype, "
|
|
80
|
+
], FinancialStatementQuery.prototype, "creator", null);
|
|
71
81
|
tslib_1.__decorate([
|
|
72
|
-
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
|
|
82
|
+
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User, { nullable: true }),
|
|
73
83
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
74
84
|
tslib_1.__metadata("design:type", Function),
|
|
75
85
|
tslib_1.__metadata("design:paramtypes", [financial_statement_1.FinancialStatement]),
|
|
76
86
|
tslib_1.__metadata("design:returntype", Promise)
|
|
77
|
-
], FinancialStatementQuery.prototype, "
|
|
87
|
+
], FinancialStatementQuery.prototype, "updater", null);
|
|
78
88
|
exports.FinancialStatementQuery = FinancialStatementQuery = tslib_1.__decorate([
|
|
79
89
|
(0, type_graphql_1.Resolver)(financial_statement_1.FinancialStatement)
|
|
80
90
|
], FinancialStatementQuery);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"financial-statement-query.js","sourceRoot":"","sources":["../../../server/service/financial-statement/financial-statement-query.ts"],"names":[],"mappings":";;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"financial-statement-query.js","sourceRoot":"","sources":["../../../server/service/financial-statement/financial-statement-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA6F;AAE7F,iDAA6D;AAC7D,yDAAgD;AAEhD,+DAA0D;AAC1D,yEAAmE;AAG5D,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAG5B,AAAN,KAAK,CAAC,uBAAuB,CAAQ,OAAwB;QAC3D,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAChC,MAAM,IAAI,GAAG,MAAM,IAAA,qBAAa,EAAC,wCAAkB,CAAC,CAAC,IAAI,CAAC;YACxD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE;YACpC,MAAM,EAAE,CAAC,YAAY,CAAC;SACvB,CAAC,CAAA;QAEF,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IAC5E,CAAC;IAIK,AAAN,KAAK,CAAC,mBAAmB,CACS,UAAkB,EAC3C,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,OAAO,MAAM,IAAA,qBAAa,EAAC,wCAAkB,CAAC,CAAC,IAAI,CAAC;YAClD,KAAK,EAAE,EAAE,MA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AAE,WAAW,EAAE,2DAA2D,EAAE,CAAC;IACvE,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;sEAQnC;AAIK;IAFL,IAAA,wBAAS,EAAC,kFAAkF,CAAC;IAC7F,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC,wCAAkB,CAAC,EAAE,EAAE,WAAW,EAAE,wCAAwC,EAAE,CAAC;IAE/F,mBAAA,IAAA,kBAAG,EAAC,YAAY,EAAE,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC,CAAA;IAC9B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;kEAQP;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,iDAAsB,CAAC,CAAC;IACnC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAY,wCAAkB;;oDAKhD;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAY,wCAAkB;;qDAEjD;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAY,wCAAkB;;sDAElD;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAY,wCAAkB;;sDAElD;kCAhDU,uBAAuB;IADnC,IAAA,uBAAQ,EAAC,wCAAkB,CAAC;GAChB,uBAAuB,CAiDnC","sourcesContent":["import { Resolver, Query, FieldResolver, Root, Arg, Ctx, Directive, Int } from 'type-graphql'\n\nimport { Domain, getRepository } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\n\nimport { FinancialStatement } from './financial-statement'\nimport { FinancialStatementLine } from './financial-statement-line'\n\n@Resolver(FinancialStatement)\nexport class FinancialStatementQuery {\n @Directive('@privilege(category: \"accounting\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => [Int], { description: 'The fiscal years with a filed statement, the latest first' })\n async financialStatementYears(@Ctx() context: ResolverContext): Promise<number[]> {\n const { domain } = context.state\n const rows = await getRepository(FinancialStatement).find({\n where: { domain: { id: domain.id } },\n select: ['fiscalYear']\n })\n\n return [...new Set(rows.map(row => row.fiscalYear))].sort((a, b) => b - a)\n }\n\n @Directive('@privilege(category: \"accounting\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => [FinancialStatement], { description: 'The statements filed for a fiscal year' })\n async financialStatements(\n @Arg('fiscalYear', type => Int) fiscalYear: number,\n @Ctx() context: ResolverContext\n ): Promise<FinancialStatement[]> {\n const { domain } = context.state\n\n return await getRepository(FinancialStatement).find({\n where: { domain: { id: domain.id }, fiscalYear },\n order: { kind: 'ASC' }\n })\n }\n\n @FieldResolver(type => [FinancialStatementLine])\n async lines(@Root() statement: FinancialStatement): Promise<FinancialStatementLine[]> {\n return await getRepository(FinancialStatementLine).find({\n where: { statement: { id: statement.id } },\n order: { code: 'ASC' }\n })\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() statement: FinancialStatement): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: statement.domainId })\n }\n\n @FieldResolver(type => User, { nullable: true })\n async creator(@Root() statement: FinancialStatement): Promise<User | null> {\n return statement.creatorId ? await getRepository(User).findOneBy({ id: statement.creatorId }) : null\n }\n\n @FieldResolver(type => User, { nullable: true })\n async updater(@Root() statement: FinancialStatement): Promise<User | null> {\n return statement.updaterId ? await getRepository(User).findOneBy({ id: statement.updaterId }) : null\n }\n}\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { EntityManager } from 'typeorm';
|
|
2
|
+
import { FinancialStatement, FinancialStatementKind } from './financial-statement';
|
|
3
|
+
export interface FiledStatement {
|
|
4
|
+
fiscalYear: number;
|
|
5
|
+
kind: FinancialStatementKind;
|
|
6
|
+
periodFrom?: string | null;
|
|
7
|
+
periodTo?: string | null;
|
|
8
|
+
filingKind?: string | null;
|
|
9
|
+
filedOn?: string | null;
|
|
10
|
+
issueNo?: string | null;
|
|
11
|
+
source?: string | null;
|
|
12
|
+
notes?: string | null;
|
|
13
|
+
lines: {
|
|
14
|
+
code: string;
|
|
15
|
+
name: string;
|
|
16
|
+
amount: number;
|
|
17
|
+
rank?: number;
|
|
18
|
+
level?: number;
|
|
19
|
+
contra?: boolean;
|
|
20
|
+
}[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Record a filed statement. The one of the same year and kind it replaces is deleted (softly), lines and all.
|
|
24
|
+
* Returns whether one was replaced.
|
|
25
|
+
*/
|
|
26
|
+
export declare function saveFiledStatement(tx: EntityManager, domain: {
|
|
27
|
+
id: string;
|
|
28
|
+
}, user: any, filed: FiledStatement): Promise<{
|
|
29
|
+
statement: FinancialStatement;
|
|
30
|
+
replaced: boolean;
|
|
31
|
+
}>;
|
|
32
|
+
/** Delete statements (softly), lines and all. */
|
|
33
|
+
export declare function deleteStatements(tx: EntityManager, statements: FinancialStatement[]): Promise<void>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.saveFiledStatement = saveFiledStatement;
|
|
4
|
+
exports.deleteStatements = deleteStatements;
|
|
5
|
+
const shell_1 = require("@things-factory/shell");
|
|
6
|
+
const financial_statement_1 = require("./financial-statement");
|
|
7
|
+
const financial_statement_line_1 = require("./financial-statement-line");
|
|
8
|
+
/**
|
|
9
|
+
* Record a filed statement. The one of the same year and kind it replaces is deleted (softly), lines and all.
|
|
10
|
+
* Returns whether one was replaced.
|
|
11
|
+
*/
|
|
12
|
+
async function saveFiledStatement(tx, domain, user, filed) {
|
|
13
|
+
if (!Number.isInteger(filed.fiscalYear))
|
|
14
|
+
throw new shell_1.Refusal('statement-year-required', {}, 'fiscalYear: the year it is of');
|
|
15
|
+
if (!Object.values(financial_statement_1.FinancialStatementKind).includes(filed.kind))
|
|
16
|
+
throw new shell_1.Refusal('statement-kind-unknown', { kind: filed.kind ?? '' }, 'kind: which statement');
|
|
17
|
+
const codes = filed.lines.map(line => line.code);
|
|
18
|
+
if (new Set(codes).size !== codes.length)
|
|
19
|
+
throw new shell_1.Refusal('statement-line-code-twice', {}, 'a line code appears twice');
|
|
20
|
+
const statements = tx.getRepository(financial_statement_1.FinancialStatement);
|
|
21
|
+
const lines = tx.getRepository(financial_statement_line_1.FinancialStatementLine);
|
|
22
|
+
const previous = await statements.findOne({
|
|
23
|
+
where: { domain: { id: domain.id }, fiscalYear: filed.fiscalYear, kind: filed.kind }
|
|
24
|
+
});
|
|
25
|
+
if (previous)
|
|
26
|
+
await deleteStatements(tx, [previous]);
|
|
27
|
+
const { lines: filedLines, ...fields } = filed;
|
|
28
|
+
const statement = await statements.save({ ...fields, domain, creator: user, updater: user });
|
|
29
|
+
await lines.save(filedLines.map(line => ({ ...line, domain, statement: { id: statement.id }, creator: user, updater: user })));
|
|
30
|
+
return { statement, replaced: !!previous };
|
|
31
|
+
}
|
|
32
|
+
/** Delete statements (softly), lines and all. */
|
|
33
|
+
async function deleteStatements(tx, statements) {
|
|
34
|
+
if (!statements.length)
|
|
35
|
+
return;
|
|
36
|
+
const lines = tx.getRepository(financial_statement_line_1.FinancialStatementLine);
|
|
37
|
+
for (const statement of statements) {
|
|
38
|
+
const old = await lines.find({ where: { statement: { id: statement.id } }, select: ['id'] });
|
|
39
|
+
if (old.length)
|
|
40
|
+
await lines.softDelete(old.map(line => line.id));
|
|
41
|
+
}
|
|
42
|
+
await tx.getRepository(financial_statement_1.FinancialStatement).softDelete(statements.map(statement => statement.id));
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=financial-statement-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"financial-statement-service.js","sourceRoot":"","sources":["../../../server/service/financial-statement/financial-statement-service.ts"],"names":[],"mappings":";;AAwBA,gDA+BC;AAGD,4CAQC;AAhED,iDAA+C;AAE/C,+DAAkF;AAClF,yEAAmE;AAenE;;;GAGG;AACI,KAAK,UAAU,kBAAkB,CACtC,EAAiB,EACjB,MAAsB,EACtB,IAAS,EACT,KAAqB;IAErB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC;QACrC,MAAM,IAAI,eAAO,CAAC,yBAAyB,EAAE,EAAE,EAAE,+BAA+B,CAAC,CAAA;IACnF,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,4CAAsB,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;QAC7D,MAAM,IAAI,eAAO,CAAC,wBAAwB,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,EAAE,EAAE,EAAE,uBAAuB,CAAC,CAAA;IAClG,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAChD,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,MAAM;QACtC,MAAM,IAAI,eAAO,CAAC,2BAA2B,EAAE,EAAE,EAAE,2BAA2B,CAAC,CAAA;IAEjF,MAAM,UAAU,GAAG,EAAE,CAAC,aAAa,CAAC,wCAAkB,CAAC,CAAA;IACvD,MAAM,KAAK,GAAG,EAAE,CAAC,aAAa,CAAC,iDAAsB,CAAC,CAAA;IACtD,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;QACxC,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE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AC,EAAE,CAAC,CAAC,CAAA;IAClE,CAAC;IACD,MAAM,EAAE,CAAC,aAAa,CAAC,wCAAkB,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAA;AAClG,CAAC","sourcesContent":["import { EntityManager } from 'typeorm'\n\nimport { Refusal } from '@things-factory/shell'\n\nimport { FinancialStatement, FinancialStatementKind } from './financial-statement'\nimport { FinancialStatementLine } from './financial-statement-line'\n\nexport interface FiledStatement {\n fiscalYear: number\n kind: FinancialStatementKind\n periodFrom?: string | null\n periodTo?: string | null\n filingKind?: string | null\n filedOn?: string | null\n issueNo?: string | null\n source?: string | null\n notes?: string | null\n lines: { code: string; name: string; amount: number; rank?: number; level?: number; contra?: boolean }[]\n}\n\n/**\n * Record a filed statement. The one of the same year and kind it replaces is deleted (softly), lines and all.\n * Returns whether one was replaced.\n */\nexport async function saveFiledStatement(\n tx: EntityManager,\n domain: { id: string },\n user: any,\n filed: FiledStatement\n): Promise<{ statement: FinancialStatement; replaced: boolean }> {\n if (!Number.isInteger(filed.fiscalYear))\n throw new Refusal('statement-year-required', {}, 'fiscalYear: the year it is of')\n if (!Object.values(FinancialStatementKind).includes(filed.kind))\n throw new Refusal('statement-kind-unknown', { kind: filed.kind ?? '' }, 'kind: which statement')\n const codes = filed.lines.map(line => line.code)\n if (new Set(codes).size !== codes.length)\n throw new Refusal('statement-line-code-twice', {}, 'a line code appears twice')\n\n const statements = tx.getRepository(FinancialStatement)\n const lines = tx.getRepository(FinancialStatementLine)\n const previous = await statements.findOne({\n where: { domain: { id: domain.id }, fiscalYear: filed.fiscalYear, kind: filed.kind }\n })\n if (previous) await deleteStatements(tx, [previous])\n\n const { lines: filedLines, ...fields } = filed\n const statement = await statements.save({ ...fields, domain, creator: user, updater: user } as FinancialStatement)\n await lines.save(\n filedLines.map(\n line =>\n ({ ...line, domain, statement: { id: statement.id }, creator: user, updater: user }) as FinancialStatementLine\n )\n )\n\n return { statement, replaced: !!previous }\n}\n\n/** Delete statements (softly), lines and all. */\nexport async function deleteStatements(tx: EntityManager, statements: FinancialStatement[]): Promise<void> {\n if (!statements.length) return\n const lines = tx.getRepository(FinancialStatementLine)\n for (const statement of statements) {\n const old = await lines.find({ where: { statement: { id: statement.id } }, select: ['id'] })\n if (old.length) await lines.softDelete(old.map(line => line.id))\n }\n await tx.getRepository(FinancialStatement).softDelete(statements.map(statement => statement.id))\n}\n"]}
|
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
import { Domain } from '@things-factory/shell';
|
|
2
2
|
import { User } from '@things-factory/auth-base';
|
|
3
|
-
import {
|
|
4
|
-
export declare enum
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import { FinancialStatementLine } from './financial-statement-line';
|
|
4
|
+
export declare enum FinancialStatementKind {
|
|
5
|
+
BALANCE_SHEET = "BALANCE_SHEET",
|
|
6
|
+
INCOME_STATEMENT = "INCOME_STATEMENT",
|
|
7
|
+
COST_OF_GOODS = "COST_OF_GOODS"
|
|
7
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* A financial statement of a fiscal year, line by line, as it was filed. Filing it again replaces it; what the books
|
|
11
|
+
* moved on the same lines is read beside it, not kept.
|
|
12
|
+
*/
|
|
8
13
|
export declare class FinancialStatement {
|
|
9
14
|
readonly id: string;
|
|
10
15
|
version?: number;
|
|
11
16
|
domain?: Domain;
|
|
12
17
|
domainId?: string;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
fiscalYear: number;
|
|
19
|
+
kind: FinancialStatementKind;
|
|
20
|
+
periodFrom?: string;
|
|
21
|
+
periodTo?: string;
|
|
22
|
+
filingKind?: string;
|
|
23
|
+
filedOn?: string;
|
|
24
|
+
issueNo?: string;
|
|
25
|
+
source?: string;
|
|
26
|
+
notes?: string;
|
|
27
|
+
lines?: FinancialStatementLine[];
|
|
20
28
|
createdAt?: Date;
|
|
21
29
|
updatedAt?: Date;
|
|
22
30
|
deletedAt?: Date;
|