@leaddreamer/inventorylogic 0.0.3-beta.30 → 0.0.3-beta.38
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/README.md +427 -0
- package/business/Addresses/index.js +181 -0
- package/business/BusinessData/index.js +2 -3
- package/business/Fundamentals/index.js +184 -0
- package/business/PrivateData/index.js +176 -0
- package/business/boilerplate/index.js +6 -0
- package/business/index.js +6 -3
- package/dist/InventoryLogic.14a7860a.js +2 -0
- package/dist/InventoryLogic.14b7f292.js +2 -0
- package/dist/InventoryLogic.22a36cc8.js +2 -0
- package/dist/InventoryLogic.34455124.js +2 -0
- package/dist/InventoryLogic.3675b133.js +2 -0
- package/dist/InventoryLogic.3b10ccc5.js +2 -0
- package/dist/InventoryLogic.421e1e7c.js +9 -0
- package/dist/InventoryLogic.7407f5ab.js +2 -0
- package/dist/InventoryLogic.7559452d.js +2 -0
- package/dist/InventoryLogic.9f07806b.js +2 -0
- package/dist/InventoryLogic.bf7b624e.js +2 -0
- package/dist/InventoryLogic.c903d27c.js +2 -0
- package/dist/InventoryLogic.d14897a2.js +2 -0
- package/dist/InventoryLogic.f29bd369.js +2 -0
- package/dist/InventoryLogic.f3361cdd.js +2 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,6 +19,9 @@ services.</p>
|
|
|
19
19
|
<dd><p>A collection of Business logic and database functions. Shared between ReactJS
|
|
20
20
|
frontEnd and NodeJS BackEnd</p>
|
|
21
21
|
</dd>
|
|
22
|
+
<dt><a href="#module_Addresses">Addresses</a></dt>
|
|
23
|
+
<dd><p>Types and functins for handling addresses</p>
|
|
24
|
+
</dd>
|
|
22
25
|
<dt><a href="#module_BusinessData">BusinessData</a></dt>
|
|
23
26
|
<dd><p>Functions for managing (potentially)private data for an organization.
|
|
24
27
|
Unified structure as a sub-record of organization, or CityManager accounts</p>
|
|
@@ -27,6 +30,10 @@ Unified structure as a sub-record of organization, or CityManager accounts</p>
|
|
|
27
30
|
<dd><p>Typedefs, constants, support functions and database operations related to Commodity Matrials
|
|
28
31
|
users</p>
|
|
29
32
|
</dd>
|
|
33
|
+
<dt><a href="#module_Fundamentals">Fundamentals</a></dt>
|
|
34
|
+
<dd><p>Typedefs, constants, support functions and database operations related to Fundamental
|
|
35
|
+
setting from the Database *</p>
|
|
36
|
+
</dd>
|
|
30
37
|
<dt><a href="#module_LineItem">LineItem</a></dt>
|
|
31
38
|
<dd><p>Typedefs, constants, support functions and database operations related to LineItem Matrials
|
|
32
39
|
users</p>
|
|
@@ -40,6 +47,10 @@ users</p>
|
|
|
40
47
|
to an individual user. These do not <em>particularly</em> represent a paymentProvider - they are meant
|
|
41
48
|
as an abstraction above a specific payment processor.</p>
|
|
42
49
|
</dd>
|
|
50
|
+
<dt><a href="#module_PrivateData">PrivateData</a></dt>
|
|
51
|
+
<dd><p>Functions for managing (potentially)private data for a user or organization.
|
|
52
|
+
Unified structure as a sub-record of fan, organization, or CityManager accounts</p>
|
|
53
|
+
</dd>
|
|
43
54
|
<dt><a href="#module_Product">Product</a></dt>
|
|
44
55
|
<dd><p>Typedefs, constants, support functions and database operations related to Products</p>
|
|
45
56
|
</dd>
|
|
@@ -182,6 +193,141 @@ called from a cloud environment
|
|
|
182
193
|
| measurementId: | <code>string</code> | (optional) Analytics/Measurement ID from Firebase Console |
|
|
183
194
|
| mapsAPIKey | <code>string</code> | (optional) App ID for Google Maps API, from Google |
|
|
184
195
|
|
|
196
|
+
<a name="module_Addresses"></a>
|
|
197
|
+
|
|
198
|
+
## Addresses
|
|
199
|
+
Types and functins for handling addresses
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
* [Addresses](#module_Addresses)
|
|
203
|
+
* _static_
|
|
204
|
+
* [.AddressDefault](#module_Addresses.AddressDefault) : <code>AddressType</code>
|
|
205
|
+
* [.AddressForm](#module_Addresses.AddressForm) : <code>AddressType</code>
|
|
206
|
+
* [.maplink](#module_Addresses.maplink) : <code>MapLink</code>
|
|
207
|
+
* [.deleteAddress(address)](#module_Addresses.deleteAddress) ⇒ <code>Promise.<void></code>
|
|
208
|
+
* [.deleteAddressByIdAndParent(addressId, parent, batch)](#module_Addresses.deleteAddressByIdAndParent) ⇒ <code>Promise.ChainType</code>
|
|
209
|
+
* [.formatAddress(address)](#module_Addresses.formatAddress) ⇒ <code>string</code>
|
|
210
|
+
* [.saveAddress(address, paraentRefPath)](#module_Addresses.saveAddress) ⇒ <code>Promise.<AddressType></code>
|
|
211
|
+
* [.fetchAddresses(account)](#module_Addresses.fetchAddresses) ⇒ <code>Promise.<Array.AddressType></code>
|
|
212
|
+
* _inner_
|
|
213
|
+
* [~AddressType](#module_Addresses..AddressType) : <code>object</code>
|
|
214
|
+
* [~MapLink](#module_Addresses..MapLink) : <code>object</code>
|
|
215
|
+
* [~ChainType](#module_Addresses..ChainType) : <code>WriteBatch</code> \| <code>Transaction</code> \| <code>void</code>
|
|
216
|
+
|
|
217
|
+
<a name="module_Addresses.AddressDefault"></a>
|
|
218
|
+
|
|
219
|
+
### Addresses.AddressDefault : <code>AddressType</code>
|
|
220
|
+
**Kind**: static constant of [<code>Addresses</code>](#module_Addresses)
|
|
221
|
+
<a name="module_Addresses.AddressForm"></a>
|
|
222
|
+
|
|
223
|
+
### Addresses.AddressForm : <code>AddressType</code>
|
|
224
|
+
**Kind**: static constant of [<code>Addresses</code>](#module_Addresses)
|
|
225
|
+
<a name="module_Addresses.maplink"></a>
|
|
226
|
+
|
|
227
|
+
### Addresses.maplink : <code>MapLink</code>
|
|
228
|
+
**Kind**: static constant of [<code>Addresses</code>](#module_Addresses)
|
|
229
|
+
**Read only**: true
|
|
230
|
+
<a name="module_Addresses.deleteAddress"></a>
|
|
231
|
+
|
|
232
|
+
### Addresses.deleteAddress(address) ⇒ <code>Promise.<void></code>
|
|
233
|
+
Deletes an existing address record from the database, based on it's own refPath
|
|
234
|
+
|
|
235
|
+
**Kind**: static method of [<code>Addresses</code>](#module_Addresses)
|
|
236
|
+
|
|
237
|
+
| Param | Type |
|
|
238
|
+
| --- | --- |
|
|
239
|
+
| address | <code>AddressType</code> |
|
|
240
|
+
| address.refPath | <code>string</code> |
|
|
241
|
+
|
|
242
|
+
<a name="module_Addresses.deleteAddressByIdAndParent"></a>
|
|
243
|
+
|
|
244
|
+
### Addresses.deleteAddressByIdAndParent(addressId, parent, batch) ⇒ <code>Promise.ChainType</code>
|
|
245
|
+
Deletes an existing address record from the database, based on it's parent
|
|
246
|
+
record and Id
|
|
247
|
+
|
|
248
|
+
**Kind**: static method of [<code>Addresses</code>](#module_Addresses)
|
|
249
|
+
|
|
250
|
+
| Param | Type |
|
|
251
|
+
| --- | --- |
|
|
252
|
+
| addressId | <code>string</code> |
|
|
253
|
+
| parent | <code>OrganizationType</code> |
|
|
254
|
+
| parent.refPath | <code>string</code> |
|
|
255
|
+
| batch | <code>ChainType</code> |
|
|
256
|
+
|
|
257
|
+
<a name="module_Addresses.formatAddress"></a>
|
|
258
|
+
|
|
259
|
+
### Addresses.formatAddress(address) ⇒ <code>string</code>
|
|
260
|
+
Builds a formatted string from a provided address record
|
|
261
|
+
|
|
262
|
+
**Kind**: static method of [<code>Addresses</code>](#module_Addresses)
|
|
263
|
+
|
|
264
|
+
| Param | Type |
|
|
265
|
+
| --- | --- |
|
|
266
|
+
| address | <code>AddressType</code> |
|
|
267
|
+
|
|
268
|
+
<a name="module_Addresses.saveAddress"></a>
|
|
269
|
+
|
|
270
|
+
### Addresses.saveAddress(address, paraentRefPath) ⇒ <code>Promise.<AddressType></code>
|
|
271
|
+
Saves an address record to the database below the provided parentRefPath,
|
|
272
|
+
whether exsiting or not
|
|
273
|
+
|
|
274
|
+
**Kind**: static method of [<code>Addresses</code>](#module_Addresses)
|
|
275
|
+
|
|
276
|
+
| Param | Type | Description |
|
|
277
|
+
| --- | --- | --- |
|
|
278
|
+
| address | <code>AddressType</code> | |
|
|
279
|
+
| address.refPath | <code>string</code> | if present, writes back |
|
|
280
|
+
| paraentRefPath | <code>string</code> | required if new record |
|
|
281
|
+
|
|
282
|
+
<a name="module_Addresses.fetchAddresses"></a>
|
|
283
|
+
|
|
284
|
+
### Addresses.fetchAddresses(account) ⇒ <code>Promise.<Array.AddressType></code>
|
|
285
|
+
Fetches all address records for an account
|
|
286
|
+
|
|
287
|
+
**Kind**: static method of [<code>Addresses</code>](#module_Addresses)
|
|
288
|
+
|
|
289
|
+
| Param | Type |
|
|
290
|
+
| --- | --- |
|
|
291
|
+
| account | <code>Record</code> |
|
|
292
|
+
| account.refPath | <code>string</code> |
|
|
293
|
+
|
|
294
|
+
<a name="module_Addresses..AddressType"></a>
|
|
295
|
+
|
|
296
|
+
### Addresses~AddressType : <code>object</code>
|
|
297
|
+
**Kind**: inner typedef of [<code>Addresses</code>](#module_Addresses)
|
|
298
|
+
**Properties**
|
|
299
|
+
|
|
300
|
+
| Name | Type | Description |
|
|
301
|
+
| --- | --- | --- |
|
|
302
|
+
| Id | <code>string</code> | will be populated for existing record; null or missing for new/minimal object |
|
|
303
|
+
| refPath | <code>string</code> | will be populated for existing record; null or missing for new/minimal object |
|
|
304
|
+
| address_line_1 | <code>string</code> | |
|
|
305
|
+
| address_line_2 | <code>string</code> | |
|
|
306
|
+
| city | <code>string</code> | |
|
|
307
|
+
| region | <code>string</code> | selected from a list of supported Cities/Regions |
|
|
308
|
+
| state | <code>string</code> | |
|
|
309
|
+
| zip | <code>zip</code> | |
|
|
310
|
+
| mapLink | <code>maplink</code> | link to Google map location |
|
|
311
|
+
|
|
312
|
+
<a name="module_Addresses..MapLink"></a>
|
|
313
|
+
|
|
314
|
+
### Addresses~MapLink : <code>object</code>
|
|
315
|
+
**Kind**: inner typedef of [<code>Addresses</code>](#module_Addresses)
|
|
316
|
+
**Properties**
|
|
317
|
+
|
|
318
|
+
| Name | Type | Description |
|
|
319
|
+
| --- | --- | --- |
|
|
320
|
+
| placeId | <code>string</code> | as defined by Google |
|
|
321
|
+
| latlng | <code>object</code> | coordinates tuple |
|
|
322
|
+
| latlng.lat | <code>string</code> | lattitude |
|
|
323
|
+
| latlng.lng | <code>string</code> | longitude |
|
|
324
|
+
| url | <code>string</code> | link to place/map entry |
|
|
325
|
+
| formatted_address | <code>string</code> | printable string of address |
|
|
326
|
+
|
|
327
|
+
<a name="module_Addresses..ChainType"></a>
|
|
328
|
+
|
|
329
|
+
### Addresses~ChainType : <code>WriteBatch</code> \| <code>Transaction</code> \| <code>void</code>
|
|
330
|
+
**Kind**: inner typedef of [<code>Addresses</code>](#module_Addresses)
|
|
185
331
|
<a name="module_BusinessData"></a>
|
|
186
332
|
|
|
187
333
|
## BusinessData
|
|
@@ -595,6 +741,166 @@ An object to allow for paginating a table read from Firestore. REQUIRES a sortin
|
|
|
595
741
|
| PageForward | <code>method</code> | pages the fetch forward |
|
|
596
742
|
| PageBack | <code>method</code> | pages the fetch backward |
|
|
597
743
|
|
|
744
|
+
<a name="module_Fundamentals"></a>
|
|
745
|
+
|
|
746
|
+
## Fundamentals
|
|
747
|
+
Typedefs, constants, support functions and database operations related to Fundamental
|
|
748
|
+
setting from the Database *
|
|
749
|
+
|
|
750
|
+
|
|
751
|
+
* [Fundamentals](#module_Fundamentals)
|
|
752
|
+
* _static_
|
|
753
|
+
* [.fetchFundamentals()](#module_Fundamentals.fetchFundamentals) ⇒ <code>Promise.<Fundamentals></code>
|
|
754
|
+
* [.fetchRates()](#module_Fundamentals.fetchRates) ⇒ <code>Promise.<Rates></code>
|
|
755
|
+
* [.fetchPayoutRates()](#module_Fundamentals.fetchPayoutRates) ⇒ <code>Promise.<PaymentProcessor></code>
|
|
756
|
+
* [.fetchMCCs()](#module_Fundamentals.fetchMCCs) ⇒ <code>Promise.<Array.MCCType></code>
|
|
757
|
+
* [.fetchBusinessTypes()](#module_Fundamentals.fetchBusinessTypes) ⇒ <code>Promise.<Array.BusinessType></code>
|
|
758
|
+
* _inner_
|
|
759
|
+
* [~Rates](#module_Fundamentals..Rates) : <code>Rates</code>
|
|
760
|
+
* [~paymentProcessor](#module_Fundamentals..paymentProcessor) : <code>PaymentProcessor</code>
|
|
761
|
+
* [~MCCDefault](#module_Fundamentals..MCCDefault) : <code>MCCType</code>
|
|
762
|
+
* [~BusinessTypeDefault](#module_Fundamentals..BusinessTypeDefault) : <code>BusinessType</code>
|
|
763
|
+
* [~OrganizationFundamentals](#module_Fundamentals..OrganizationFundamentals) : <code>object</code>
|
|
764
|
+
* [~Rates](#module_Fundamentals..Rates) : <code>object</code>
|
|
765
|
+
* [~PaymentProcessor](#module_Fundamentals..PaymentProcessor) : <code>object</code>
|
|
766
|
+
* [~MCCType](#module_Fundamentals..MCCType) : <code>object</code>
|
|
767
|
+
* [~BusinessType](#module_Fundamentals..BusinessType) : <code>object</code>
|
|
768
|
+
* [~Fundamentals](#module_Fundamentals..Fundamentals) : <code>object</code>
|
|
769
|
+
|
|
770
|
+
<a name="module_Fundamentals.fetchFundamentals"></a>
|
|
771
|
+
|
|
772
|
+
### Fundamentals.fetchFundamentals() ⇒ <code>Promise.<Fundamentals></code>
|
|
773
|
+
returns a Promise which resolves with an
|
|
774
|
+
array of all Fundamentals Objects (or err)
|
|
775
|
+
|
|
776
|
+
**Kind**: static method of [<code>Fundamentals</code>](#module_Fundamentals)
|
|
777
|
+
<a name="module_Fundamentals.fetchRates"></a>
|
|
778
|
+
|
|
779
|
+
### Fundamentals.fetchRates() ⇒ <code>Promise.<Rates></code>
|
|
780
|
+
returns a Promise that resolves with the Rates record from the database
|
|
781
|
+
|
|
782
|
+
**Kind**: static method of [<code>Fundamentals</code>](#module_Fundamentals)
|
|
783
|
+
<a name="module_Fundamentals.fetchPayoutRates"></a>
|
|
784
|
+
|
|
785
|
+
### Fundamentals.fetchPayoutRates() ⇒ <code>Promise.<PaymentProcessor></code>
|
|
786
|
+
returns a Promise that resolves with the Rates record from the database
|
|
787
|
+
|
|
788
|
+
**Kind**: static method of [<code>Fundamentals</code>](#module_Fundamentals)
|
|
789
|
+
<a name="module_Fundamentals.fetchMCCs"></a>
|
|
790
|
+
|
|
791
|
+
### Fundamentals.fetchMCCs() ⇒ <code>Promise.<Array.MCCType></code>
|
|
792
|
+
returns an array of all MCC (Merchant Commerce Code) available
|
|
793
|
+
|
|
794
|
+
**Kind**: static method of [<code>Fundamentals</code>](#module_Fundamentals)
|
|
795
|
+
<a name="module_Fundamentals.fetchBusinessTypes"></a>
|
|
796
|
+
|
|
797
|
+
### Fundamentals.fetchBusinessTypes() ⇒ <code>Promise.<Array.BusinessType></code>
|
|
798
|
+
returns an array of all MCC (Merchant Commerce Code) available
|
|
799
|
+
|
|
800
|
+
**Kind**: static method of [<code>Fundamentals</code>](#module_Fundamentals)
|
|
801
|
+
<a name="module_Fundamentals..Rates"></a>
|
|
802
|
+
|
|
803
|
+
### Fundamentals~Rates : <code>Rates</code>
|
|
804
|
+
**Kind**: inner constant of [<code>Fundamentals</code>](#module_Fundamentals)
|
|
805
|
+
**Default**: <code>{"Id":null,"service_charge":""}</code>
|
|
806
|
+
<a name="module_Fundamentals..paymentProcessor"></a>
|
|
807
|
+
|
|
808
|
+
### Fundamentals~paymentProcessor : <code>PaymentProcessor</code>
|
|
809
|
+
**Kind**: inner constant of [<code>Fundamentals</code>](#module_Fundamentals)
|
|
810
|
+
**Default**: <code>{"connected_active":200,"processing_concurrency":10,"processing_rate":25,"processing_time_window":1000,"per_payout":25,"rate_payout":25,"rate_payout_scale":10000}</code>
|
|
811
|
+
<a name="module_Fundamentals..MCCDefault"></a>
|
|
812
|
+
|
|
813
|
+
### Fundamentals~MCCDefault : <code>MCCType</code>
|
|
814
|
+
**Kind**: inner constant of [<code>Fundamentals</code>](#module_Fundamentals)
|
|
815
|
+
**Default**: <code>{"Id":null,"MCC":null,"name":null,"description":null,"long":null,"type":null}</code>
|
|
816
|
+
<a name="module_Fundamentals..BusinessTypeDefault"></a>
|
|
817
|
+
|
|
818
|
+
### Fundamentals~BusinessTypeDefault : <code>BusinessType</code>
|
|
819
|
+
**Kind**: inner constant of [<code>Fundamentals</code>](#module_Fundamentals)
|
|
820
|
+
**Default**: <code>{"Id":null,"business_type":null,"name":null,"description":null}</code>
|
|
821
|
+
<a name="module_Fundamentals..OrganizationFundamentals"></a>
|
|
822
|
+
|
|
823
|
+
### Fundamentals~OrganizationFundamentals : <code>object</code>
|
|
824
|
+
**Kind**: inner typedef of [<code>Fundamentals</code>](#module_Fundamentals)
|
|
825
|
+
**Properties**
|
|
826
|
+
|
|
827
|
+
| Name | Type | Description |
|
|
828
|
+
| --- | --- | --- |
|
|
829
|
+
| Types | <code>Array.string</code> | Allowed organization types |
|
|
830
|
+
|
|
831
|
+
<a name="module_Fundamentals..Rates"></a>
|
|
832
|
+
|
|
833
|
+
### Fundamentals~Rates : <code>object</code>
|
|
834
|
+
**Kind**: inner typedef of [<code>Fundamentals</code>](#module_Fundamentals)
|
|
835
|
+
**Properties**
|
|
836
|
+
|
|
837
|
+
| Name | Type | Description |
|
|
838
|
+
| --- | --- | --- |
|
|
839
|
+
| Id | <code>string</code> | |
|
|
840
|
+
| service_charge | <code>object</code> | |
|
|
841
|
+
| service_charge.minimum | <code>number</code> | |
|
|
842
|
+
| service_charge.rate | <code>number</code> | percentage |
|
|
843
|
+
| service_charge.rounding_factor | <code>number</code> | |
|
|
844
|
+
|
|
845
|
+
<a name="module_Fundamentals..PaymentProcessor"></a>
|
|
846
|
+
|
|
847
|
+
### Fundamentals~PaymentProcessor : <code>object</code>
|
|
848
|
+
**Kind**: inner typedef of [<code>Fundamentals</code>](#module_Fundamentals)
|
|
849
|
+
**Properties**
|
|
850
|
+
|
|
851
|
+
| Name | Type | Description |
|
|
852
|
+
| --- | --- | --- |
|
|
853
|
+
| connected_active | <code>number</code> | allowed active connections |
|
|
854
|
+
| processing_concurrency | <code>number</code> | |
|
|
855
|
+
| processing_rate | <code>number</code> | |
|
|
856
|
+
| processing_time_window | <code>number</code> | |
|
|
857
|
+
| per_payout | <code>number</code> | |
|
|
858
|
+
| rate_payout | <code>number</code> | |
|
|
859
|
+
| rate_payout_scale | <code>number</code> | |
|
|
860
|
+
|
|
861
|
+
<a name="module_Fundamentals..MCCType"></a>
|
|
862
|
+
|
|
863
|
+
### Fundamentals~MCCType : <code>object</code>
|
|
864
|
+
**Kind**: inner typedef of [<code>Fundamentals</code>](#module_Fundamentals)
|
|
865
|
+
**Properties**
|
|
866
|
+
|
|
867
|
+
| Name | Type | Description |
|
|
868
|
+
| --- | --- | --- |
|
|
869
|
+
| Id | <code>string</code> | |
|
|
870
|
+
| MCC | <code>string</code> | Merchant Class Code |
|
|
871
|
+
| name | <code>string</code> | Merchant Class Code |
|
|
872
|
+
| description | <code>string</code> | description of Merchant Class Code |
|
|
873
|
+
| long | <code>string</code> | long description of Merchant Class Code |
|
|
874
|
+
| type | <code>string</code> | Applicable business model - "Artists", "Venues" or "Brands" |
|
|
875
|
+
|
|
876
|
+
<a name="module_Fundamentals..BusinessType"></a>
|
|
877
|
+
|
|
878
|
+
### Fundamentals~BusinessType : <code>object</code>
|
|
879
|
+
**Kind**: inner typedef of [<code>Fundamentals</code>](#module_Fundamentals)
|
|
880
|
+
**Properties**
|
|
881
|
+
|
|
882
|
+
| Name | Type | Description |
|
|
883
|
+
| --- | --- | --- |
|
|
884
|
+
| Id | <code>string</code> | |
|
|
885
|
+
| business_type | <code>string</code> | allowed business type value |
|
|
886
|
+
| name | <code>string</code> | business type value |
|
|
887
|
+
| description | <code>string</code> | description ofbusiness type value |
|
|
888
|
+
|
|
889
|
+
<a name="module_Fundamentals..Fundamentals"></a>
|
|
890
|
+
|
|
891
|
+
### Fundamentals~Fundamentals : <code>object</code>
|
|
892
|
+
**Kind**: inner typedef of [<code>Fundamentals</code>](#module_Fundamentals)
|
|
893
|
+
**Properties**
|
|
894
|
+
|
|
895
|
+
| Name | Type | Description |
|
|
896
|
+
| --- | --- | --- |
|
|
897
|
+
| Rates | <code>Rates</code> | |
|
|
898
|
+
| PaymentProcessor | <code>PaymentProcessor</code> | |
|
|
899
|
+
| Defaults | <code>object</code> | |
|
|
900
|
+
| Defaults.MCC | <code>MCCType</code> | |
|
|
901
|
+
| Organizations | <code>OrganizationFundamentals</code> | |
|
|
902
|
+
| Organizations.Types | <code>Array.string</code> | Allowed organization types |
|
|
903
|
+
|
|
598
904
|
<a name="module_LineItem"></a>
|
|
599
905
|
|
|
600
906
|
## LineItem
|
|
@@ -1342,6 +1648,127 @@ Changes the paidQ label on a receipt associated with a pledgeTicket
|
|
|
1342
1648
|
|
|
1343
1649
|
### Payment~AccountObject : <code>UserObject</code>
|
|
1344
1650
|
**Kind**: inner typedef of [<code>Payment</code>](#module_Payment)
|
|
1651
|
+
<a name="module_PrivateData"></a>
|
|
1652
|
+
|
|
1653
|
+
## PrivateData
|
|
1654
|
+
Functions for managing (potentially)private data for a user or organization.
|
|
1655
|
+
Unified structure as a sub-record of fan, organization, or CityManager accounts
|
|
1656
|
+
|
|
1657
|
+
|
|
1658
|
+
* [PrivateData](#module_PrivateData)
|
|
1659
|
+
* _static_
|
|
1660
|
+
* [.fetchPrivateData(account)](#module_PrivateData.fetchPrivateData) ⇒ <code>Promise.PrivateData</code>
|
|
1661
|
+
* [.createPrivateData(account, batch)](#module_PrivateData.createPrivateData) ⇒ <code>Promise.<ChainType></code>
|
|
1662
|
+
* [.savePrivateData(privateData)](#module_PrivateData.savePrivateData) ⇒ <code>Promise.<PrivateData></code>
|
|
1663
|
+
* [.deletePrivateData(privateData)](#module_PrivateData.deletePrivateData) ⇒ <code>Promise.<void></code>
|
|
1664
|
+
* [.privateDataPath(account)](#module_PrivateData.privateDataPath) ⇒ <code>string</code>
|
|
1665
|
+
* _inner_
|
|
1666
|
+
* [~PrivateDefault](#module_PrivateData..PrivateDefault) : <code>PrivateData</code>
|
|
1667
|
+
* [~PrivateAccountForm](#module_PrivateData..PrivateAccountForm) : <code>PrivateData</code>
|
|
1668
|
+
* [~contact](#module_PrivateData..contact) : <code>object</code>
|
|
1669
|
+
* [~PrivateData](#module_PrivateData..PrivateData) : <code>object</code>
|
|
1670
|
+
* [~ChainType](#module_PrivateData..ChainType) : <code>WriteBatch</code> \| <code>Transaction</code> \| <code>void</code>
|
|
1671
|
+
|
|
1672
|
+
<a name="module_PrivateData.fetchPrivateData"></a>
|
|
1673
|
+
|
|
1674
|
+
### PrivateData.fetchPrivateData(account) ⇒ <code>Promise.PrivateData</code>
|
|
1675
|
+
Fecthes the PrivateData (email, tel, addresses, etc) for a Fan account
|
|
1676
|
+
|
|
1677
|
+
**Kind**: static method of [<code>PrivateData</code>](#module_PrivateData)
|
|
1678
|
+
|
|
1679
|
+
| Param | Type |
|
|
1680
|
+
| --- | --- |
|
|
1681
|
+
| account | <code>AccountType</code> |
|
|
1682
|
+
|
|
1683
|
+
<a name="module_PrivateData.createPrivateData"></a>
|
|
1684
|
+
|
|
1685
|
+
### PrivateData.createPrivateData(account, batch) ⇒ <code>Promise.<ChainType></code>
|
|
1686
|
+
**Kind**: static method of [<code>PrivateData</code>](#module_PrivateData)
|
|
1687
|
+
**Returns**: <code>Promise.<ChainType></code> - WriteBatch, Transaction or Void
|
|
1688
|
+
|
|
1689
|
+
| Param | Type | Description |
|
|
1690
|
+
| --- | --- | --- |
|
|
1691
|
+
| account | <code>AccountType</code> | |
|
|
1692
|
+
| batch | <code>ChainType</code> | batching object. Transaction will be added to the batch |
|
|
1693
|
+
|
|
1694
|
+
<a name="module_PrivateData.savePrivateData"></a>
|
|
1695
|
+
|
|
1696
|
+
### PrivateData.savePrivateData(privateData) ⇒ <code>Promise.<PrivateData></code>
|
|
1697
|
+
Writes the "private" data to the database
|
|
1698
|
+
|
|
1699
|
+
**Kind**: static method of [<code>PrivateData</code>](#module_PrivateData)
|
|
1700
|
+
|
|
1701
|
+
| Param | Type |
|
|
1702
|
+
| --- | --- |
|
|
1703
|
+
| privateData | <code>PrivateData</code> |
|
|
1704
|
+
|
|
1705
|
+
<a name="module_PrivateData.deletePrivateData"></a>
|
|
1706
|
+
|
|
1707
|
+
### PrivateData.deletePrivateData(privateData) ⇒ <code>Promise.<void></code>
|
|
1708
|
+
Deletes a PrivateData record (rarely used if ever)
|
|
1709
|
+
|
|
1710
|
+
**Kind**: static method of [<code>PrivateData</code>](#module_PrivateData)
|
|
1711
|
+
|
|
1712
|
+
| Param | Type |
|
|
1713
|
+
| --- | --- |
|
|
1714
|
+
| privateData | <code>PrivateData</code> |
|
|
1715
|
+
| privateData.refPath | <code>string</code> |
|
|
1716
|
+
|
|
1717
|
+
<a name="module_PrivateData.privateDataPath"></a>
|
|
1718
|
+
|
|
1719
|
+
### PrivateData.privateDataPath(account) ⇒ <code>string</code>
|
|
1720
|
+
creates the "base path" (refPath) to store addresses based on an account (refPath)
|
|
1721
|
+
|
|
1722
|
+
**Kind**: static method of [<code>PrivateData</code>](#module_PrivateData)
|
|
1723
|
+
|
|
1724
|
+
| Param | Type |
|
|
1725
|
+
| --- | --- |
|
|
1726
|
+
| account | <code>Record</code> |
|
|
1727
|
+
| account.refPath | <code>string</code> |
|
|
1728
|
+
|
|
1729
|
+
<a name="module_PrivateData..PrivateDefault"></a>
|
|
1730
|
+
|
|
1731
|
+
### PrivateData~PrivateDefault : <code>PrivateData</code>
|
|
1732
|
+
**Kind**: inner constant of [<code>PrivateData</code>](#module_PrivateData)
|
|
1733
|
+
**Default**: <code>{"Id":null,"email":null,"contact":null,"business_address":null,"mailing_address":null,"billing_address":null,"tel":null,"tax_rate":null,"openIssues":false}</code>
|
|
1734
|
+
<a name="module_PrivateData..PrivateAccountForm"></a>
|
|
1735
|
+
|
|
1736
|
+
### PrivateData~PrivateAccountForm : <code>PrivateData</code>
|
|
1737
|
+
**Kind**: inner constant of [<code>PrivateData</code>](#module_PrivateData)
|
|
1738
|
+
**Default**: <code>{"refPath":"hidden:text","email":"email","contact":"","business_address":"","mailing_address":"","billing_address":"","tel":"tel"}</code>
|
|
1739
|
+
<a name="module_PrivateData..contact"></a>
|
|
1740
|
+
|
|
1741
|
+
### PrivateData~contact : <code>object</code>
|
|
1742
|
+
**Kind**: inner typedef of [<code>PrivateData</code>](#module_PrivateData)
|
|
1743
|
+
**Properties**
|
|
1744
|
+
|
|
1745
|
+
| Name | Type | Description |
|
|
1746
|
+
| --- | --- | --- |
|
|
1747
|
+
| contact.Id | <code>string</code> | |
|
|
1748
|
+
| contact.first_name | <code>string</code> | |
|
|
1749
|
+
| contact.last_name | <code>string</code> | |
|
|
1750
|
+
| contact.tel | <code>string</code> | |
|
|
1751
|
+
| contact.email | <code>string</code> | must be filled in to make profile public |
|
|
1752
|
+
|
|
1753
|
+
<a name="module_PrivateData..PrivateData"></a>
|
|
1754
|
+
|
|
1755
|
+
### PrivateData~PrivateData : <code>object</code>
|
|
1756
|
+
**Kind**: inner typedef of [<code>PrivateData</code>](#module_PrivateData)
|
|
1757
|
+
**Properties**
|
|
1758
|
+
|
|
1759
|
+
| Name | Type | Description |
|
|
1760
|
+
| --- | --- | --- |
|
|
1761
|
+
| email | <code>string</code> | must be filled in to make profile public |
|
|
1762
|
+
| contact | <code>contact</code> | |
|
|
1763
|
+
| tel | <code>string</code> | |
|
|
1764
|
+
| business_address | <code>AddressType</code> | |
|
|
1765
|
+
| mailing_address | <code>AddressType</code> | |
|
|
1766
|
+
| billing_address | <code>AddressType</code> | |
|
|
1767
|
+
|
|
1768
|
+
<a name="module_PrivateData..ChainType"></a>
|
|
1769
|
+
|
|
1770
|
+
### PrivateData~ChainType : <code>WriteBatch</code> \| <code>Transaction</code> \| <code>void</code>
|
|
1771
|
+
**Kind**: inner typedef of [<code>PrivateData</code>](#module_PrivateData)
|
|
1345
1772
|
<a name="module_Product"></a>
|
|
1346
1773
|
|
|
1347
1774
|
## Product
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types and functins for handling addresses
|
|
3
|
+
* @module Addresses
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
writeRecord,
|
|
9
|
+
writeBack,
|
|
10
|
+
deleteRecord,
|
|
11
|
+
deleteRecordByRefPath,
|
|
12
|
+
collectRecords,
|
|
13
|
+
} from "@leaddreamer/firebase-wrapper";
|
|
14
|
+
import { Forms } from "@leaddreamer/staticforms";
|
|
15
|
+
import { ADDRESSES } from "../boilerplate";
|
|
16
|
+
import { businessDataPath } from "../BusinessData";
|
|
17
|
+
|
|
18
|
+
//////////////////////////////////////////////////////////////////////
|
|
19
|
+
//Constants
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {object} AddressType
|
|
22
|
+
* @property {?string} Id - will be populated for existing record; null or
|
|
23
|
+
* missing for new/minimal object
|
|
24
|
+
* @property {?string} refPath - will be populated for existing record; null or
|
|
25
|
+
* missing for new/minimal object
|
|
26
|
+
* @property {string} address_line_1
|
|
27
|
+
* @property {?string} address_line_2
|
|
28
|
+
* @property {string} city
|
|
29
|
+
* @property {string} region - selected from a list of supported Cities/Regions
|
|
30
|
+
* @property {string} state
|
|
31
|
+
* @property {zip} zip
|
|
32
|
+
* @property {?maplink} mapLink - link to Google map location
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* @constant
|
|
36
|
+
* @type {AddressType}
|
|
37
|
+
* @default
|
|
38
|
+
*/
|
|
39
|
+
export const AddressDefault = {
|
|
40
|
+
name: null,
|
|
41
|
+
tel: null,
|
|
42
|
+
address_line_1: null,
|
|
43
|
+
address_line_2: null,
|
|
44
|
+
city: null,
|
|
45
|
+
region: null,
|
|
46
|
+
state: null,
|
|
47
|
+
zip: null,
|
|
48
|
+
maplink: null,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @constant
|
|
53
|
+
* @type {AddressType}
|
|
54
|
+
* @default
|
|
55
|
+
*/
|
|
56
|
+
export const AddressForm = {
|
|
57
|
+
name: "text::6",
|
|
58
|
+
tel: "tel::6",
|
|
59
|
+
address_line_1: "text::6",
|
|
60
|
+
address_line_2: "text::6",
|
|
61
|
+
city: "text::6",
|
|
62
|
+
// region: "lookup:Regions:4",
|
|
63
|
+
state: "text::3",
|
|
64
|
+
zip: "number::3",
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export const AddressSelectForm = {
|
|
68
|
+
address: `lookupLink:${ADDRESSES}`,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @typedef {object} MapLink
|
|
73
|
+
* @property {?string} placeId - as defined by Google
|
|
74
|
+
* @property {?object} latlng - coordinates tuple
|
|
75
|
+
* @property {string} latlng.lat - lattitude
|
|
76
|
+
* @property {string} latlng.lng - longitude
|
|
77
|
+
* @property {?string} url - link to place/map entry
|
|
78
|
+
* @property {?string} formatted_address - printable string of address
|
|
79
|
+
*/
|
|
80
|
+
/**
|
|
81
|
+
* @readonly
|
|
82
|
+
* @constant
|
|
83
|
+
* @type {MapLink}
|
|
84
|
+
* @default
|
|
85
|
+
*/
|
|
86
|
+
export const maplink = {
|
|
87
|
+
placeID: null,
|
|
88
|
+
latlng: {
|
|
89
|
+
lat: null,
|
|
90
|
+
lng: null,
|
|
91
|
+
},
|
|
92
|
+
url: null,
|
|
93
|
+
formatted_address: null,
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
Forms.Base[ADDRESSES] = AddressDefault;
|
|
97
|
+
Forms.BaseForm[ADDRESSES] = AddressForm;
|
|
98
|
+
Forms.AccountForm[ADDRESSES] = AddressForm;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @external WriteBatch
|
|
102
|
+
* @external Transaction
|
|
103
|
+
* @typedef {WriteBatch|Transaction|void} ChainType
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
//////////////////////////////////////////////////////////////////////
|
|
107
|
+
//Business Logic
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Deletes an existing address record from the database, based on it's own refPath
|
|
111
|
+
* @param {AddressType} address
|
|
112
|
+
* @param {!string} address.refPath
|
|
113
|
+
* @returns {Promise<void>}
|
|
114
|
+
*/
|
|
115
|
+
export async function deleteAddress(address) {
|
|
116
|
+
//check for real reacord (i.e. refPath)
|
|
117
|
+
if (!address?.refPath) return null;
|
|
118
|
+
return deleteRecordByRefPath(address.refPath);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Deletes an existing address record from the database, based on it's parent
|
|
123
|
+
* record and Id
|
|
124
|
+
* @param {!string} addressId
|
|
125
|
+
* @param {OrganizationType} parent
|
|
126
|
+
* @param {!string} parent.refPath
|
|
127
|
+
* @param {ChainType} batch
|
|
128
|
+
* @returns {Promise.ChainType}
|
|
129
|
+
*/
|
|
130
|
+
export async function deleteAddressByIdAndParent(
|
|
131
|
+
addressId,
|
|
132
|
+
parent,
|
|
133
|
+
batch = null
|
|
134
|
+
) {
|
|
135
|
+
//check for real reacord (i.e. refPath)
|
|
136
|
+
return deleteRecord(ADDRESSES, addressId, parent?.refPath, batch);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
//////////////////////////////////////////////////////////////////////
|
|
140
|
+
//helpers
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Builds a formatted string from a provided address record
|
|
144
|
+
* @param {AddressType} address
|
|
145
|
+
* @returns {string}
|
|
146
|
+
*/
|
|
147
|
+
export function formatAddress(address) {
|
|
148
|
+
let formattedString = address
|
|
149
|
+
? (address.address_line_1 ? address.address_line_1 + ", " : "") +
|
|
150
|
+
(address.address_line_2 ? address.address_line_2 + ", " : "") +
|
|
151
|
+
(address.city ? address.city + ", " : "") +
|
|
152
|
+
(address.state ? address.state + " " : "") +
|
|
153
|
+
(address.zip ? address.zip : "") +
|
|
154
|
+
(address.region ? " ( " + address.region + " )" : "")
|
|
155
|
+
: null;
|
|
156
|
+
return formattedString;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Saves an address record to the database below the provided parentRefPath,
|
|
161
|
+
* whether exsiting or not
|
|
162
|
+
* @param {AddressType} address
|
|
163
|
+
* @param {?string} address.refPath - if present, writes back
|
|
164
|
+
* @param {string} paraentRefPath - required if new record
|
|
165
|
+
* @returns {Promise<AddressType>}
|
|
166
|
+
*/
|
|
167
|
+
export async function saveAddress(address, parentRefPath) {
|
|
168
|
+
return address?.refPath
|
|
169
|
+
? writeBack(address)
|
|
170
|
+
: writeRecord(ADDRESSES, address, parentRefPath);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Fetches all address records for an account
|
|
175
|
+
* @param {Record} account
|
|
176
|
+
* @param {!string} account.refPath
|
|
177
|
+
* @returns {Promise<Array.AddressType>}
|
|
178
|
+
*/
|
|
179
|
+
export async function fetchAddresses(account) {
|
|
180
|
+
return collectRecords(ADDRESSES, businessDataPath(account));
|
|
181
|
+
}
|
|
@@ -15,10 +15,9 @@ import {
|
|
|
15
15
|
BUSINESSDATA,
|
|
16
16
|
BUSINESS_TYPE,
|
|
17
17
|
ADDRESSES,
|
|
18
|
-
|
|
18
|
+
USER,
|
|
19
19
|
MCC,
|
|
20
20
|
} from "../boilerplate";
|
|
21
|
-
import { Forms, fillForm } from "../../formModule";
|
|
22
21
|
import { fetchAddresses } from "../Addresses";
|
|
23
22
|
|
|
24
23
|
//////////////////////////////////////////////////////////////////////
|
|
@@ -74,7 +73,7 @@ const BusinessAccountForm = {
|
|
|
74
73
|
refPath: "hidden:text",
|
|
75
74
|
email: "email",
|
|
76
75
|
business_type: `lookup:${BUSINESS_TYPE}`,
|
|
77
|
-
contact: `object:${
|
|
76
|
+
contact: `object:${USER}`,
|
|
78
77
|
business_address: `lookupLink:${ADDRESSES}`,
|
|
79
78
|
mailing_address: `lookupLink:${ADDRESSES}`,
|
|
80
79
|
billing_address: `lookupLink:${ADDRESSES}`,
|