@mj-biz-apps/accounting-entities 0.1.0
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/LICENSE +183 -0
- package/dist/JournalEntryEntity.d.ts +50 -0
- package/dist/JournalEntryEntity.d.ts.map +1 -0
- package/dist/JournalEntryEntity.js +113 -0
- package/dist/JournalEntryEntity.js.map +1 -0
- package/dist/JournalEntryLineEntity.d.ts +39 -0
- package/dist/JournalEntryLineEntity.d.ts.map +1 -0
- package/dist/JournalEntryLineEntity.js +96 -0
- package/dist/JournalEntryLineEntity.js.map +1 -0
- package/dist/generated/entity_subclasses.d.ts +4723 -0
- package/dist/generated/entity_subclasses.d.ts.map +1 -0
- package/dist/generated/entity_subclasses.js +6962 -0
- package/dist/generated/entity_subclasses.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/package.json +37 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
License text copyright (c) 2024 MariaDB plc, All Rights Reserved.
|
|
4
|
+
"Business Source License" is a trademark of MariaDB plc.
|
|
5
|
+
|
|
6
|
+
-----------------------------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
Parameters
|
|
9
|
+
|
|
10
|
+
Licensor: Blue Cypress, Inc.
|
|
11
|
+
|
|
12
|
+
Licensed Work: MemberJunction.
|
|
13
|
+
The Licensed Work is (c) 2023-2026 Blue Cypress, Inc.
|
|
14
|
+
|
|
15
|
+
Additional Use Grant: Subject to the terms of this License, Licensor grants
|
|
16
|
+
you the following additional rights to make Production
|
|
17
|
+
Use of the Licensed Work.
|
|
18
|
+
|
|
19
|
+
1. Internal Use
|
|
20
|
+
|
|
21
|
+
You may make production use of the Licensed Work for
|
|
22
|
+
your own internal business or organizational operations.
|
|
23
|
+
|
|
24
|
+
2. Nonprofit Use
|
|
25
|
+
|
|
26
|
+
If you are a Nonprofit, you may make production use of
|
|
27
|
+
the Licensed Work for the operations and activities of
|
|
28
|
+
your Organizational Family.
|
|
29
|
+
|
|
30
|
+
3. MemberJunction Certified Program Use
|
|
31
|
+
|
|
32
|
+
If you are authorized by Licensor under the
|
|
33
|
+
MemberJunction Certified Program to provide professional
|
|
34
|
+
services using the Licensed Work, you may make
|
|
35
|
+
production use of the Licensed Work in providing such
|
|
36
|
+
professional services to a client, provided that:
|
|
37
|
+
|
|
38
|
+
(a) the Licensed Work is deployed in, and the applicable
|
|
39
|
+
production use occurs within, an environment owned,
|
|
40
|
+
leased, licensed, subscribed to, or otherwise controlled
|
|
41
|
+
by that client; and
|
|
42
|
+
|
|
43
|
+
(b) the production use is for that client's own internal
|
|
44
|
+
business or organizational operations or is otherwise
|
|
45
|
+
independently permitted to that client under this
|
|
46
|
+
Additional Use Grant.
|
|
47
|
+
|
|
48
|
+
4. Definitions Applicable to the Additional Use Grant
|
|
49
|
+
|
|
50
|
+
"Affiliate" means, with respect to a specified Person,
|
|
51
|
+
any other Person that directly or indirectly Controls,
|
|
52
|
+
is Controlled by, or is under common Control with such
|
|
53
|
+
specified Person.
|
|
54
|
+
|
|
55
|
+
"Control" (including the terms "Controls," "Controlled
|
|
56
|
+
by," and "under common Control with") means the direct
|
|
57
|
+
or indirect possession of the power to direct or cause
|
|
58
|
+
the direction of the management and policies of a
|
|
59
|
+
Person, whether through ownership of voting interests,
|
|
60
|
+
by contract, or otherwise.
|
|
61
|
+
|
|
62
|
+
"Organizational Family" means, with respect to a Person,
|
|
63
|
+
(a) such Person and its Affiliates, and (b) any
|
|
64
|
+
nonprofit organization, governmental entity, chapter,
|
|
65
|
+
division, local affiliate, regional affiliate, state
|
|
66
|
+
affiliate, national affiliate, or other entity that is
|
|
67
|
+
formally affiliated with such Person through governing
|
|
68
|
+
documents, a charter, bylaws, a membership agreement, or
|
|
69
|
+
another written organizational instrument, and is
|
|
70
|
+
recognized under such documents as part of the same
|
|
71
|
+
organizational structure.
|
|
72
|
+
|
|
73
|
+
"Nonprofit" means a Person recognized by the Internal
|
|
74
|
+
Revenue Service as exempt from federal income taxation
|
|
75
|
+
under Section 501(c)(3), 501(c)(4), 501(c)(5), or
|
|
76
|
+
501(c)(6) of the Internal Revenue Code, or a foreign
|
|
77
|
+
organization recognized under substantially equivalent
|
|
78
|
+
laws.
|
|
79
|
+
|
|
80
|
+
A Person claiming eligibility as a Nonprofit shall, upon
|
|
81
|
+
Licensor's reasonable request, provide documentation
|
|
82
|
+
reasonably sufficient to demonstrate that it qualifies
|
|
83
|
+
as a Nonprofit. If such Person materially misrepresents,
|
|
84
|
+
or is unable to demonstrate, its qualification as a
|
|
85
|
+
Nonprofit, the rights granted to such Person under
|
|
86
|
+
Section 2 of this Additional Use Grant shall terminate.
|
|
87
|
+
|
|
88
|
+
"MemberJunction Certified Program" means Licensor's
|
|
89
|
+
then-current program for certifying and authorizing a
|
|
90
|
+
Person to provide professional services using the
|
|
91
|
+
Licensed Work.
|
|
92
|
+
|
|
93
|
+
"Person" means any individual, corporation, limited
|
|
94
|
+
liability company, partnership, association, nonprofit
|
|
95
|
+
organization, governmental entity, or other legal or
|
|
96
|
+
organizational entity.
|
|
97
|
+
|
|
98
|
+
Change Date: Four (4) years from the date the Licensed Work is first
|
|
99
|
+
made available.
|
|
100
|
+
|
|
101
|
+
Change License: MIT License.
|
|
102
|
+
|
|
103
|
+
For information about alternative licensing arrangements for the Licensed
|
|
104
|
+
Work, please contact Blue Cypress, Inc.
|
|
105
|
+
|
|
106
|
+
-----------------------------------------------------------------------------
|
|
107
|
+
|
|
108
|
+
Terms
|
|
109
|
+
|
|
110
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
111
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
112
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
113
|
+
production use.
|
|
114
|
+
|
|
115
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
116
|
+
available distribution of a specific version of the Licensed Work under this
|
|
117
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
118
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
119
|
+
above terminate.
|
|
120
|
+
|
|
121
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
122
|
+
currently in effect as described in this License, you must purchase a
|
|
123
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
124
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
125
|
+
|
|
126
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
127
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
128
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
129
|
+
for each version of the Licensed Work released by Licensor.
|
|
130
|
+
|
|
131
|
+
You must conspicuously display this License on each original or modified copy
|
|
132
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
133
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
134
|
+
License apply to your use of that work.
|
|
135
|
+
|
|
136
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
137
|
+
terminate your rights under this License for the current and all other
|
|
138
|
+
versions of the Licensed Work.
|
|
139
|
+
|
|
140
|
+
This License does not grant you any right in any trademark or logo of
|
|
141
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
142
|
+
Licensor as expressly required by this License).
|
|
143
|
+
|
|
144
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
145
|
+
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
146
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
147
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
148
|
+
TITLE.
|
|
149
|
+
|
|
150
|
+
MariaDB hereby grants you permission to use this License's text to license
|
|
151
|
+
your works, and to refer to it using the trademark "Business Source License",
|
|
152
|
+
as long as you comply with the Covenants of Licensor below.
|
|
153
|
+
|
|
154
|
+
-----------------------------------------------------------------------------
|
|
155
|
+
|
|
156
|
+
Covenants of Licensor
|
|
157
|
+
|
|
158
|
+
In consideration of the right to use this License's text and the "Business
|
|
159
|
+
Source License" name and trademark, Licensor covenants to MariaDB, and to all
|
|
160
|
+
other recipients of the licensed work to be provided by Licensor:
|
|
161
|
+
|
|
162
|
+
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
|
163
|
+
or a license that is compatible with GPL Version 2.0 or a later version,
|
|
164
|
+
where "compatible" means that software provided under the Change License
|
|
165
|
+
can be included in a program with software provided under GPL Version 2.0
|
|
166
|
+
or a later version. Licensor may specify additional Change Licenses without
|
|
167
|
+
limitation.
|
|
168
|
+
|
|
169
|
+
2. To either: (a) specify an additional grant of rights to use that does not
|
|
170
|
+
impose any additional restriction on the right granted in this License, as
|
|
171
|
+
the Additional Use Grant; or (b) insert the text "None".
|
|
172
|
+
|
|
173
|
+
3. To specify a Change Date.
|
|
174
|
+
|
|
175
|
+
4. Not to modify this License in any other way.
|
|
176
|
+
|
|
177
|
+
-----------------------------------------------------------------------------
|
|
178
|
+
|
|
179
|
+
Notice
|
|
180
|
+
|
|
181
|
+
The Business Source License (this document, or the "License") is not an Open
|
|
182
|
+
Source license. However, the Licensed Work will eventually be made available
|
|
183
|
+
under an Open Source License, as stated in this License.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview `JournalEntryEntity` — the double-entry rules, on BOTH tiers.
|
|
3
|
+
*
|
|
4
|
+
* WHY THIS LAYER EXISTS
|
|
5
|
+
*
|
|
6
|
+
* Every journal-entry rule lived in `JournalEntryEntityServer`, in a server-only package, alongside
|
|
7
|
+
* a hand-rolled child collection (`_lines`, `_deletedLines`, `AddLine`, `RemoveLine`, `CreateLine`,
|
|
8
|
+
* `LoadLines`). The browser could not model an entry at all, so the JE editor reached through an
|
|
9
|
+
* Angular service layer to compose something it had no type for — and learned an entry was
|
|
10
|
+
* unbalanced only after a round trip.
|
|
11
|
+
*
|
|
12
|
+
* The rules now split by what they NEED rather than where they were written:
|
|
13
|
+
*
|
|
14
|
+
* · Here — decidable from the entry and its lines alone. No database, no provider. Runs in the
|
|
15
|
+
* browser before a round trip, and again on the server, because the server subclass extends
|
|
16
|
+
* this one and `super.Validate()` still fires.
|
|
17
|
+
* · `JournalEntryEntityServer` — anything requiring the database: entry numbering, fiscal-year
|
|
18
|
+
* derivation, the reversal-type discriminator, GL account existence and company scoping.
|
|
19
|
+
*
|
|
20
|
+
* `ClassFactory` priority auto-increments by load order, so the server subclass wins server-side
|
|
21
|
+
* with no configuration while the browser resolves to this one and keeps the `Lines` collection the
|
|
22
|
+
* generated class declares.
|
|
23
|
+
*
|
|
24
|
+
* @module @mj-biz-apps/accounting-entities
|
|
25
|
+
*/
|
|
26
|
+
import { ValidationResult } from '@memberjunction/core';
|
|
27
|
+
import { mjBizAppsAccountingJournalEntryEntity } from './generated/entity_subclasses.js';
|
|
28
|
+
export declare class JournalEntryEntity extends mjBizAppsAccountingJournalEntryEntity {
|
|
29
|
+
/**
|
|
30
|
+
* Whether the line set is KNOWN, as opposed to merely empty.
|
|
31
|
+
*
|
|
32
|
+
* An empty collection means "no lines" only when there cannot be any on disk: an entry that was
|
|
33
|
+
* never saved, or one whose collection was actually loaded. On a saved entry with an unloaded
|
|
34
|
+
* collection, empty means "unknown" — and counting it as zero would reject a perfectly good
|
|
35
|
+
* entry whose lines are sitting in the table.
|
|
36
|
+
*
|
|
37
|
+
* `IsLoaded` alone is not the test, because `Add()` does not mark a collection loaded: an entry
|
|
38
|
+
* composed in the browser has lines and `IsLoaded === false`.
|
|
39
|
+
*/
|
|
40
|
+
protected get LinesAreKnown(): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* The double-entry invariants, over the complete line set, before anything is written.
|
|
43
|
+
*
|
|
44
|
+
* `super.Validate()` fans out to the `Lines` collection, so each line's own `Validate()` runs
|
|
45
|
+
* here too and its failures arrive attributed by position (`Lines[3].DebitAmount`). That
|
|
46
|
+
* replaces a hand-written per-line loop that existed only on the server.
|
|
47
|
+
*/
|
|
48
|
+
Validate(): ValidationResult;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=JournalEntryEntity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JournalEntryEntity.d.ts","sourceRoot":"","sources":["../src/JournalEntryEntity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAmC,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAEzF,OAAO,EAAE,qCAAqC,EAAE,MAAM,+BAA+B,CAAC;AAGtF,qBACa,kBAAmB,SAAQ,qCAAqC;IACzE;;;;;;;;;;OAUG;IACH,SAAS,KAAK,aAAa,IAAI,OAAO,CAErC;IAED;;;;;;OAMG;IACa,QAAQ,IAAI,gBAAgB;CAqE/C"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* @fileoverview `JournalEntryEntity` — the double-entry rules, on BOTH tiers.
|
|
9
|
+
*
|
|
10
|
+
* WHY THIS LAYER EXISTS
|
|
11
|
+
*
|
|
12
|
+
* Every journal-entry rule lived in `JournalEntryEntityServer`, in a server-only package, alongside
|
|
13
|
+
* a hand-rolled child collection (`_lines`, `_deletedLines`, `AddLine`, `RemoveLine`, `CreateLine`,
|
|
14
|
+
* `LoadLines`). The browser could not model an entry at all, so the JE editor reached through an
|
|
15
|
+
* Angular service layer to compose something it had no type for — and learned an entry was
|
|
16
|
+
* unbalanced only after a round trip.
|
|
17
|
+
*
|
|
18
|
+
* The rules now split by what they NEED rather than where they were written:
|
|
19
|
+
*
|
|
20
|
+
* · Here — decidable from the entry and its lines alone. No database, no provider. Runs in the
|
|
21
|
+
* browser before a round trip, and again on the server, because the server subclass extends
|
|
22
|
+
* this one and `super.Validate()` still fires.
|
|
23
|
+
* · `JournalEntryEntityServer` — anything requiring the database: entry numbering, fiscal-year
|
|
24
|
+
* derivation, the reversal-type discriminator, GL account existence and company scoping.
|
|
25
|
+
*
|
|
26
|
+
* `ClassFactory` priority auto-increments by load order, so the server subclass wins server-side
|
|
27
|
+
* with no configuration while the browser resolves to this one and keeps the `Lines` collection the
|
|
28
|
+
* generated class declares.
|
|
29
|
+
*
|
|
30
|
+
* @module @mj-biz-apps/accounting-entities
|
|
31
|
+
*/
|
|
32
|
+
import { BaseEntity, ValidationErrorInfo } from '@memberjunction/core';
|
|
33
|
+
import { RegisterClass } from '@memberjunction/global';
|
|
34
|
+
import { mjBizAppsAccountingJournalEntryEntity } from './generated/entity_subclasses.js';
|
|
35
|
+
let JournalEntryEntity = class JournalEntryEntity extends mjBizAppsAccountingJournalEntryEntity {
|
|
36
|
+
/**
|
|
37
|
+
* Whether the line set is KNOWN, as opposed to merely empty.
|
|
38
|
+
*
|
|
39
|
+
* An empty collection means "no lines" only when there cannot be any on disk: an entry that was
|
|
40
|
+
* never saved, or one whose collection was actually loaded. On a saved entry with an unloaded
|
|
41
|
+
* collection, empty means "unknown" — and counting it as zero would reject a perfectly good
|
|
42
|
+
* entry whose lines are sitting in the table.
|
|
43
|
+
*
|
|
44
|
+
* `IsLoaded` alone is not the test, because `Add()` does not mark a collection loaded: an entry
|
|
45
|
+
* composed in the browser has lines and `IsLoaded === false`.
|
|
46
|
+
*/
|
|
47
|
+
get LinesAreKnown() {
|
|
48
|
+
return !this.IsSaved || this.Lines.IsLoaded || this.Lines.Count > 0;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The double-entry invariants, over the complete line set, before anything is written.
|
|
52
|
+
*
|
|
53
|
+
* `super.Validate()` fans out to the `Lines` collection, so each line's own `Validate()` runs
|
|
54
|
+
* here too and its failures arrive attributed by position (`Lines[3].DebitAmount`). That
|
|
55
|
+
* replaces a hand-written per-line loop that existed only on the server.
|
|
56
|
+
*/
|
|
57
|
+
Validate() {
|
|
58
|
+
const result = super.Validate();
|
|
59
|
+
if (!this.LinesAreKnown) {
|
|
60
|
+
return result; // the server subclass settles it against the database
|
|
61
|
+
}
|
|
62
|
+
const lines = this.Lines.Items;
|
|
63
|
+
// COUNT THE LINES SOMEBODY ACTUALLY TYPED IN.
|
|
64
|
+
//
|
|
65
|
+
// An editor opens with blank rows and keeps one at the bottom, so `Lines.Count` is never the
|
|
66
|
+
// number of lines the entry HAS. Counting them all would let an untouched two-row draft
|
|
67
|
+
// satisfy the double-entry rule with nothing on it — and the balance check would agree,
|
|
68
|
+
// because zero equals zero.
|
|
69
|
+
//
|
|
70
|
+
// Written as `!== true` rather than `!l.IsEmpty` DELIBERATELY. If the collection ever
|
|
71
|
+
// resolves to the generated class instead of this subclass — a registration that did not
|
|
72
|
+
// load, a host that imports the entities package differently — `IsEmpty` is `undefined`, and
|
|
73
|
+
// `!undefined` is `true`. Every line would read as blank and every entry in the system would
|
|
74
|
+
// be rejected as having no lines. This way the same accident makes lines count as REAL,
|
|
75
|
+
// which is the safe direction: a blank one still fails on its own rules a moment later.
|
|
76
|
+
const live = lines.filter((l) => l.IsEmpty !== true);
|
|
77
|
+
// A JE must have at least two lines — that is what double entry MEANS.
|
|
78
|
+
if (live.length < 2) {
|
|
79
|
+
result.Success = false;
|
|
80
|
+
result.Errors.push(new ValidationErrorInfo('Lines', `A Journal Entry must have at least 2 line items (double-entry invariant). Found ${live.length} line(s).`, null));
|
|
81
|
+
}
|
|
82
|
+
// EQUAL DEBITS AND CREDITS, COMPARED AT PENNY PRECISION.
|
|
83
|
+
//
|
|
84
|
+
// This was `totalDebits !== totalCredits` — exact float equality on accumulated sums — and
|
|
85
|
+
// it rejected entries that balance perfectly. A four-line entry of
|
|
86
|
+
//
|
|
87
|
+
// Dr AR 302.59 / Cr Sales 233.51 + Cr Tax 25.30 + Cr Shipping 43.78
|
|
88
|
+
//
|
|
89
|
+
// sums on the credit side to 302.59000000000003 in IEEE-754, so the comparison failed while
|
|
90
|
+
// the error message printed both sides as "302.59" — telling the caller two identical
|
|
91
|
+
// numbers were unequal. It stayed latent while entries had two or three lines and friendly
|
|
92
|
+
// amounts; the first four-line entry from bizapps-orders hit it.
|
|
93
|
+
//
|
|
94
|
+
// DebitAmount and CreditAmount are DECIMAL(18,2), so a penny IS the unit of account and
|
|
95
|
+
// anything finer is an artefact of summing in binary floating point. Half a penny is
|
|
96
|
+
// therefore the correct tolerance: tight enough that no real imbalance passes — the smallest
|
|
97
|
+
// storable discrepancy is a whole penny, two hundred times the epsilon — and loose enough
|
|
98
|
+
// that accumulation order cannot decide whether a balanced entry is accepted.
|
|
99
|
+
const totalDebits = lines.reduce((sum, l) => sum + (l.DebitAmount ?? 0), 0);
|
|
100
|
+
const totalCredits = lines.reduce((sum, l) => sum + (l.CreditAmount ?? 0), 0);
|
|
101
|
+
if (Math.abs(totalDebits - totalCredits) >= 0.005) {
|
|
102
|
+
result.Success = false;
|
|
103
|
+
result.Errors.push(new ValidationErrorInfo('Lines', `Unbalanced Journal Entry: total debits (${totalDebits.toFixed(2)}) must equal ` +
|
|
104
|
+
`total credits (${totalCredits.toFixed(2)}).`, null));
|
|
105
|
+
}
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
JournalEntryEntity = __decorate([
|
|
110
|
+
RegisterClass(BaseEntity, 'MJ_BizApps_Accounting: Journal Entries')
|
|
111
|
+
], JournalEntryEntity);
|
|
112
|
+
export { JournalEntryEntity };
|
|
113
|
+
//# sourceMappingURL=JournalEntryEntity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JournalEntryEntity.js","sourceRoot":"","sources":["../src/JournalEntryEntity.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAoB,MAAM,sBAAsB,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,qCAAqC,EAAE,MAAM,+BAA+B,CAAC;AAI/E,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,qCAAqC;IACzE;;;;;;;;;;OAUG;IACH,IAAc,aAAa;QACvB,OAAO,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC;IACxE,CAAC;IAED;;;;;;OAMG;IACa,QAAQ;QACpB,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;QAEhC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACtB,OAAO,MAAM,CAAC,CAAC,sDAAsD;QACzE,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAiC,CAAC;QAE3D,8CAA8C;QAC9C,EAAE;QACF,6FAA6F;QAC7F,wFAAwF;QACxF,wFAAwF;QACxF,4BAA4B;QAC5B,EAAE;QACF,sFAAsF;QACtF,yFAAyF;QACzF,6FAA6F;QAC7F,6FAA6F;QAC7F,wFAAwF;QACxF,wFAAwF;QACxF,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC;QAErD,uEAAuE;QACvE,IAAI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AAC,UAAU,EAAE,wCAAwC,CAAC;GACvD,kBAAkB,CA4F9B"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview `JournalEntryLineEntity` — the per-line debit/credit rules, on BOTH tiers.
|
|
3
|
+
*
|
|
4
|
+
* WHY THIS LAYER EXISTS
|
|
5
|
+
*
|
|
6
|
+
* These rules — an account is required, exactly one side carries an amount, neither side is
|
|
7
|
+
* negative — need nothing but the line itself. They lived in `JournalEntryLineEntityServer`, in a
|
|
8
|
+
* server-only package, so the browser could not run them; the JE workspace therefore carried a
|
|
9
|
+
* hand-written `lineIssue()` saying the same things in different words, and the two were free to
|
|
10
|
+
* drift. They did: the server's wording named `DebitAmount`, the screen's named "the debit column",
|
|
11
|
+
* and only one of them was ever updated when the rule changed.
|
|
12
|
+
*
|
|
13
|
+
* `super.Validate()` on the parent entry fans out to the `Lines` collection, so these run as part of
|
|
14
|
+
* the entry's own validation and arrive attributed by position — `Lines[3].DebitAmount` — which is
|
|
15
|
+
* what lets the editor put an error on the offending ROW rather than in a list above the grid.
|
|
16
|
+
*
|
|
17
|
+
* WHAT DELIBERATELY STAYED ON THE SERVER SUBCLASS. Anything that reads reference data: whether the
|
|
18
|
+
* GL account is active, whether it belongs to the entry's company, whether a dimension value belongs
|
|
19
|
+
* to the dimension it tags. The browser has a cache of those, but a cache is not an authority, and a
|
|
20
|
+
* rule enforced against a stale cache is worse than one enforced late.
|
|
21
|
+
*
|
|
22
|
+
* @module @mj-biz-apps/accounting-entities
|
|
23
|
+
*/
|
|
24
|
+
import { ValidationResult } from '@memberjunction/core';
|
|
25
|
+
import { mjBizAppsAccountingJournalEntryLineEntity } from './generated/entity_subclasses.js';
|
|
26
|
+
export declare class JournalEntryLineEntity extends mjBizAppsAccountingJournalEntryLineEntity {
|
|
27
|
+
/** How this line names itself in a message. Falls back to the id while the number is unassigned. */
|
|
28
|
+
protected get Label(): string;
|
|
29
|
+
/**
|
|
30
|
+
* True when the operator has not touched this row at all.
|
|
31
|
+
*
|
|
32
|
+
* An untouched row is not an error — the editor opens with two blank lines by design, and
|
|
33
|
+
* reporting "pick an account" against a row nobody has typed in is noise that trains people to
|
|
34
|
+
* ignore the error list. It is dropped at save rather than reported.
|
|
35
|
+
*/
|
|
36
|
+
get IsEmpty(): boolean;
|
|
37
|
+
Validate(): ValidationResult;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=JournalEntryLineEntity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JournalEntryLineEntity.d.ts","sourceRoot":"","sources":["../src/JournalEntryLineEntity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAmC,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAEzF,OAAO,EAAE,yCAAyC,EAAE,MAAM,+BAA+B,CAAC;AAE1F,qBACa,sBAAuB,SAAQ,yCAAyC;IACjF,oGAAoG;IACpG,SAAS,KAAK,KAAK,IAAI,MAAM,CAE5B;IAED;;;;;;OAMG;IACH,IAAW,OAAO,IAAI,OAAO,CAO5B;IAEe,QAAQ,IAAI,gBAAgB;CAoD/C"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* @fileoverview `JournalEntryLineEntity` — the per-line debit/credit rules, on BOTH tiers.
|
|
9
|
+
*
|
|
10
|
+
* WHY THIS LAYER EXISTS
|
|
11
|
+
*
|
|
12
|
+
* These rules — an account is required, exactly one side carries an amount, neither side is
|
|
13
|
+
* negative — need nothing but the line itself. They lived in `JournalEntryLineEntityServer`, in a
|
|
14
|
+
* server-only package, so the browser could not run them; the JE workspace therefore carried a
|
|
15
|
+
* hand-written `lineIssue()` saying the same things in different words, and the two were free to
|
|
16
|
+
* drift. They did: the server's wording named `DebitAmount`, the screen's named "the debit column",
|
|
17
|
+
* and only one of them was ever updated when the rule changed.
|
|
18
|
+
*
|
|
19
|
+
* `super.Validate()` on the parent entry fans out to the `Lines` collection, so these run as part of
|
|
20
|
+
* the entry's own validation and arrive attributed by position — `Lines[3].DebitAmount` — which is
|
|
21
|
+
* what lets the editor put an error on the offending ROW rather than in a list above the grid.
|
|
22
|
+
*
|
|
23
|
+
* WHAT DELIBERATELY STAYED ON THE SERVER SUBCLASS. Anything that reads reference data: whether the
|
|
24
|
+
* GL account is active, whether it belongs to the entry's company, whether a dimension value belongs
|
|
25
|
+
* to the dimension it tags. The browser has a cache of those, but a cache is not an authority, and a
|
|
26
|
+
* rule enforced against a stale cache is worse than one enforced late.
|
|
27
|
+
*
|
|
28
|
+
* @module @mj-biz-apps/accounting-entities
|
|
29
|
+
*/
|
|
30
|
+
import { BaseEntity, ValidationErrorInfo, ValidationResult } from '@memberjunction/core';
|
|
31
|
+
import { RegisterClass } from '@memberjunction/global';
|
|
32
|
+
import { mjBizAppsAccountingJournalEntryLineEntity } from './generated/entity_subclasses.js';
|
|
33
|
+
let JournalEntryLineEntity = class JournalEntryLineEntity extends mjBizAppsAccountingJournalEntryLineEntity {
|
|
34
|
+
/** How this line names itself in a message. Falls back to the id while the number is unassigned. */
|
|
35
|
+
get Label() {
|
|
36
|
+
return this.LineNumber ? `Line ${this.LineNumber}` : 'This line';
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* True when the operator has not touched this row at all.
|
|
40
|
+
*
|
|
41
|
+
* An untouched row is not an error — the editor opens with two blank lines by design, and
|
|
42
|
+
* reporting "pick an account" against a row nobody has typed in is noise that trains people to
|
|
43
|
+
* ignore the error list. It is dropped at save rather than reported.
|
|
44
|
+
*/
|
|
45
|
+
get IsEmpty() {
|
|
46
|
+
return (!this.GLAccountID &&
|
|
47
|
+
!(this.DebitAmount ?? 0) &&
|
|
48
|
+
!(this.CreditAmount ?? 0) &&
|
|
49
|
+
!(this.Description ?? '').trim());
|
|
50
|
+
}
|
|
51
|
+
Validate() {
|
|
52
|
+
// AN UNTOUCHED ROW REPORTS NOTHING — including whatever the generated base would say about
|
|
53
|
+
// it. `super.Validate()` mirrors the table's CHECK constraints, one of which is "a line must
|
|
54
|
+
// have a positive debit or a positive credit"; running it here would put that on the blank
|
|
55
|
+
// row the editor always keeps at the bottom, which is the noise this whole rule exists to
|
|
56
|
+
// avoid. A blank line that reaches a SAVE is caught by `JournalEntryEntityServer.Validate()`,
|
|
57
|
+
// which names it by number.
|
|
58
|
+
if (this.IsEmpty) {
|
|
59
|
+
const quiet = new ValidationResult();
|
|
60
|
+
quiet.Success = true;
|
|
61
|
+
return quiet;
|
|
62
|
+
}
|
|
63
|
+
const result = super.Validate();
|
|
64
|
+
const debit = this.DebitAmount ?? 0;
|
|
65
|
+
const credit = this.CreditAmount ?? 0;
|
|
66
|
+
const fail = (source, message, value) => {
|
|
67
|
+
result.Success = false;
|
|
68
|
+
result.Errors.push(new ValidationErrorInfo(source, message, value));
|
|
69
|
+
};
|
|
70
|
+
if (!this.GLAccountID) {
|
|
71
|
+
fail('GLAccountID', `${this.Label} needs an account.`, null);
|
|
72
|
+
}
|
|
73
|
+
// ONE SIDE ONLY. A line carrying both is not a line that nets — it is two lines somebody
|
|
74
|
+
// typed into one row, and the entry would still balance, so nothing downstream would notice.
|
|
75
|
+
if (debit > 0 && credit > 0) {
|
|
76
|
+
fail('DebitAmount', `${this.Label} is either a debit or a credit, not both (${debit} / ${credit}).`, debit);
|
|
77
|
+
}
|
|
78
|
+
if (debit === 0 && credit === 0) {
|
|
79
|
+
fail('DebitAmount', `${this.Label} needs a debit or a credit amount.`, null);
|
|
80
|
+
}
|
|
81
|
+
// A NEGATIVE AMOUNT IS THE OTHER COLUMN. Accepting one would let an entry balance by two
|
|
82
|
+
// wrongs — a negative debit against a smaller credit sums correctly and posts backwards.
|
|
83
|
+
if (debit < 0) {
|
|
84
|
+
fail('DebitAmount', `${this.Label} cannot have a negative debit — use the credit column instead.`, debit);
|
|
85
|
+
}
|
|
86
|
+
if (credit < 0) {
|
|
87
|
+
fail('CreditAmount', `${this.Label} cannot have a negative credit — use the debit column instead.`, credit);
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
JournalEntryLineEntity = __decorate([
|
|
93
|
+
RegisterClass(BaseEntity, 'MJ_BizApps_Accounting: Journal Entry Lines')
|
|
94
|
+
], JournalEntryLineEntity);
|
|
95
|
+
export { JournalEntryLineEntity };
|
|
96
|
+
//# sourceMappingURL=JournalEntryLineEntity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JournalEntryLineEntity.js","sourceRoot":"","sources":["../src/JournalEntryLineEntity.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,yCAAyC,EAAE,MAAM,+BAA+B,CAAC;AAGnF,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,yCAAyC;IACjF,oGAAoG;IACpG,IAAc,KAAK;QACf,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC;IACrE,CAAC;IAED;;;;;;OAMG;IACH,IAAW,OAA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