@7365admin1/core 3.48.1-staging.174 → 3.48.1-staging.175
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/.changeset/site-billing-configuration-scope.md +5 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +10 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/e2e/harness.mjs +14 -0
- package/test/e2e/site-billing-configuration-scope.e2e.test.mjs +422 -0
package/dist/index.d.ts
CHANGED
|
@@ -6253,6 +6253,23 @@ declare function useSiteBillingConfigurationRepo(): {
|
|
|
6253
6253
|
createIndexes: () => Promise<string>;
|
|
6254
6254
|
};
|
|
6255
6255
|
|
|
6256
|
+
/**
|
|
6257
|
+
* Billing configuration is per-estate — the tax rate, the rounding and the
|
|
6258
|
+
* payment settings every bill at that site is calculated from.
|
|
6259
|
+
*
|
|
6260
|
+
* Every one of these five handlers carried `requireAuth` and nothing else. The
|
|
6261
|
+
* record id came from the URL and the site came from the caller's own query or
|
|
6262
|
+
* body, so any signed-in account on the platform could read another client's
|
|
6263
|
+
* billing settings, change their tax rate, move a configuration to a different
|
|
6264
|
+
* estate, or delete it. `createdBy` was read off the raw `user` COOKIE with a
|
|
6265
|
+
* fall back to the body, so the "who set this up" name was client-supplied.
|
|
6266
|
+
*
|
|
6267
|
+
* The rule is the existing one — `requireSiteReach`, i.e. `entitleSite` — asked
|
|
6268
|
+
* about the site the request names on the way in, and about the STORED site for
|
|
6269
|
+
* the id routes, which name no site at all. `PUT` asks twice: once about where
|
|
6270
|
+
* the record is and once about where the body wants to move it, because a MOVE
|
|
6271
|
+
* needs the destination checked too. `createdBy` now comes from the session.
|
|
6272
|
+
*/
|
|
6256
6273
|
declare function useSiteBillingConfigurationController(): {
|
|
6257
6274
|
add: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
6258
6275
|
getAll: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -58897,11 +58897,6 @@ function useSiteBillingConfigurationController() {
|
|
|
58897
58897
|
} = useSiteBillingConfigurationRepo();
|
|
58898
58898
|
const { add: _add } = useSiteBillingConfigurationService();
|
|
58899
58899
|
async function add(req, res, next) {
|
|
58900
|
-
const cookies = req.headers.cookie?.split(";").map((cookie) => cookie.trim().split("=")).reduce(
|
|
58901
|
-
(acc, [key, value2]) => ({ ...acc, [key]: value2 }),
|
|
58902
|
-
{}
|
|
58903
|
-
);
|
|
58904
|
-
req.body.createdBy = cookies?.["user"] ? cookies["user"].toString() : req.body.createdBy;
|
|
58905
58900
|
const data = { ...req.body };
|
|
58906
58901
|
const { error, value } = schemaBillingConfiguration.validate(data);
|
|
58907
58902
|
if (error) {
|
|
@@ -58909,7 +58904,8 @@ function useSiteBillingConfigurationController() {
|
|
|
58909
58904
|
return;
|
|
58910
58905
|
}
|
|
58911
58906
|
try {
|
|
58912
|
-
|
|
58907
|
+
await requireSiteReach(req, value.site);
|
|
58908
|
+
const question = await _add({ ...value, createdBy: callerId(req) });
|
|
58913
58909
|
res.status(201).json({
|
|
58914
58910
|
message: "Site Billing Configuration added successfully.",
|
|
58915
58911
|
data: question
|
|
@@ -58953,6 +58949,7 @@ function useSiteBillingConfigurationController() {
|
|
|
58953
58949
|
}
|
|
58954
58950
|
});
|
|
58955
58951
|
try {
|
|
58952
|
+
await requireSiteReach(req, site);
|
|
58956
58953
|
const data = await _getAll({
|
|
58957
58954
|
search,
|
|
58958
58955
|
page,
|
|
@@ -58981,6 +58978,7 @@ function useSiteBillingConfigurationController() {
|
|
|
58981
58978
|
}
|
|
58982
58979
|
try {
|
|
58983
58980
|
const building = await _getById(id);
|
|
58981
|
+
await requireSiteReach(req, building?.site);
|
|
58984
58982
|
res.json({
|
|
58985
58983
|
message: "Successfully retrieved site billing configuration.",
|
|
58986
58984
|
data: { building }
|
|
@@ -59003,6 +59001,10 @@ function useSiteBillingConfigurationController() {
|
|
|
59003
59001
|
return;
|
|
59004
59002
|
}
|
|
59005
59003
|
try {
|
|
59004
|
+
const current = await _getById(_id);
|
|
59005
|
+
await requireSiteReach(req, current?.site);
|
|
59006
|
+
if (req.body?.site)
|
|
59007
|
+
await requireSiteReach(req, req.body.site);
|
|
59006
59008
|
const result = await _updateById(_id, req.body);
|
|
59007
59009
|
res.status(200).json({ message: result });
|
|
59008
59010
|
return;
|
|
@@ -59022,6 +59024,8 @@ function useSiteBillingConfigurationController() {
|
|
|
59022
59024
|
return;
|
|
59023
59025
|
}
|
|
59024
59026
|
try {
|
|
59027
|
+
const current = await _getById(_id);
|
|
59028
|
+
await requireSiteReach(req, current?.site);
|
|
59025
59029
|
await _deleteById(_id);
|
|
59026
59030
|
res.status(200).json({ message: "Successfully deleted site billing configuration." });
|
|
59027
59031
|
return;
|