@leaddreamer/inventorylogic 0.0.3-beta.81 → 0.0.3-beta.83

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.
Files changed (60) hide show
  1. package/README.md +0 -648
  2. package/business/Product/GoogleMerchantAPI.js +0 -2
  3. package/business/Utilities/index.js +0 -3
  4. package/package.json +5 -16
  5. package/business/Utilities/other.js +0 -404
  6. package/business/Utilities/promise-queue/index.js +0 -264
  7. package/business/Utilities/promise-queue/new.js +0 -231
  8. package/business/Utilities/rate-limited-queue/index.js +0 -127
  9. package/dist/InventoryLogic.0ac93278.js +0 -35
  10. package/dist/InventoryLogic.0ac93278.js.map +0 -1
  11. package/dist/InventoryLogic.31f6d549.js +0 -152
  12. package/dist/InventoryLogic.31f6d549.js.map +0 -1
  13. package/dist/InventoryLogic.35827495.js +0 -285
  14. package/dist/InventoryLogic.35827495.js.map +0 -1
  15. package/dist/InventoryLogic.37dfff3e.js +0 -72
  16. package/dist/InventoryLogic.37dfff3e.js.map +0 -1
  17. package/dist/InventoryLogic.4206cb15.js +0 -213
  18. package/dist/InventoryLogic.4206cb15.js.map +0 -1
  19. package/dist/InventoryLogic.44193a77.js +0 -35
  20. package/dist/InventoryLogic.44193a77.js.map +0 -1
  21. package/dist/InventoryLogic.46ca6768.js +0 -131
  22. package/dist/InventoryLogic.46ca6768.js.map +0 -1
  23. package/dist/InventoryLogic.4d012935.js +0 -151
  24. package/dist/InventoryLogic.4d012935.js.map +0 -1
  25. package/dist/InventoryLogic.57f24f5f.js +0 -155
  26. package/dist/InventoryLogic.57f24f5f.js.map +0 -1
  27. package/dist/InventoryLogic.59be76a4.js +0 -184
  28. package/dist/InventoryLogic.59be76a4.js.map +0 -1
  29. package/dist/InventoryLogic.70925a32.js +0 -375
  30. package/dist/InventoryLogic.70925a32.js.map +0 -1
  31. package/dist/InventoryLogic.72fcf301.js +0 -6
  32. package/dist/InventoryLogic.72fcf301.js.map +0 -1
  33. package/dist/InventoryLogic.7741caec.js +0 -375
  34. package/dist/InventoryLogic.7741caec.js.map +0 -1
  35. package/dist/InventoryLogic.78480e5e.js +0 -152
  36. package/dist/InventoryLogic.78480e5e.js.map +0 -1
  37. package/dist/InventoryLogic.80d0e568.js +0 -135
  38. package/dist/InventoryLogic.80d0e568.js.map +0 -1
  39. package/dist/InventoryLogic.8a273d2e.js +0 -110
  40. package/dist/InventoryLogic.8a273d2e.js.map +0 -1
  41. package/dist/InventoryLogic.8addb055.js +0 -202
  42. package/dist/InventoryLogic.8addb055.js.map +0 -1
  43. package/dist/InventoryLogic.9dee46ea.js +0 -6
  44. package/dist/InventoryLogic.9dee46ea.js.map +0 -1
  45. package/dist/InventoryLogic.b90f66ea.js +0 -124
  46. package/dist/InventoryLogic.b90f66ea.js.map +0 -1
  47. package/dist/InventoryLogic.bb447b4c.js +0 -39
  48. package/dist/InventoryLogic.bb447b4c.js.map +0 -1
  49. package/dist/InventoryLogic.d27e84a7.js +0 -75
  50. package/dist/InventoryLogic.d27e84a7.js.map +0 -1
  51. package/dist/InventoryLogic.d69ad127.js +0 -217
  52. package/dist/InventoryLogic.d69ad127.js.map +0 -1
  53. package/dist/InventoryLogic.e03e6b07.js +0 -245
  54. package/dist/InventoryLogic.e03e6b07.js.map +0 -1
  55. package/dist/InventoryLogic.f276f76c.js +0 -213
  56. package/dist/InventoryLogic.f276f76c.js.map +0 -1
  57. package/dist/InventoryLogic.f4627c8a.js +0 -160
  58. package/dist/InventoryLogic.f4627c8a.js.map +0 -1
  59. package/dist/index.js +0 -23
  60. package/dist/index.js.map +0 -1
@@ -1,124 +0,0 @@
1
- import "mathjs";
2
-
3
- /**
4
- * Typedefs, constants, support functions and database operations related to Products
5
- * @module GoogleProduct
6
- */ //////////////////////////////////////////////////////////////////////
7
- // Constants
8
-
9
- const $e409a6a48e9bf1c0$export$4059922dac929494 = {
10
- //id needs programmatic processing
11
- id: "variants[index].sku",
12
- title: "name",
13
- item_group_id: "id",
14
- item_group_title: "title",
15
- description: "description",
16
- link: "URL",
17
- //image_link and image_additional_links need programmatic process
18
- image_link: "variants[index].image.URL",
19
- additional_image_link: "mediaobject.images[all]",
20
- video_link: "mediaobject.video_image.video_link",
21
- virtual_model_link: "mediaobject.virtual_model.virtual_model_link",
22
- mobile_link: null,
23
- //availability needs to be programmatic
24
- availability: null,
25
- availability_date: "variants[index].availability_date",
26
- cost_of_goods_sold: null,
27
- expiration_date: "variants[index].expiration_date",
28
- price: "variants[index].pricing.baseprice.value| |variants[index].pricing.baseprice.currencyDescription.displayName",
29
- sale_price: "variants[index].pricing.saleprice.value| |variants[index].pricing.saleprice.currencyDescription.displayName",
30
- sale_price_effective_date: "variants[index].pricing.effectiveDate.",
31
- google_product_category: "google_product_category",
32
- product_type: "product_type",
33
- brand: "brand.name",
34
- gtin: "variants[index].gtin",
35
- mpn: "variants[index].gtin",
36
- adult: "demographics.adult",
37
- age_group: "demographics.age_group",
38
- gender: "demographics.gender",
39
- condition: "attributes.condition",
40
- color: "attributes.colors[0]",
41
- material: "attributes.materials[0]",
42
- pattern: "attributes.patterns[0]",
43
- product_length: "variants[index].productMeasurements.dimensions.length&' '&variants[index].productMeasurements.dimensions.unit",
44
- product_width: "variants[index].productMeasurements.dimensions.width&' '&variants[index].productMeasurements.dimensions.unit",
45
- product_height: "variants[index].productMeasurements.dimensions.height&' '&variants[index].productMeasurements.dimensions.unit",
46
- product_highlight: "short_description",
47
- product_weight: "variants[index].productMeasurements.weight.value&' '&variants[index].productMeasurements.weight.unit",
48
- /*question_and_answer: [
49
- {
50
- question: Text,
51
- answer: Text,
52
- },
53
- ],*/ size: "variants[index].sizeSpecification.hasMeasurement.value",
54
- size_type: "variants[index].sizeSpecification.sizeGroup",
55
- size_system: "variants[index].sizeSpecification.sizeSystem",
56
- variant_option: "variants[index].sizeSpecification.attributes",
57
- ads_redirect: null,
58
- custom_label_0: null,
59
- custom_label_1: null,
60
- custom_label_2: null,
61
- custom_label_3: null,
62
- custom_label_4: null,
63
- promotion_id: null,
64
- lifestyle_image_link: null,
65
- short_title: "short_name",
66
- shipping_length: "variants[index].shippingMeasurements.dimensions.length",
67
- shipping_width: "variants[index].shippingMeasurements.dimensions.width",
68
- shipping_height: "variants[index].shippingMeasurements.dimensions.height",
69
- shipping_label: null
70
- };
71
- /**
72
- *
73
- * @param {string} field
74
- * @param {Product} InventoryProduct
75
- */ function $e409a6a48e9bf1c0$var$GoogleProductAPIField(field, InventoryProduct) {}
76
- const $e409a6a48e9bf1c0$var$GoogleProductCategory = {
77
- "Animals & Pet Supplies": {
78
- index: 1,
79
- "Live Animals": {
80
- index: 3237
81
- },
82
- "Pet Supplies": {
83
- index: 2,
84
- "Bird Supplies": {
85
- index: 3,
86
- "Bird Cage Accessories": {
87
- index: 7385,
88
- "Bird Cage Bird Baths": {
89
- index: 499954
90
- },
91
- "Bird Cage Food & Water Dishes": {
92
- index: 7386
93
- }
94
- },
95
- "Bird Cages & Stands": {
96
- index: 4989
97
- },
98
- "Bird Food": {
99
- index: 4990
100
- },
101
- "Bird Gyms & Playstands": {
102
- index: 7398
103
- },
104
- "Bird Ladders & Perches": {
105
- index: 4991
106
- },
107
- "Bird Toys": {
108
- index: 4992
109
- },
110
- "Bird Treats": {
111
- index: 4993
112
- }
113
- },
114
- "Cat Supplies": {
115
- index: 4,
116
- "": {}
117
- }
118
- }
119
- }
120
- };
121
-
122
-
123
- export {$e409a6a48e9bf1c0$export$4059922dac929494 as GoogleAPIProductMap};
124
- //# sourceMappingURL=InventoryLogic.b90f66ea.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;AAAA;;;CAGC,GACD,sEAAsE;AACtE,YAAY;;AAmJL,MAAM,4CAAsB;IAChC,kCAAkC;IAClC,IAAI;IACJ,OAAO;IACP,eAAe;IACf,kBAAkB;IAClB,aAAa;IACb,MAAM;IACN,iEAAiE;IACjE,YAAY;IACZ,uBAAuB;IACvB,YAAY;IACZ,oBAAoB;IACpB,aAAa;IACb,uCAAuC;IACvC,cAAc;IACd,mBAAmB;IACnB,oBAAoB;IACpB,iBAAiB;IACjB,OAAO;IACP,YAAY;IACZ,2BAA2B;IAC3B,yBAAyB;IACzB,cAAc;IACd,OAAO;IACP,MAAM;IACN,KAAK;IACL,OAAO;IACP,WAAW;IACX,QAAQ;IACR,WAAW;IACX,OAAO;IACP,UAAU;IACV,SAAS;IACT,gBAAgB;IAChB,eAAe;IACf,gBAAgB;IAChB,mBAAmB;IACnB,gBAAgB;IAChB;;;;;KAKE,GACF,MAAM;IACN,WAAW;IACX,aAAa;IACb,gBAAgB;IAChB,cAAc;IACd,gBAAgB;IAChB,gBAAgB;IAChB,gBAAgB;IAChB,gBAAgB;IAChB,gBAAgB;IAChB,cAAc;IACd,sBAAsB;IACtB,aAAa;IACb,iBAAiB;IACjB,gBAAgB;IAChB,iBAAiB;IACjB,gBAAgB;AACnB;AAEA;;;;CAIC,GACD,SAAS,4CAAsB,KAAK,EAAE,gBAAgB,GAEtD;AAEA,MAAM,8CAAwB;IAC3B,0BAA0B;QACvB,OAAO;QACP,gBAAgB;YACb,OAAO;QACV;QACA,gBAAgB;YACb,OAAO;YACP,iBAAiB;gBACd,OAAO;gBACP,yBAAyB;oBACtB,OAAO;oBACP,wBAAwB;wBACrB,OAAO;oBACV;oBACA,iCAAiC;wBAC9B,OAAO;oBACV;gBACH;gBACA,uBAAuB;oBACpB,OAAO;gBACV;gBACA,aAAa;oBACV,OAAO;gBACV;gBACA,0BAA0B;oBACvB,OAAO;gBACV;gBACA,0BAA0B;oBACvB,OAAO;gBACV;gBACA,aAAa;oBACV,OAAO;gBACV;gBACA,eAAe;oBACZ,OAAO;gBACV;YACH;YACA,gBAAgB;gBACb,OAAO;gBACP,IAAI,CAEJ;YACH;QAEH;IACH;AACH","sources":["business/Product/GoogleMerchantAPI.js"],"sourcesContent":["/**\n * Typedefs, constants, support functions and database operations related to Products\n * @module GoogleProduct\n */\n//////////////////////////////////////////////////////////////////////\n// Constants\n\nimport { index, string } from \"mathjs\";\n\n/**\n * @typedef {string} SKU\n */\n/**\n * @typedef {string} Name\n */\n\n/**\n * Google Merchant API Size/Fit Options\n * @typedef {\"regular\"|\"petite\"|\"maternity\"|\"big\"|\"tall\"|\"plus\"} SizeTypeEnumeration\n */\n\n/**\n * Google Merchant API Size System/Country Options\n * @typedef {\"US\"|\"UK\"|\"EU\"|\"DE\"|\"FR\"|\"JP\"|\"CN\"|\"IT\"|\"BR\"|\"MEX\"|\"AU\"} SizeSystemEnumeration\n */\n\n/**\n * Google Merchant API Variant-identifying dimensions and their values\n * @typedef {object} GoogleAPIVariantOption\n * @property {Text} name\n * @property {Text} value\n */\n\n/**\n * Google Merchant API User-, merchant-, and manufacturer-authored questions and answers about the product.\n * @typedef {object} QAObject\n * @property {Text} question Max. 1000 characters.\n * @property {Text} answer Max. 1000 characters.\n */\n\n/**\n * a Google Product record\n * @typedef {object} GoogleProductAPI\n * @property {SKU} id id of Product also used as sku\n * @property {Name} title title (name) of Product\n * @property {Text} item_group_id ID for a group of products that come in different versions (variants)\n * @property {Text} item_group_title name for a group of products that come in different versions (variants)\n * @property {string} description Basic description of the product\n * @property {URL} link Your product’s landing page\n * @property {URL} image_link The URL of your product’s main image\n * @property {?URL} additional_image_link The URL of your product’s main image\n * @property {?URL} video_link Additional link to show a video of your product.\n * @property {?URL} virtual_model_link Additional link to show a 3D model of your product.\n * @property {?URL} mobile_link\n * Your product’s mobile-optimized landing page when you have a different URL for mobile and desktop traffic\n * @property {\"in_stock\"|\"out_of_stock\"|\"preorder\"|\"backorder\"} availability\n * Accurately submit the product's availability and match the availability\n * from your landing page, checkout pages, and structured data (for\n * example, “in_stock” or “out_of_stock” in your Schema.org markup).\n * If an item is out of stock, the price must still be clearly visible\n * on the landing page.\n * Provide the availability date [availability_date] attribute if you\n * submit preorder [preorder] or backorder [backorder] as the availability value.\n * @property {string|ISO8601} availability_date\n * Use this attribute if your product's availability is set to preorder.\n * Provide a value up to one year in the future.\n * The availability date should also be added to the product’s landing\n * page and be clear to your customers (for example, “May 6, 2023”).\n * If an exact date can’t be provided, you can use an estimated date\n * (for example, “May 2023”).\n * @property {?string|ISO4217} cost_of_goods_sold\n * The costs associated with the sale of a particular product as defined\n * by the accounting convention you set up. These costs may include\n * material, labor, freight, or other overhead expenses. By\n * submittingthe COGS for your products, you gain insights about\n * other metrics, such as your gross margin and the amount of revenue\n * generated by your ads and free listings.\n * @property {ISO8601} expiration_date The date that your product should stop showing\n * @property {number|ISO4217} price\n * @property {?number|ISO4217} sale_price\n * @property {?DateRange} sale_price_effective_date\n * @property {?GoogleProductTaxonomy} google_product_category\n * @property {?string} product_type \"Casual\" google_product_category\n * @property {Text} brand\n * The brand(s) associated with a product or service, or the brand(s) maintained by an organization or business user.\n * @property {gtin8 | gtin12 | gtin13 | gtin14 | gtin | isbn} gtin\n * @property {Text} mpn\n * The Manufacturer Part Number (MPN) of the product, or the product to which the offer refers.\n * @property {\"no\"|\"yes\"} adult\n * @property {Text} age_group newborn | infant | toddler | kids | adult\n * @property {\"male\"|\"female\"|\"unisex\"} gender male female unisex\n * @property {Text} color The color of the product.\n * @property {?\"new\"|\"refurbished\"|\"used\"|null} condition\n * @property {?Text} material A material that something is made from, e.g. leather, wool, cotton, paper.\n * @property {?Text} pattern A pattern that something has\n * @property {?Text}product_length Your product's length\n * @property {?Text}product_width Your product's width\n * @property {?Text}product_height Your product's height\n * Use the same unit of measurement for each product dimension attribute\n * (including product length, width, and height). Otherwise, the\n * information won't be displayed.\n * @property {?Text} product_highlight The most relevant highlights of your products\n * @property {?Text} product_weight Your product's weight\n * @property {?Array.QAObject} question_and_answer User-, merchant-, and\n * manufacturer-authored questions and answers about the product.\n * @property {Text} size\n * @property {SizeTypeEnumeration} size_type Your apparel product’s cut\n * @property {SizeSystemEnumeration} size_system\n * The country of the size system used by your produc\n * @property {Array.GoogleAPIVariantOption} variant_option\n * Variant-identifying dimensions and their values\n * @property {?URL} ads_redirect\n * A URL used to specify additional parameters for your product page.\n * Customers will be sent to this URL rather than the value that you\n * submit for the link [link] or mobile link [mobile_link] attributes\n * @property {?Text} custom_label_0\n * Label that you assign to a product to help organize bidding and\n * reporting in Shopping campaigns\n * @property {?Text} custom_label_1\n * Label that you assign to a product to help organize bidding and\n * reporting in Shopping campaigns\n * @property {?Text} custom_label_2\n * Label that you assign to a product to help organize bidding and\n * reporting in Shopping campaigns\n * @property {?Text} custom_label_3\n * Label that you assign to a product to help organize bidding and\n * reporting in Shopping campaigns\n * @property {?Text} custom_label_4\n * Label that you assign to a product to help organize bidding and\n * reporting in Shopping campaigns\n * @property {?Text} promotion_id An identifier that allows you to\n * match products to promotions\n * @property {?URL} lifestyle_image_link\n * Attribute used to include the URL for a lifestyle image for your product\n * @property {?Text} short_title Short product name. Only available for Demand Gen Ads, including\n * YouTube, Gmail, Maps, Discover app, Google Display Network, and Google Video Partners.\n * @property {?Text} shipping_label\n * Label that you assign to a product to help assign correct\n * shipping times and transit costs in Merchant Center account settings\n * @property {?Text} shipping_weight The weight of the product used to\n * calculate the shipping cost\n * @property {?Text} shipping_length The length of the product used to\n * calculate the shipping cost by dimensional weight\n * @property {?Text} shipping_width The width of the product used to\n * calculate the shipping cost by dimensional weight\n * @property {?Text} shipping_height The height of the product used to\n * calculate the shipping cost by dimensional weight\n */\n\n/**\n * @type {GoogleProductAPI}\n */\nexport const GoogleAPIProductMap = {\n //id needs programmatic processing\n id: \"variants[index].sku\", //id of Product also used as sku\n title: \"name\", //title (name) of Product\n item_group_id: \"id\",\n item_group_title: \"title\",\n description: \"description\",\n link: \"URL\",\n //image_link and image_additional_links need programmatic process\n image_link: \"variants[index].image.URL\",\n additional_image_link: \"mediaobject.images[all]\",\n video_link: \"mediaobject.video_image.video_link\",\n virtual_model_link: \"mediaobject.virtual_model.virtual_model_link\",\n mobile_link: null,\n //availability needs to be programmatic\n availability: null, //\"in_stock\" | \"out_of_stock\" | \"preorder\" | \"backorder\",\n availability_date: \"variants[index].availability_date\",\n cost_of_goods_sold: null,\n expiration_date: \"variants[index].expiration_date\",\n price: \"variants[index].pricing.baseprice.value| |variants[index].pricing.baseprice.currencyDescription.displayName\",\n sale_price: \"variants[index].pricing.saleprice.value| |variants[index].pricing.saleprice.currencyDescription.displayName\",\n sale_price_effective_date: \"variants[index].pricing.effectiveDate.\",\n google_product_category: \"google_product_category\",\n product_type: \"product_type\",\n brand: \"brand.name\",\n gtin: \"variants[index].gtin\",\n mpn: \"variants[index].gtin\",\n adult: \"demographics.adult\",\n age_group: \"demographics.age_group\",\n gender: \"demographics.gender\",\n condition: \"attributes.condition\",\n color: \"attributes.colors[0]\",\n material: \"attributes.materials[0]\",\n pattern: \"attributes.patterns[0]\",\n product_length: \"variants[index].productMeasurements.dimensions.length&' '&variants[index].productMeasurements.dimensions.unit\",\n product_width: \"variants[index].productMeasurements.dimensions.width&' '&variants[index].productMeasurements.dimensions.unit\",\n product_height: \"variants[index].productMeasurements.dimensions.height&' '&variants[index].productMeasurements.dimensions.unit\",\n product_highlight: \"short_description\",\n product_weight: \"variants[index].productMeasurements.weight.value&' '&variants[index].productMeasurements.weight.unit\",\n /*question_and_answer: [\n {\n question: Text,\n answer: Text,\n },\n ],*/\n size: \"variants[index].sizeSpecification.hasMeasurement.value\",\n size_type: \"variants[index].sizeSpecification.sizeGroup\",\n size_system: \"variants[index].sizeSpecification.sizeSystem\",\n variant_option: \"variants[index].sizeSpecification.attributes\",\n ads_redirect: null,\n custom_label_0: null,\n custom_label_1: null,\n custom_label_2: null,\n custom_label_3: null,\n custom_label_4: null,\n promotion_id: null,\n lifestyle_image_link: null,\n short_title: \"short_name\",\n shipping_length: \"variants[index].shippingMeasurements.dimensions.length\",\n shipping_width: \"variants[index].shippingMeasurements.dimensions.width\",\n shipping_height: \"variants[index].shippingMeasurements.dimensions.height\",\n shipping_label: null,\n}\n\n/**\n * \n * @param {string} field \n * @param {Product} InventoryProduct \n */\nfunction GoogleProductAPIField(field, InventoryProduct) {\n\n}\n\nconst GoogleProductCategory = {\n \"Animals & Pet Supplies\": {\n index: 1,\n \"Live Animals\": {\n index: 3237,\n },\n \"Pet Supplies\": {\n index: 2,\n \"Bird Supplies\": {\n index: 3,\n \"Bird Cage Accessories\": {\n index: 7385,\n \"Bird Cage Bird Baths\": {\n index: 499954,\n },\n \"Bird Cage Food & Water Dishes\": {\n index: 7386\n },\n },\n \"Bird Cages & Stands\": {\n index: 4989,\n },\n \"Bird Food\": {\n index: 4990,\n },\n \"Bird Gyms & Playstands\": {\n index: 7398,\n },\n \"Bird Ladders & Perches\": {\n index: 4991,\n },\n \"Bird Toys\": {\n index: 4992,\n },\n \"Bird Treats\": {\n index: 4993,\n },\n },\n \"Cat Supplies\": {\n index: 4,\n \"\": {\n\n }\n }\n\n }\n }\n};\n"],"names":[],"version":3,"file":"InventoryLogic.b90f66ea.js.map"}
@@ -1,39 +0,0 @@
1
- import {MESSAGES as $fefa9c41cb73ae0b$export$af7faffe10421f14} from "./InventoryLogic.d27e84a7.js";
2
- import {writeRecord as $eflym$writeRecord, collectRecordsByFilter as $eflym$collectRecordsByFilter} from "@leaddreamer/firebase-wrapper";
3
-
4
- /**
5
- * Typedefs, constants, support functions and database operations related to Messaging
6
- * @module Messages
7
- */
8
-
9
- async function $b08abff958f5c1f9$export$1d949c62ce6e9407(messageEvent) {
10
- //NOTE
11
- const parentRef = messageEvent.refPath;
12
- delete messageEvent.refPath;
13
- delete messageEvent.Id;
14
- return (0, $eflym$writeRecord)((0, $fefa9c41cb73ae0b$export$af7faffe10421f14), messageEvent, parentRef //parent
15
- );
16
- }
17
- async function $b08abff958f5c1f9$export$fb609933e410a9ca(record) {
18
- const sortArray = [
19
- {
20
- fieldRef: "timestamp",
21
- dirStr: "desc"
22
- }
23
- ];
24
- const chain = await (0, $eflym$collectRecordsByFilter)((0, $fefa9c41cb73ae0b$export$af7faffe10421f14), record.refPath, null, sortArray, 1);
25
- return chain[0].event;
26
- }
27
- async function $b08abff958f5c1f9$export$404463f191aa95a1(record) {
28
- const sortArray = [
29
- {
30
- fieldRef: "timestamp",
31
- dirStr: "desc"
32
- }
33
- ];
34
- return (0, $eflym$collectRecordsByFilter)((0, $fefa9c41cb73ae0b$export$af7faffe10421f14), record.refPath, null, sortArray);
35
- }
36
-
37
-
38
- export {$b08abff958f5c1f9$export$1d949c62ce6e9407 as logMessageEvent, $b08abff958f5c1f9$export$fb609933e410a9ca as messageStatus, $b08abff958f5c1f9$export$404463f191aa95a1 as messageEvents};
39
- //# sourceMappingURL=InventoryLogic.bb447b4c.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;AAAA;;;CAGC;;AAmBM,eAAe,0CAAgB,YAAY;IAChD,MAAM;IACN,MAAM,YAAY,aAAa,OAAO;IACtC,OAAO,aAAa,OAAO;IAC3B,OAAO,aAAa,EAAE;IAEtB,OAAO,CAAA,GAAA,kBAAU,EACf,CAAA,GAAA,yCAAO,GACP,cACA,UAAU,QAAQ;;AAEtB;AASO,eAAe,0CAAc,MAAM;IACxC,MAAM,YAAY;QAChB;YACE,UAAU;YACV,QAAQ;QACV;KACD;IACD,MAAM,QAAQ,MAAM,CAAA,GAAA,6BAAqB,EACvC,CAAA,GAAA,yCAAO,GACP,OAAO,OAAO,EACd,MACA,WACA;IAGF,OAAO,KAAK,CAAC,EAAE,CAAC,KAAK;AACvB;AASO,eAAe,0CAAc,MAAM;IACxC,MAAM,YAAY;QAChB;YACE,UAAU;YACV,QAAQ;QACV;KACD;IACD,OAAO,CAAA,GAAA,6BAAqB,EAC1B,CAAA,GAAA,yCAAO,GACP,OAAO,OAAO,EACd,MACA;AAEJ","sources":["business/Messages/index.js"],"sourcesContent":["/**\n * Typedefs, constants, support functions and database operations related to Messaging\n * @module Messages\n */\nimport {\n writeRecord,\n collectRecordsByFilter,\n} from \"@leaddreamer/firebase-wrapper\";\n\nimport { MESSAGES } from \"../boilerplate/index.js\";\n\n/**\n * Message \"receipts\" are saved in a MESSAGES collection directly under\n * the relevant object. Each is saved as distinct object. They can be\n * queried by the parent event, sorted by the timestamp, to find the latest\n * status. Note that the messaging systens ADDS the rlevant .Id and .refPath\n * to the \"message\" so we can do this.\n * @param {MessageEvent} messageEvent - the webhook event structure\n * @returns {Promise<RecordDocument>} - document as written to database - note NOT the stored\n * document, but the PRE-MERGED document including Id and refPath.\n *\n */\nexport async function logMessageEvent(messageEvent) {\n //NOTE\n const parentRef = messageEvent.refPath;\n delete messageEvent.refPath;\n delete messageEvent.Id;\n\n return writeRecord(\n MESSAGES, //tableName\n messageEvent, //record\n parentRef //parent\n );\n}\n\n/**\n * fetches the most recent status message event on a particular object\n * Could involve multiple messages, statuses, etc\n * @param {documentRecord} record - object to find message history for. Currently\n * only Receipts and PledgeTickets\n * @returns {Promise<string>} event type/status - \"processed\", \"bounced\", \"delivered\", etc\n */\nexport async function messageStatus(record) {\n const sortArray = [\n {\n fieldRef: \"timestamp\",\n dirStr: \"desc\",\n },\n ];\n const chain = await collectRecordsByFilter(\n MESSAGES,\n record.refPath,\n null, //filterArray\n sortArray,\n 1\n );\n\n return chain[0].event;\n}\n\n/**\n * fetches all of the message events associated with a partucular record, sorted\n * by reverse timestamp\n * @param {documentRecord} record - object to find message history for. Currently\n * only Receipts and PledgeTickets\n * @returns {Promise<Array<MessageEvent>>} array of message events\n */\nexport async function messageEvents(record) {\n const sortArray = [\n {\n fieldRef: \"timestamp\",\n dirStr: \"desc\",\n },\n ];\n return collectRecordsByFilter(\n MESSAGES,\n record.refPath,\n null, //filterArray\n sortArray\n );\n}\n"],"names":[],"version":3,"file":"InventoryLogic.bb447b4c.js.map"}
@@ -1,75 +0,0 @@
1
- /**
2
- * Shared constants and symbols
3
- * @module Boilerplate
4
- */ /////////////////////////////////////////////////////////////
5
- // generic constants
6
- const $fefa9c41cb73ae0b$export$7d0a9b0c57bf84fd = `unsubscribeKeys`;
7
- const $fefa9c41cb73ae0b$export$6890d3564b1f252d = "Addresses";
8
- const $fefa9c41cb73ae0b$export$6f454e69bce3a691 = `Business`; //mostly used for URL of management tree
9
- const $fefa9c41cb73ae0b$export$9547bc19be285f8c = `Brands`;
10
- const $fefa9c41cb73ae0b$export$73f9b6e7973e6848 = `ManagedBrands`;
11
- const $fefa9c41cb73ae0b$export$a338fcb90fb9aa37 = `Organizations`;
12
- const $fefa9c41cb73ae0b$export$e72e4cc6cbc6ed26 = `ManagedOrganizations`;
13
- const $fefa9c41cb73ae0b$export$398ebe85ebcaa41f = `PrivateData`;
14
- const $fefa9c41cb73ae0b$export$e651cf32bc3f78a4 = `BusinessData`;
15
- const $fefa9c41cb73ae0b$export$466d3e044dd15afb = `logistics`;
16
- const $fefa9c41cb73ae0b$export$eb747620ce9c5e16 = `Commodity`;
17
- const $fefa9c41cb73ae0b$export$695940e05bf65de8 = $fefa9c41cb73ae0b$export$eb747620ce9c5e16;
18
- const $fefa9c41cb73ae0b$export$4843f9d856059ffd = `LineItem`;
19
- const $fefa9c41cb73ae0b$export$f079c6e3d7477fb7 = $fefa9c41cb73ae0b$export$4843f9d856059ffd;
20
- const $fefa9c41cb73ae0b$export$32912c8ca0a712d8 = `LaborRates`;
21
- const $fefa9c41cb73ae0b$export$af7faffe10421f14 = `Messages`;
22
- const $fefa9c41cb73ae0b$export$e36553b0ff5db35a = `Products`;
23
- const $fefa9c41cb73ae0b$export$4f02bea739260915 = $fefa9c41cb73ae0b$export$e36553b0ff5db35a;
24
- const $fefa9c41cb73ae0b$export$eaa266db8852871e = `Payment`;
25
- const $fefa9c41cb73ae0b$export$fadbf22af86be55a = $fefa9c41cb73ae0b$export$eaa266db8852871e;
26
- const $fefa9c41cb73ae0b$export$5f768699f44cc740 = `Cards`;
27
- const $fefa9c41cb73ae0b$export$88e60f3c1cd6ae1f = `Transfers`;
28
- const $fefa9c41cb73ae0b$export$1a96cd5ee36c0372 = `Fundamentals`;
29
- const $fefa9c41cb73ae0b$export$e313271f328bdd7d = `PayoutRates`;
30
- const $fefa9c41cb73ae0b$export$6b29f6d6b64b8c84 = `Rates`;
31
- const $fefa9c41cb73ae0b$export$af5764009005aa8e = `MCC`;
32
- const $fefa9c41cb73ae0b$export$1bd589465335bb9d = `business_type`;
33
- const $fefa9c41cb73ae0b$export$5eb0c58c8af5c758 = `access`;
34
- const $fefa9c41cb73ae0b$export$d66f9cc3fc90ff67 = `accessTo`;
35
- const $fefa9c41cb73ae0b$export$f9865a0a7f208c15 = `stages`;
36
- const $fefa9c41cb73ae0b$export$47007d96f3617630 = $fefa9c41cb73ae0b$export$f9865a0a7f208c15;
37
- const $fefa9c41cb73ae0b$export$ca8f11448d1a1116 = `material`;
38
- const $fefa9c41cb73ae0b$export$b7815f33793b967 = $fefa9c41cb73ae0b$export$ca8f11448d1a1116;
39
- const $fefa9c41cb73ae0b$export$cfa5730cd5118215 = `Receipts`;
40
- const $fefa9c41cb73ae0b$export$a037d132965e1c9f = "units";
41
- const $fefa9c41cb73ae0b$export$97361b7a0c542045 = $fefa9c41cb73ae0b$export$a037d132965e1c9f;
42
- const $fefa9c41cb73ae0b$export$ff09b90989b21a8 = "User";
43
- const $fefa9c41cb73ae0b$export$5a898dd3a28f57e9 = $fefa9c41cb73ae0b$export$ff09b90989b21a8;
44
- const $fefa9c41cb73ae0b$export$1bfdae073fb20e6c = "markups";
45
- const $fefa9c41cb73ae0b$export$9e15ff8aa6bc996f = `base`;
46
- const $fefa9c41cb73ae0b$export$d93f73eb990136ee = `highValue`;
47
- const $fefa9c41cb73ae0b$export$3ccfc9db9b7bf43f = `service`;
48
- const $fefa9c41cb73ae0b$export$5d39addb0306dfd4 = `fabrication`;
49
- const $fefa9c41cb73ae0b$export$75be49b93be74cb5 = `wholesale`;
50
- const $fefa9c41cb73ae0b$export$4466b7859aa06ffd = `retail`;
51
- const $fefa9c41cb73ae0b$export$22e7de231b4ec209 = `succeeded`;
52
- const $fefa9c41cb73ae0b$export$1d0cc9f143bfe9fc = `customer`;
53
- const $fefa9c41cb73ae0b$export$f437a67b3be18bd2 = `customerAddress`;
54
- const $fefa9c41cb73ae0b$export$fe909d0e7ec8aa88 = {
55
- COMPONENT_RANGE: {
56
- min: 0.01,
57
- max: 20.0,
58
- dec: 2,
59
- symbol: "$"
60
- },
61
- COMPONENT_COUNT_RANGE: {
62
- min: 1,
63
- max: 10
64
- },
65
- ISBN_LENGTH: {
66
- variant: 10
67
- }
68
- };
69
- const $fefa9c41cb73ae0b$export$72581e25313abf48 = "COMPONENT_RANGE";
70
- const $fefa9c41cb73ae0b$export$d141374f02dd06d9 = "COMPONENT_COUNT_RANGE";
71
- const $fefa9c41cb73ae0b$export$dbb3cd0a4caa6254 = "ISBN_LENGTH"; //end constants
72
-
73
-
74
- export {$fefa9c41cb73ae0b$export$7d0a9b0c57bf84fd as UNSUBSCRIBEKEYS, $fefa9c41cb73ae0b$export$6890d3564b1f252d as ADDRESSES, $fefa9c41cb73ae0b$export$6f454e69bce3a691 as BUSINESS, $fefa9c41cb73ae0b$export$9547bc19be285f8c as BRANDS, $fefa9c41cb73ae0b$export$73f9b6e7973e6848 as MANAGEDBRANDS, $fefa9c41cb73ae0b$export$a338fcb90fb9aa37 as ORGANIZATIONS, $fefa9c41cb73ae0b$export$e72e4cc6cbc6ed26 as MANAGEDORGANIZATIONS, $fefa9c41cb73ae0b$export$398ebe85ebcaa41f as PRIVATEDATA, $fefa9c41cb73ae0b$export$e651cf32bc3f78a4 as BUSINESSDATA, $fefa9c41cb73ae0b$export$466d3e044dd15afb as LOGISTICS, $fefa9c41cb73ae0b$export$eb747620ce9c5e16 as COMMODITY, $fefa9c41cb73ae0b$export$695940e05bf65de8 as COMMODITIES, $fefa9c41cb73ae0b$export$4843f9d856059ffd as LINEITEM, $fefa9c41cb73ae0b$export$f079c6e3d7477fb7 as LINEITEMS, $fefa9c41cb73ae0b$export$32912c8ca0a712d8 as LABORRATES, $fefa9c41cb73ae0b$export$af7faffe10421f14 as MESSAGES, $fefa9c41cb73ae0b$export$e36553b0ff5db35a as PRODUCT, $fefa9c41cb73ae0b$export$4f02bea739260915 as PRODUCTS, $fefa9c41cb73ae0b$export$eaa266db8852871e as PAYMENT, $fefa9c41cb73ae0b$export$fadbf22af86be55a as PAYMENTS, $fefa9c41cb73ae0b$export$5f768699f44cc740 as CARDS, $fefa9c41cb73ae0b$export$88e60f3c1cd6ae1f as TRANSFERS, $fefa9c41cb73ae0b$export$1a96cd5ee36c0372 as FUNDAMENTALS, $fefa9c41cb73ae0b$export$e313271f328bdd7d as PAYOUTRATES, $fefa9c41cb73ae0b$export$6b29f6d6b64b8c84 as RATES, $fefa9c41cb73ae0b$export$af5764009005aa8e as MCC, $fefa9c41cb73ae0b$export$1bd589465335bb9d as BUSINESS_TYPE, $fefa9c41cb73ae0b$export$5eb0c58c8af5c758 as ACCESS, $fefa9c41cb73ae0b$export$d66f9cc3fc90ff67 as ACCESSTO, $fefa9c41cb73ae0b$export$f9865a0a7f208c15 as STAGE, $fefa9c41cb73ae0b$export$47007d96f3617630 as STAGES, $fefa9c41cb73ae0b$export$ca8f11448d1a1116 as MATERIAL, $fefa9c41cb73ae0b$export$b7815f33793b967 as MATERIALS, $fefa9c41cb73ae0b$export$cfa5730cd5118215 as RECEIPTS, $fefa9c41cb73ae0b$export$a037d132965e1c9f as UNITS, $fefa9c41cb73ae0b$export$97361b7a0c542045 as UNIT, $fefa9c41cb73ae0b$export$ff09b90989b21a8 as USER, $fefa9c41cb73ae0b$export$5a898dd3a28f57e9 as USERS, $fefa9c41cb73ae0b$export$1bfdae073fb20e6c as MARKUPS, $fefa9c41cb73ae0b$export$9e15ff8aa6bc996f as BASE, $fefa9c41cb73ae0b$export$d93f73eb990136ee as HIGHVALUE, $fefa9c41cb73ae0b$export$3ccfc9db9b7bf43f as SERVICE, $fefa9c41cb73ae0b$export$5d39addb0306dfd4 as FABRICATION, $fefa9c41cb73ae0b$export$75be49b93be74cb5 as WHOLESALE, $fefa9c41cb73ae0b$export$4466b7859aa06ffd as RETAIL, $fefa9c41cb73ae0b$export$22e7de231b4ec209 as PAYMENT_SUCCEEDED, $fefa9c41cb73ae0b$export$1d0cc9f143bfe9fc as CUSTOMER, $fefa9c41cb73ae0b$export$f437a67b3be18bd2 as CUSTOMERADDRESS, $fefa9c41cb73ae0b$export$fe909d0e7ec8aa88 as fakerJSON, $fefa9c41cb73ae0b$export$72581e25313abf48 as COMPONENT_RANGE, $fefa9c41cb73ae0b$export$d141374f02dd06d9 as COMPONENT_COUNT_RANGE, $fefa9c41cb73ae0b$export$dbb3cd0a4caa6254 as ISBN_LENGTH};
75
- //# sourceMappingURL=InventoryLogic.d27e84a7.js.map
@@ -1 +0,0 @@
1
- {"mappings":"AAAA;;;CAGC,GAED,6DAA6D;AAC7D,oBAAoB;AACb,MAAM,4CAAkB,CAAC,eAAe,CAAC;AACzC,MAAM,4CAAY;AAClB,MAAM,4CAAW,CAAC,QAAQ,CAAC,EAAE,wCAAwC;AACrE,MAAM,4CAAS,CAAC,MAAM,CAAC;AACvB,MAAM,4CAAgB,CAAC,aAAa,CAAC;AACrC,MAAM,4CAAgB,CAAC,aAAa,CAAC;AACrC,MAAM,4CAAuB,CAAC,oBAAoB,CAAC;AACnD,MAAM,4CAAc,CAAC,WAAW,CAAC;AACjC,MAAM,4CAAe,CAAC,YAAY,CAAC;AACnC,MAAM,4CAAY,CAAC,SAAS,CAAC;AAC7B,MAAM,4CAAY,CAAC,SAAS,CAAC;AAC7B,MAAM,4CAAc;AACpB,MAAM,4CAAW,CAAC,QAAQ,CAAC;AAC3B,MAAM,4CAAY;AAClB,MAAM,4CAAa,CAAC,UAAU,CAAC;AAC/B,MAAM,4CAAW,CAAC,QAAQ,CAAC;AAC3B,MAAM,4CAAU,CAAC,QAAQ,CAAC;AAC1B,MAAM,4CAAW;AACjB,MAAM,4CAAU,CAAC,OAAO,CAAC;AACzB,MAAM,4CAAW;AACjB,MAAM,4CAAQ,CAAC,KAAK,CAAC;AACrB,MAAM,4CAAY,CAAC,SAAS,CAAC;AAC7B,MAAM,4CAAe,CAAC,YAAY,CAAC;AACnC,MAAM,4CAAc,CAAC,WAAW,CAAC;AACjC,MAAM,4CAAQ,CAAC,KAAK,CAAC;AACrB,MAAM,4CAAM,CAAC,GAAG,CAAC;AACjB,MAAM,4CAAgB,CAAC,aAAa,CAAC;AACrC,MAAM,4CAAS,CAAC,MAAM,CAAC;AACvB,MAAM,4CAAW,CAAC,QAAQ,CAAC;AAC3B,MAAM,4CAAQ,CAAC,MAAM,CAAC;AACtB,MAAM,4CAAS;AACf,MAAM,4CAAW,CAAC,QAAQ,CAAC;AAC3B,MAAM,2CAAY;AAClB,MAAM,4CAAW,CAAC,QAAQ,CAAC;AAC3B,MAAM,4CAAQ;AACd,MAAM,4CAAO;AACb,MAAM,2CAAO;AACb,MAAM,4CAAQ;AAEd,MAAM,4CAAU;AAEhB,MAAM,4CAAO,CAAC,IAAI,CAAC;AACnB,MAAM,4CAAY,CAAC,SAAS,CAAC;AAC7B,MAAM,4CAAU,CAAC,OAAO,CAAC;AAEzB,MAAM,4CAAc,CAAC,WAAW,CAAC;AACjC,MAAM,4CAAY,CAAC,SAAS,CAAC;AAC7B,MAAM,4CAAS,CAAC,MAAM,CAAC;AAGvB,MAAM,4CAAoB,CAAC,SAAS,CAAC;AAGrC,MAAM,4CAAW,CAAC,QAAQ,CAAC;AAC3B,MAAM,4CAAkB,CAAC,eAAe,CAAC;AAEzC,MAAM,4CAAY;IACvB,iBAAiB;QACf,KAAK;QACL,KAAK;QACL,KAAK;QACL,QAAQ;IACV;IACA,uBAAuB;QAAE,KAAK;QAAG,KAAK;IAAG;IACzC,aAAa;QAAE,SAAS;IAAG;AAC7B;AAEO,MAAM,4CAAkB;AACxB,MAAM,4CAAwB;AAC9B,MAAM,4CAAc,eAE3B,eAAe","sources":["business/boilerplate/index.js"],"sourcesContent":["/**\n * Shared constants and symbols\n * @module Boilerplate\n */\n\n/////////////////////////////////////////////////////////////\n// generic constants\nexport const UNSUBSCRIBEKEYS = `unsubscribeKeys`;\nexport const ADDRESSES = \"Addresses\";\nexport const BUSINESS = `Business`; //mostly used for URL of management tree\nexport const BRANDS = `Brands`;\nexport const MANAGEDBRANDS = `ManagedBrands`;\nexport const ORGANIZATIONS = `Organizations`;\nexport const MANAGEDORGANIZATIONS = `ManagedOrganizations`;\nexport const PRIVATEDATA = `PrivateData`;\nexport const BUSINESSDATA = `BusinessData`;\nexport const LOGISTICS = `logistics`;\nexport const COMMODITY = `Commodity`;\nexport const COMMODITIES = COMMODITY;\nexport const LINEITEM = `LineItem`;\nexport const LINEITEMS = LINEITEM;\nexport const LABORRATES = `LaborRates`;\nexport const MESSAGES = `Messages`;\nexport const PRODUCT = `Products`;\nexport const PRODUCTS = PRODUCT;\nexport const PAYMENT = `Payment`;\nexport const PAYMENTS = PAYMENT;\nexport const CARDS = `Cards`;\nexport const TRANSFERS = `Transfers`;\nexport const FUNDAMENTALS = `Fundamentals`;\nexport const PAYOUTRATES = `PayoutRates`;\nexport const RATES = `Rates`;\nexport const MCC = `MCC`;\nexport const BUSINESS_TYPE = `business_type`;\nexport const ACCESS = `access`;\nexport const ACCESSTO = `accessTo`;\nexport const STAGE = `stages`;\nexport const STAGES = STAGE;\nexport const MATERIAL = `material`;\nexport const MATERIALS = MATERIAL;\nexport const RECEIPTS = `Receipts`;\nexport const UNITS = \"units\";\nexport const UNIT = UNITS;\nexport const USER = \"User\";\nexport const USERS = USER;\n\nexport const MARKUPS = \"markups\";\n\nexport const BASE = `base`;\nexport const HIGHVALUE = `highValue`;\nexport const SERVICE = `service`;\n\nexport const FABRICATION = `fabrication`;\nexport const WHOLESALE = `wholesale`;\nexport const RETAIL = `retail`;\n\n//Payment System Constants\nexport const PAYMENT_SUCCEEDED = `succeeded`;\n\n//Stripe\nexport const CUSTOMER = `customer`;\nexport const CUSTOMERADDRESS = `customerAddress`;\n\nexport const fakerJSON = {\n COMPONENT_RANGE: {\n min: 0.01,\n max: 20.0,\n dec: 2,\n symbol: \"$\",\n },\n COMPONENT_COUNT_RANGE: { min: 1, max: 10 },\n ISBN_LENGTH: { variant: 10 },\n};\n\nexport const COMPONENT_RANGE = \"COMPONENT_RANGE\";\nexport const COMPONENT_COUNT_RANGE = \"COMPONENT_COUNT_RANGE\";\nexport const ISBN_LENGTH = \"ISBN_LENGTH\";\n\n//end constants\n"],"names":[],"version":3,"file":"InventoryLogic.d27e84a7.js.map"}
@@ -1,217 +0,0 @@
1
- import {CARDS as $fefa9c41cb73ae0b$export$5f768699f44cc740, PAYMENT as $fefa9c41cb73ae0b$export$eaa266db8852871e, RECEIPTS as $fefa9c41cb73ae0b$export$cfa5730cd5118215} from "./InventoryLogic.d27e84a7.js";
2
- import {typedWrite as $55aHg$typedWrite, writeBack as $55aHg$writeBack, fetchRecord as $55aHg$fetchRecord, serverTimestampFieldValue as $55aHg$serverTimestampFieldValue, deleteRecord as $55aHg$deleteRecord, collectRecords as $55aHg$collectRecords, collectRecordsByFilter as $55aHg$collectRecordsByFilter, ownerByOwnerType as $55aHg$ownerByOwnerType, ownerByChild as $55aHg$ownerByChild} from "@leaddreamer/firebase-wrapper";
3
- import {Forms as $55aHg$Forms, cleanType as $55aHg$cleanType} from "@leaddreamer/staticforms";
4
-
5
- /**
6
- * "Payment Descriptor" handling operations. These descriptors represent paymentMethods, each tied
7
- * to an individual user. These do not *particularly* represent a paymentProvider - they are meant
8
- * as an abstraction above a specific payment processor.
9
- * @module Payment
10
- */
11
-
12
-
13
- const $f9cb07fd17b476cd$export$63d334e60537ba01 = {
14
- CARD_ERROR: `card_error`,
15
- VALIDATION_ERROR: `validation_error`
16
- };
17
- const $f9cb07fd17b476cd$export$25824cbb4751202b = {
18
- Id: null,
19
- payment_gateway: null,
20
- status: null
21
- };
22
- const $f9cb07fd17b476cd$export$1dc3fa0a524d39c3 = {
23
- Id: null,
24
- paymentMethod: null,
25
- fingerprint: null,
26
- label: null,
27
- nickname: null
28
- };
29
- const $f9cb07fd17b476cd$export$a5734ae35e42ad51 = {
30
- Id: null,
31
- amount: 0,
32
- payment: {
33
- link: null,
34
- paidQ: null
35
- },
36
- description: null
37
- };
38
- (0, $55aHg$Forms).Base[0, $fefa9c41cb73ae0b$export$eaa266db8852871e] = $f9cb07fd17b476cd$export$25824cbb4751202b;
39
- async function $f9cb07fd17b476cd$export$e7759a8c3eb8b251(account, batch = null) {
40
- return (0, $55aHg$typedWrite)((0, $55aHg$cleanType)(account, (0, $fefa9c41cb73ae0b$export$eaa266db8852871e)), account, (0, $fefa9c41cb73ae0b$export$eaa266db8852871e), batch);
41
- }
42
- async function $f9cb07fd17b476cd$export$f034950df5cadf57(paymentData) {
43
- //ALL OF fans, artists and venues save the payment data in the same collection
44
- // name under the parent, with the SAME Id as the parent
45
- return (0, $55aHg$writeBack)({
46
- ...paymentData
47
- });
48
- }
49
- async function $f9cb07fd17b476cd$export$81ed014c52470b45(account) {
50
- //payment data is saved under the same collection name for fans, artists
51
- //and venues, with the parent ID
52
- let payment_record = null;
53
- try {
54
- payment_record = await (0, $55aHg$fetchRecord)((0, $fefa9c41cb73ae0b$export$eaa266db8852871e), account.Id, account.refPath);
55
- } catch (err) {}
56
- return payment_record;
57
- }
58
- async function $f9cb07fd17b476cd$export$bf9a06d1f6c31bf4(accountId) {
59
- return $f9cb07fd17b476cd$export$81ed014c52470b45({
60
- Id: accountId,
61
- refPath: `${USER}/${accountId}`
62
- });
63
- }
64
- async function $f9cb07fd17b476cd$export$e5cc111dc11d988(account, descriptor, batch = null) {
65
- return (0, $55aHg$typedWrite)({
66
- ...descriptor,
67
- timestamp: (0, $55aHg$serverTimestampFieldValue)
68
- }, {
69
- //Payment documents BY DEFINITION have the same Id as the parent
70
- refPath: `${account.refPath}/${(0, $fefa9c41cb73ae0b$export$eaa266db8852871e)}/${account.Id}`
71
- }, (0, $fefa9c41cb73ae0b$export$5f768699f44cc740), batch);
72
- }
73
- async function $f9cb07fd17b476cd$export$218f64344bb0d5b1(descriptor) {
74
- //BOTH fans, artists and venues save the payment data in the same collection
75
- // name under the parent, with the SAME Id as the parent
76
- return (0, $55aHg$writeBack)({
77
- ...descriptor,
78
- timestamp: (0, $55aHg$serverTimestampFieldValue)
79
- });
80
- }
81
- async function $f9cb07fd17b476cd$export$2edf51a087d55c34(account, descriptor) {
82
- //MASSIVE CAVEAT
83
- //A paymentMethod *might* be removed with e same *fingerprint* as a current descriptor
84
- //but is still a different *paymentMethod*. PaymentDescriptors are unique on the fingerprint
85
- //Therefore, we need to *first* confirm that is is the same, so...
86
- //READ FIRST...
87
- const existingPD = await $f9cb07fd17b476cd$export$719d384deb9d4a1d(account, descriptor.fingerprint);
88
- //COMPARE PAYEMNTMETHOD, THEN DELETE IF NEEDED
89
- return existingPD.paymentMethod === descriptor.paymentMethod ? (0, $55aHg$deleteRecord)(descriptor, (0, $fefa9c41cb73ae0b$export$5f768699f44cc740), `/${account.refPath}/${(0, $fefa9c41cb73ae0b$export$eaa266db8852871e)}/${account.Id}`) : Promise.resolve(null); //don't delete if not identical
90
- }
91
- async function $f9cb07fd17b476cd$export$e67def8f84ea0ce8(account) {
92
- return (0, $55aHg$collectRecords)((0, $fefa9c41cb73ae0b$export$5f768699f44cc740), `${account.refPath}/${(0, $fefa9c41cb73ae0b$export$eaa266db8852871e)}/${account.Id}`);
93
- }
94
- async function $f9cb07fd17b476cd$export$afe4f672b985ac26(account) {
95
- const full = await $f9cb07fd17b476cd$export$e67def8f84ea0ce8(account);
96
- return full.map((pd)=>({
97
- Id: pd.Id,
98
- label: pd.label,
99
- nickname: pd.nickname
100
- }));
101
- }
102
- async function $f9cb07fd17b476cd$export$46296a85983d5325(account) {
103
- const sortArray = [
104
- {
105
- fieldRef: "timestamp",
106
- dirStr: "desc"
107
- }
108
- ];
109
- const shortlist = await (0, $55aHg$collectRecordsByFilter)((0, $fefa9c41cb73ae0b$export$5f768699f44cc740), `/${account.refPath}/${(0, $fefa9c41cb73ae0b$export$eaa266db8852871e)}/${account.Id}`, null, sortArray, 1);
110
- const latest = shortlist?.[0];
111
- return {
112
- Id: latest?.Id,
113
- label: latest?.label
114
- };
115
- }
116
- async function $f9cb07fd17b476cd$export$719d384deb9d4a1d(account, fingerprint) {
117
- return (0, $55aHg$fetchRecord)((0, $fefa9c41cb73ae0b$export$5f768699f44cc740), fingerprint, `/${account.refPath}/${(0, $fefa9c41cb73ae0b$export$eaa266db8852871e)}/${account.Id}`);
118
- }
119
- async function $f9cb07fd17b476cd$export$c10d531939e9952c(accountId, type, fingerprint) {
120
- return (0, $55aHg$fetchRecord)((0, $fefa9c41cb73ae0b$export$5f768699f44cc740), fingerprint, `/${type}/${accountId}/${(0, $fefa9c41cb73ae0b$export$eaa266db8852871e)}/${accountId}`);
121
- }
122
- async function $f9cb07fd17b476cd$export$6495802cd4961871(account, PDSummary = null) {
123
- //if not passed a PaymentDescriptorType, use the latest available
124
- const lastestPayment = await (PDSummary ? Promise.resolve(PDSummary) : $f9cb07fd17b476cd$export$46296a85983d5325(account));
125
- return (0, $55aHg$writeBack)({
126
- ...account,
127
- payment_method: lastestPayment
128
- });
129
- }
130
- async function $f9cb07fd17b476cd$export$4c730f12f97432c2(account, receipt, batch = null) {
131
- return (0, $55aHg$typedWrite)(receipt, account, (0, $fefa9c41cb73ae0b$export$cfa5730cd5118215), batch);
132
- }
133
- async function $f9cb07fd17b476cd$export$9d597d6207d02073(receipt) {
134
- return (0, $55aHg$writeBack)(receipt);
135
- }
136
- async function $f9cb07fd17b476cd$export$16e7bde1d3e4806e(ownerId, ownerType, receipt, batch = null) {
137
- return $f9cb07fd17b476cd$export$4c730f12f97432c2((0, $55aHg$ownerByOwnerType)(ownerId, ownerType), receipt, batch);
138
- }
139
- async function $f9cb07fd17b476cd$export$be8e05196fbdd05c(account, monthStamp) {
140
- const filterArray = [
141
- {
142
- fieldRef: "monthStamp",
143
- opStr: "==",
144
- value: monthStamp
145
- }
146
- ];
147
- try {
148
- const receipts = await $f9cb07fd17b476cd$export$4eb0e1031e4cb663(account, filterArray);
149
- return !!receipts.length; //true if more than zero
150
- } catch (err) {
151
- return false;
152
- }
153
- }
154
- async function $f9cb07fd17b476cd$export$9612333da9eb2b55(child, receipt, batch = null) {
155
- return $f9cb07fd17b476cd$export$4c730f12f97432c2((0, $55aHg$ownerByChild)(child), receipt, batch);
156
- }
157
- async function $f9cb07fd17b476cd$export$4eb0e1031e4cb663(account, filterArray = null, sortArray = null, limit = null) {
158
- return (0, $55aHg$collectRecordsByFilter)((0, $fefa9c41cb73ae0b$export$cfa5730cd5118215), account.refPath, filterArray, sortArray, limit);
159
- }
160
- /**
161
- * @param {AccountObject} account
162
- * @param {!string} account.refPath
163
- * @param {!string} receiptId
164
- * @return {Promise.ReceiptType}
165
- */ async function $f9cb07fd17b476cd$var$fetchReceipt(account, receiptId) {
166
- return (0, $55aHg$fetchRecord)((0, $fefa9c41cb73ae0b$export$cfa5730cd5118215), receiptId, account.refPath);
167
- }
168
- async function $f9cb07fd17b476cd$export$f9dd3c42a9fe0ec7(account) {
169
- //const in_status_array = [
170
- //`requires_payment_method`,
171
- //`requires_confirmation`,
172
- //`requires_action`,
173
- //`processing`,
174
- //`requires_capture`,
175
- //`canceled`,
176
- //`succeeded`,
177
- //`none`
178
- //];
179
- const not_in_status_array = [
180
- `succeeded`,
181
- `none`
182
- ];
183
- const filterArray = [
184
- {
185
- fieldRef: "payment.paidQ",
186
- opStr: "not-in",
187
- value: not_in_status_array
188
- }
189
- ];
190
- return $f9cb07fd17b476cd$export$4eb0e1031e4cb663(account, filterArray, null, null);
191
- }
192
- async function $f9cb07fd17b476cd$export$912a34b09f6646f6(pledgeTicket) {
193
- const account = {
194
- Id: pledgeTicket.fan.Id,
195
- refPath: `/${USER}/${pledgeTicket.fan.Id}`
196
- };
197
- const receiptId = pledgeTicket.Id;
198
- return $f9cb07fd17b476cd$var$fetchReceipt(account, receiptId);
199
- }
200
- async function $f9cb07fd17b476cd$export$cc5e46e81267707d(pledgeTicket, label) {
201
- const receipt = await $f9cb07fd17b476cd$export$912a34b09f6646f6(pledgeTicket);
202
- return $f9cb07fd17b476cd$export$b31aae8a995874b9(receipt, label);
203
- }
204
- async function $f9cb07fd17b476cd$export$b31aae8a995874b9(receipt, label) {
205
- return $f9cb07fd17b476cd$export$9d597d6207d02073({
206
- ...receipt,
207
- payment: {
208
- ...receipt.payment,
209
- paidQ: label
210
- }
211
- });
212
- } //////////////////////////////////////////////////////////////////////
213
- // utilities
214
-
215
-
216
- export {$f9cb07fd17b476cd$export$63d334e60537ba01 as ERROR_TYPES, $f9cb07fd17b476cd$export$25824cbb4751202b as PaymentDefault, $f9cb07fd17b476cd$export$1dc3fa0a524d39c3 as paymentDescriptor, $f9cb07fd17b476cd$export$a5734ae35e42ad51 as receiptDefault, $f9cb07fd17b476cd$export$e7759a8c3eb8b251 as createPaymentRecord, $f9cb07fd17b476cd$export$f034950df5cadf57 as savePaymentData, $f9cb07fd17b476cd$export$81ed014c52470b45 as fetchPayment, $f9cb07fd17b476cd$export$bf9a06d1f6c31bf4 as fetchPaymentByUser, $f9cb07fd17b476cd$export$e5cc111dc11d988 as addPaymentDescriptor, $f9cb07fd17b476cd$export$218f64344bb0d5b1 as savePaymentDescriptor, $f9cb07fd17b476cd$export$2edf51a087d55c34 as removePaymentDescriptor, $f9cb07fd17b476cd$export$719d384deb9d4a1d as fetchPDByFingerprint, $f9cb07fd17b476cd$export$e67def8f84ea0ce8 as fetchPaymentDescriptors, $f9cb07fd17b476cd$export$afe4f672b985ac26 as listPDSummaries, $f9cb07fd17b476cd$export$46296a85983d5325 as fetchLatestPDSummary, $f9cb07fd17b476cd$export$c10d531939e9952c as fetchPDByOwnerType, $f9cb07fd17b476cd$export$6495802cd4961871 as replaceDefaultPDSummary, $f9cb07fd17b476cd$export$4c730f12f97432c2 as saveReceiptRecord, $f9cb07fd17b476cd$export$9d597d6207d02073 as updateReceipt, $f9cb07fd17b476cd$export$16e7bde1d3e4806e as saveReceiptRecordByOwnerType, $f9cb07fd17b476cd$export$be8e05196fbdd05c as anyReceiptsByMonthStamp, $f9cb07fd17b476cd$export$4eb0e1031e4cb663 as fetchReceiptsFiltered, $f9cb07fd17b476cd$export$9612333da9eb2b55 as saveReceiptRecordByChild, $f9cb07fd17b476cd$export$f9dd3c42a9fe0ec7 as fetchProblemReceipts, $f9cb07fd17b476cd$export$912a34b09f6646f6 as fetchPledgeTicketReceipt, $f9cb07fd17b476cd$export$cc5e46e81267707d as markReceiptFromPledgeTicket, $f9cb07fd17b476cd$export$b31aae8a995874b9 as markReceipt};
217
- //# sourceMappingURL=InventoryLogic.d69ad127.js.map
@@ -1 +0,0 @@
1
- {"mappings":"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","sources":["business/Payment/index.js"],"sourcesContent":["/**\n * \"Payment Descriptor\" handling operations. These descriptors represent paymentMethods, each tied\n * to an individual user. These do not *particularly* represent a paymentProvider - they are meant\n * as an abstraction above a specific payment processor.\n * @module Payment\n */\nimport {\n typedWrite,\n writeBack,\n fetchRecord,\n collectRecords,\n collectRecordsByFilter,\n deleteRecord,\n ownerByChild,\n ownerByOwnerType,\n serverTimestampFieldValue,\n} from \"@leaddreamer/firebase-wrapper\";\n\nimport { Forms, cleanType } from \"@leaddreamer/staticforms\";\nimport { PAYMENT, RECEIPTS, CARDS } from \"../boilerplate/index.js\";\n\n//////////////////////////////////////////////////////////////////////\n// definitions\n/**\n * @constant\n * @type {{CARD_ERROR: string, VALIDATION_ERROR: string}}\n * @default\n */\nexport const ERROR_TYPES = {\n CARD_ERROR: `card_error`,\n VALIDATION_ERROR: `validation_error`,\n};\n\n/**\n * @typedef {object} PaymentData\n * @property {string} Id\n * @property {string} payment_gateway\n * @property {string} status\n */\n/**\n * @constant\n * @type {PaymentData}\n * @default\n */\nexport const PaymentDefault = {\n Id: null,\n payment_gateway: null,\n status: null,\n};\n\n/**\n * @typedef {object} PaymentDescriptorType\n * @property {!string} Id document Id of this Card Descriptor (same as fingerprint)\n * @property {!string} paymentMethod Id of payment system card item\n * @property {!string} fingerprint Unique hash of card info - for checking uniqueness\n * @property {!string} label Brand & last4, or other descriptive\n * @property {!string} expiry expiry date of payment method (if any)\n * @property {timestamp} timestamp last create or modify server time\n */\n/**\n * @typedef {object} PDSummary\n * @property {!string} Id document Id of this Card Descriptor\n * @property {!string} label Brand & last4, or other descriptive\n */\n/**\n * @constant\n * @type {PaymentDescriptorType}\n * @default\n */\nexport const paymentDescriptor = {\n Id: null,\n paymentMethod: null,\n fingerprint: null,\n label: null,\n nickname: null,\n};\n\n/**\n * @typedef {object} ReceiptType\n * @property {!string} Id same Id as the associated pledgeTicket\n * @property {!number} amount\n * @property {object} payment\n * @property {!string} link Id of associated payment_intent\n * @property {!string} paidQ string describing status\n * @property {?string} description supplemental information\n */\n/**\n * @constant\n * @type {ReceiptType}\n * @default\n */\nexport const receiptDefault = {\n Id: null, //pledgeTicketId for user receipts\n amount: 0,\n payment: {\n link: null, //paymentIntentId\n paidQ: null, //current status\n },\n description: null, //supplemental information\n};\n\nForms.Base[PAYMENT] = PaymentDefault;\n\n//////////////////////////////////////////////////////////////////////\n// Utilities\n\n/**\n * @typedef {UserObject} AccountObject\n */\n\n/**\n * Creates the Organization Payment information document\n * @async\n * @function\n * @param {AccountObject} account\n * @param {?WriteBatch|Transaction} batch batching object. Transaction will be added to the batch\n * @return {Promise<WriteBatch|Transaction|void>} WriteBatch, Transaction or Void\n */\nexport async function createPaymentRecord(account, batch = null) {\n return typedWrite(\n cleanType(account, PAYMENT), //sanitized data - unused fields added\n account, //parent\n PAYMENT, //type\n batch,\n );\n}\n\n/**\n * Saves a payment data record to a given account (user)\n * ALL OF fans, artists and venues save the payment data in the same collection\n * name under the parent, with the SAME Id as the parent\n * PaymentData *COMES FROM* payement processor, and should INCLUDE the record Id and\n * refPath\n * @param {PaymentDataRecord} paymentData\n */\nexport async function savePaymentData(paymentData) {\n //ALL OF fans, artists and venues save the payment data in the same collection\n // name under the parent, with the SAME Id as the parent\n return writeBack({\n ...paymentData,\n });\n}\n\n/**\n * fetches a paymentData record from the database for an account\n * ALL OF fans, artists and venues, etc save the payment data in the same collection\n * name under the parent, with the SAME Id as the parent\n * @param {AccountType} account\n * @param {Promise.PaymentData} paymentData\n */\nexport async function fetchPayment(account) {\n //payment data is saved under the same collection name for fans, artists\n //and venues, with the parent ID\n let payment_record = null;\n try {\n payment_record = await fetchRecord(PAYMENT, account.Id, account.refPath);\n } catch (err) { }\n return payment_record;\n}\n\n/**\n * fetches a paymentData record from the database for an account when only accountID and type are known\n * ALL OF fans, artists and venues save the payment data in the same collection\n * name under the parent, with the SAME Id as the parent\n * @param {!string} accountId\n * @param {!string} type\n * @param {Promise.PaymentData} paymentData\n */\nexport async function fetchPaymentByUser(accountId) {\n return fetchPayment({\n Id: accountId,\n refPath: `${USER}/${accountId}`,\n });\n}\n\n/**\n * Adds a specific paymentDescriptor to an account payment data\n * @param {AccountType} account\n * @param {!string} account.Id\n * @param {!string} account.refPath\n * @param {PaymentDescriptorType} descriptor\n * @param {!string} descriptor.paymentMethod\n * @param {!string} descriptor.fingerprint\n * @param {!string} descriptor.label\n * @param {?WriteBatch|Transaction} batch batching object. Transaction will be added to the batch\n * @return {Promise.PaymentDescriptorType}\n */\nexport async function addPaymentDescriptor(account, descriptor, batch = null) {\n return typedWrite(\n {\n ...descriptor,\n timestamp: serverTimestampFieldValue,\n },\n {\n //Payment documents BY DEFINITION have the same Id as the parent\n refPath: `${account.refPath}/${PAYMENT}/${account.Id}`,\n },\n CARDS,\n batch,\n );\n}\n\n/**\n * Saves a modified paymentDescriptor back to the database\n * @param {PaymentDescriptorType} descriptor\n * @param {!string} descriptor.Id\n * @param {!string} descriptor.refPath\n * @return {Promise.PaymentDescriptorType}\n */\nexport async function savePaymentDescriptor(descriptor) {\n //BOTH fans, artists and venues save the payment data in the same collection\n // name under the parent, with the SAME Id as the parent\n return writeBack({\n ...descriptor,\n timestamp: serverTimestampFieldValue,\n });\n}\n\n/**\n * Removes a paymentDescriptor from an account's paymentData\n * @param {AccountType} account\n * @param {PaymentDescriptorType} descriptor\n * @returns {Promise<void>}\n */\nexport async function removePaymentDescriptor(account, descriptor) {\n //MASSIVE CAVEAT\n //A paymentMethod *might* be removed with e same *fingerprint* as a current descriptor\n //but is still a different *paymentMethod*. PaymentDescriptors are unique on the fingerprint\n //Therefore, we need to *first* confirm that is is the same, so...\n //READ FIRST...\n const existingPD = await fetchPDByFingerprint(\n account,\n descriptor.fingerprint,\n );\n //COMPARE PAYEMNTMETHOD, THEN DELETE IF NEEDED\n return existingPD.paymentMethod === descriptor.paymentMethod\n ? deleteRecord(\n descriptor,\n CARDS,\n `/${account.refPath}/${PAYMENT}/${account.Id}`,\n )\n : Promise.resolve(null); //don't delete if not identical\n}\n\n/**\n * fetch all customer card records IN OUR DATABASE (not payment database)\n * @param {AccountType} account\n * @param {!string} account.refPath\n * @returns {Promise.Array.PaymentDescriptor}\n *\n */\nexport async function fetchPaymentDescriptors(account) {\n return collectRecords(CARDS, `${account.refPath}/${PAYMENT}/${account.Id}`);\n}\n\n/**\n * fetch the front-end list of paymentDescriptors\n * @param {AccountType} account\n * @param {!string} account.Id\n * @param {!string} account.refPath\n * @return {Promise.Array.PDSummary}\n */\nexport async function listPDSummaries(account) {\n const full = await fetchPaymentDescriptors(account);\n return full.map((pd) => ({\n Id: pd.Id,\n label: pd.label,\n nickname: pd.nickname,\n }));\n}\n\n/**\n * @param {AccountType} account\n * @param {!string} account.Id\n * @param {!string} account.refPath\n * @returns {Promise.PaymentDescriptorType}\n */\nexport async function fetchLatestPDSummary(account) {\n const sortArray = [\n {\n fieldRef: \"timestamp\",\n dirStr: \"desc\",\n },\n ];\n\n const shortlist = await collectRecordsByFilter(\n CARDS,\n `/${account.refPath}/${PAYMENT}/${account.Id}`,\n null, //filterArray\n sortArray,\n 1, //limit\n );\n const latest = shortlist?.[0];\n\n return { Id: latest?.Id, label: latest?.label };\n}\n\n/**\n * retreives a PD, given the account Id and Type\n * @param {AccountType} account\n * @param {!string} fingerprint\n * @returns {Promise<PDSummary>}\n */\nexport async function fetchPDByFingerprint(account, fingerprint) {\n return fetchRecord(\n CARDS, //tableName\n fingerprint, //Id/DocId\n `/${account.refPath}/${PAYMENT}/${account.Id}`, //refPath\n );\n}\n\n/**\n * retreives a PD, given the account Id and Type\n * @param {!string} accountId\n * @param {!string} type\n * @param {!string} fingerprint\n * @returns {Promise<PDSummary>}\n */\nexport async function fetchPDByOwnerType(accountId, type, fingerprint) {\n return fetchRecord(\n CARDS, //tableName\n fingerprint, //Id/DocId\n `/${type}/${accountId}/${PAYMENT}/${accountId}`, //refPath\n );\n}\n\n/**\n * Copies a PDSummary tobe the new default (convenience function)\n * @param {AccountType} account\n * @param {?PDSummary} PDSummary\n * @returns {Promise.AccountObject}\n */\nexport async function replaceDefaultPDSummary(account, PDSummary = null) {\n //if not passed a PaymentDescriptorType, use the latest available\n const lastestPayment = await (PDSummary\n ? Promise.resolve(PDSummary)\n : fetchLatestPDSummary(account));\n return writeBack({\n ...account,\n payment_method: lastestPayment,\n });\n}\n\n//////////////////////////////////////////////////////////////////////\n//Receipt support\n\n/**\n * Savess a Receipt to an account\n * @param {AccountType} account\n * @param {?ReceiptType} receipt\n * @param {?WriteBatch|Transaction} batch batching object. Transaction will be added to the batch\n * @returns {Promise.ReceiptType}\n */\nexport async function saveReceiptRecord(account, receipt, batch = null) {\n return typedWrite(receipt, account, RECEIPTS, batch);\n}\n\n/**\n * Updates a (changed?) Receipt record\n * @param {?ReceiptType} receipt\n * @returns {Promise.ReceiptType}\n */\nexport async function updateReceipt(receipt) {\n return writeBack(receipt);\n}\n\n/**\n * Saves a new receipt to an account referrred by ID and type\n * @param {!string} ownerId\n * @param {string} type either ORGANIZATIONS or USER\n * @param {ReceiptType} receipt\n * @param {?WriteBatch|Transaction} batch batching object. Transaction will be added to the batch\n * @returns {Promise.ReceiptType}\n */\nexport async function saveReceiptRecordByOwnerType(\n ownerId,\n ownerType,\n receipt,\n batch = null,\n) {\n return saveReceiptRecord(\n ownerByOwnerType(ownerId, ownerType),\n receipt,\n batch,\n );\n}\n\n/**\n * Fetches an array of receipts in any particular month by monthStampt\n * @param {AccountObject} account\n * @param {dateString} monthStamp\n * @returns {Promise.Array.ReceiptType}\n */\nexport async function anyReceiptsByMonthStamp(account, monthStamp) {\n const filterArray = [\n { fieldRef: \"monthStamp\", opStr: \"==\", value: monthStamp },\n ];\n try {\n const receipts = await fetchReceiptsFiltered(account, filterArray);\n return !!receipts.length; //true if more than zero\n } catch (err) {\n return false;\n }\n}\n\n/**\n * Saves a receipt by a child record reference\n * @param {RecordDocument} child\n * @param {ReceiptType} receipt\n * @param {?WriteBatch|Transaction} batch batching object. Transaction will be added to the batch\n * @returns {Promise.ReceiptType}\n */\nexport async function saveReceiptRecordByChild(child, receipt, batch = null) {\n return saveReceiptRecord(ownerByChild(child), receipt, batch);\n}\n\n/**\n * Fetches receipts based on a filter set\n * @param {AccountObject} account\n * @param {!string} account.refPath\n * @param {Array.filterObject} filterArray\n * @param {Array.sortObject} sortArray\n * @param {number} limit\n * @return {Promise.Array.ReceiptType}\n */\nexport async function fetchReceiptsFiltered(\n account,\n filterArray = null,\n sortArray = null,\n limit = null,\n) {\n return collectRecordsByFilter(\n RECEIPTS, //tablePath\n account.refPath, //refPath\n filterArray, //filter array\n sortArray, //sort Array\n limit, //limit\n );\n}\n\n/**\n * @param {AccountObject} account\n * @param {!string} account.refPath\n * @param {!string} receiptId\n * @return {Promise.ReceiptType}\n */\nasync function fetchReceipt(account, receiptId) {\n return fetchRecord(RECEIPTS, receiptId, account.refPath);\n}\n\n/**\n * @param {AccountObject} account\n * @param {!string} account.refPath\n * @return {Promise.Array.ReceiptType}\n */\nexport async function fetchProblemReceipts(account) {\n //const in_status_array = [\n //`requires_payment_method`,\n //`requires_confirmation`,\n //`requires_action`,\n //`processing`,\n //`requires_capture`,\n //`canceled`,\n //`succeeded`,\n //`none`\n //];\n const not_in_status_array = [`succeeded`, `none`];\n const filterArray = [\n { fieldRef: \"payment.paidQ\", opStr: \"not-in\", value: not_in_status_array },\n ];\n return fetchReceiptsFiltered(account, filterArray, null, null);\n}\n\n/**\n * Fetches the receipt for a pledgeTicket\n * @param {PledgeTicket} pledgeTicket\n * @returns {Promise.ReceiptType}\n */\nexport async function fetchPledgeTicketReceipt(pledgeTicket) {\n const account = {\n Id: pledgeTicket.fan.Id,\n refPath: `/${USER}/${pledgeTicket.fan.Id}`,\n };\n const receiptId = pledgeTicket.Id;\n return fetchReceipt(account, receiptId);\n}\n\n/**\n * Changes the paidQ label on a receipt associated with a pledgeTicket\n * @param {pledgeTicketType} pledgeTicket\n * @param {?string} label\n * @returns {Promise.ReceiptType}\n */\nexport async function markReceiptFromPledgeTicket(pledgeTicket, label) {\n const receipt = await fetchPledgeTicketReceipt(pledgeTicket);\n return markReceipt(receipt, label);\n}\n\n/**\n * Changes the paidQ label on a receipt associated with a pledgeTicket\n * @param {receiptType} receipt\n * @param {?string} label\n * @returns {Promise.ReceiptType}\n */\nexport async function markReceipt(receipt, label) {\n return updateReceipt({\n ...receipt,\n payment: {\n ...receipt.payment,\n paidQ: label,\n },\n });\n}\n\n//////////////////////////////////////////////////////////////////////\n// utilities\n"],"names":[],"version":3,"file":"InventoryLogic.d69ad127.js.map"}