From 1a9776cb8269bbf5b8a693546c83a5fd4459ddaa Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Sat, 31 Dec 2022 23:58:46 +0000 Subject: [PATCH] --- .vscode/launch.json | 2 +- server/biz/GlobalBizSettingsBiz.cs | 58 +++++++++++++++++++++++++++--- todo.txt | 2 +- 3 files changed, 55 insertions(+), 7 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index db4b77d..8d51672 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -35,7 +35,7 @@ "SOCKEYE_DB_CONNECTION": "Server=localhost;Username=postgres;Password=sockeye;Database=sockeye;CommandTimeout=300;", "SOCKEYE_DATA_PATH": "c:\\temp\\sockeye", "SOCKEYE_USE_URLS": "http://*:7676;", - //"SOCKEYE_PERMANENTLY_ERASE_DATABASE":"true", + "SOCKEYE_PERMANENTLY_ERASE_DATABASE":"true", //"SOCKEYE_REPORT_RENDERING_TIMEOUT":"1", "SOCKEYE_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_14\\bin" }, diff --git a/server/biz/GlobalBizSettingsBiz.cs b/server/biz/GlobalBizSettingsBiz.cs index 9fc64f1..10ecddf 100644 --- a/server/biz/GlobalBizSettingsBiz.cs +++ b/server/biz/GlobalBizSettingsBiz.cs @@ -168,7 +168,6 @@ namespace Sockeye.Biz client.DefaultRequestHeaders.Accept.Add(contentType); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authToken); - #region CUSTOMERS log.LogInformation("RFImport customers"); @@ -284,7 +283,7 @@ namespace Sockeye.Biz s.Quantity = jPurchase["quantity"].Value(); s.RenewNoticeSent = jPurchase["renewNoticeSent"].Value(); s.SalesOrderNumber = jPurchase["salesOrderNumber"].Value(); - s.VendorData = jPurchase["notes"].Value(); + s.Notes = jPurchase["notes"].Value(); PurchaseBiz biz = PurchaseBiz.GetBiz(ct); await biz.CreateAsync(s); } @@ -561,9 +560,6 @@ namespace Sockeye.Biz } #endregion licenses - - //============================================TRIAL REQUESTS START ========================================= - #region TRIAL LICENSE REQUESTS log.LogInformation("RFImport Raven trial requests"); { @@ -619,7 +615,59 @@ namespace Sockeye.Biz } #endregion trial requests + #region VENDOR NOTIFICATIONS + log.LogInformation("RFImport Vendor notifications"); + { + res = await client.GetAsync($"{URL_ROCKFISH}api/vendor-notifications/list"); + responseText = await res.Content.ReadAsStringAsync(); + var jaVendorNotificationList = JArray.Parse(responseText); + + foreach (JObject jVendorNotificationItem in jaVendorNotificationList) + { + /*[] + "{\n \"creation_date\": \"2022-12-28T20:20:24Z\",\n \ + "id\": 356247074,\n \ + "order_notification\": {\n \ + "purchase\": {\n \"customer_data\": {\n \"billing_contact\": {\n \"address\": {\n \"city\": \"Alpharetta\",\n \"country\": \"USA\",\n \"country_id\": \"US\",\n + \"postal_code\": \"30009\",\n \"state\": \"Georgia\",\n \"state_id\": \"GA\",\n \"street1\": \"11675 Rainwater Dr., Suite 350\"\n }, + \n …tart\": \"\",\n \"renewal_type\": \"auto\",\n \"retention_discount_count\": \"\",\n \"retention_discount_percent\": \"\",\n \ + "start_date\": \"2022-12-28T00:00:00\",\n \"status\": \"ToProcess\",\n \"status_id\": \"TOP\"\n },\n \ + "vat_pct\": 0.0,\n \"your_product_id\": \"perpetual\"\n }\n ],\n + \"purchase_origin\": \"online\",\n \"sequential_invoice_no\": \"e5-US-2022-00001637070\"\n }\n }\n}" + + { + "id": 25, + "dtCreated": 1670375661, + "vendor": "shareit", + "data": "{\n \"creation_date\": \"2022-12-07T01:14:19Z\",\n \"id\": 354935062,\n \"order_notification\": {\n \"purchase\": {\n \"customer_data\": {\n \"billing_contact\": {\n \"address\": {\n \"city\": \"Abbotsford\",\n \"country\": \"Canada\",\n \"country_id\": \"CA\",\n \"postal_code\": \"V2S 8M1\",\n \"state\": \"British Columbia\",\n \"state_id\": \"BC\",\n \"street1\": \"35355 McKee Rd\"\n },\n \"company\": \"Adtech Systems Inc.\",\n \"email\": \"erling@myadtech.com\",\n \"first_name\": \"Erling\",\n \"last_name\": \"Lassesen\"\n },\n \"customer_payment_data\": {\n \"currency\": \"USD\",\n \"payment_method\": \"PayPal\"\n },\n \"delivery_contact\": {\n \"address\": {\n \"city\": \"Abbotsford\",\n \"country\": \"Canada\",\n \"country_id\": \"CA\",\n \"postal_code\": \"V2S 8M1\",\n \"state\": \"British Columbia\",\n \"state_id\": \"BC\",\n \"street1\": \"35355 McKee Rd\"\n },\n \"company\": \"Adtech Systems Inc.\",\n \"email\": \"erling@myadtech.com\",\n \"first_name\": \"Erling\",\n \"last_name\": \"Lassesen\"\n },\n \"language\": \"English\",\n \"language_iso\": \"en\",\n \"reg_name\": \"Adtech Systems Inc.\",\n \"shopper_id\": \"50862261\",\n \"subscribe_newsletter\": true,\n \"user_id\": \"erling@adtech-systems.com-4\"\n },\n \"is_test\": false,\n \"payment_complete_date\": \"2022-12-07T01:14:19Z\",\n \"payment_status\": \"complete\",\n \"payment_status_id\": \"PCA\",\n \"purchase_date\": \"2022-12-07T01:14:16Z\",\n \"purchase_id\": 833707313,\n \"purchase_item\": [\n {\n \"accounting\": {\n \"currency\": \"USD\",\n \"product_net\": 55.65,\n \"discount\": 0.0,\n \"product_vat\": 6.68,\n \"shipping\": 0.0,\n \"shipping_vat\": 0.0,\n \"eu_vat\": -6.68,\n \"margin_net\": -5.44,\n \"your_revenue\": 50.21\n },\n \"additional_information\": [\n {\n \"additional_id\": \"ADDITIONAL1\",\n \"additional_value\": \"YES\"\n },\n {\n \"additional_id\": \"ADDITIONAL2\",\n \"additional_value\": \"YES\"\n },\n {\n \"additional_id\": \"ADDITIONAL3\",\n \"additional_value\": \"YES\"\n }\n ],\n \"currency\": \"USD\",\n \"delivery_type\": \"Electronically\",\n \"discount\": 0.0,\n \"extended_download_price\": 0.0,\n \"manual_order_price\": 0.0,\n \"notification_no\": 7926,\n \"product_id\": 300740315,\n \"product_name\": \"Single AyaNova schedulable resource 1 year subscription license\",\n \"product_single_price\": 55.65,\n \"purchase_item_key\": [],\n \"quantity\": 1,\n \"running_no\": 1,\n \"shipping_price\": 0.0,\n \"shipping_vat_pct\": 0.0,\n \"subscription\": {\n \"expiration_date\": \"2023-12-07T17:28:16Z\",\n \"id\": \"550286373-1\",\n \"interval\": \"Yearly without end\",\n \"original_notification_no\": \"6872\",\n \"original_purchase_id\": \"550286373\",\n \"original_running_no\": \"1\",\n \"renewal_discount_count\": \"\",\n \"renewal_discount_start\": \"\",\n \"renewal_type\": \"auto\",\n \"retention_discount_count\": \"\",\n \"retention_discount_percent\": \"\",\n \"start_date\": \"2017-12-07T00:00:00\",\n \"status\": \"ToProcess\",\n \"status_id\": \"TOP\"\n },\n \"vat_pct\": 12.0\n }\n ],\n \"purchase_origin\": \"Subscription\",\n \"sequential_invoice_no\": \"e5-DE-2022-00002647549\"\n }\n }\n}", + "dtProcessed": null, + "processed": false + }, + */ + + var jData = JObject.Parse(jVendorNotificationItem["data"].Value()); + var salesOrderNumber = jData["order_notification"]["purchase"]["purchase_id"].Value(); + var p = await ct.Purchase.FirstOrDefaultAsync(z => z.SalesOrderNumber == salesOrderNumber); + if (p == null) + { + log.LogError($"RFImport Vendor notifications can't match sales order number {salesOrderNumber}"); + } + else + { + if (!string.IsNullOrWhiteSpace(p.VendorData)) + p.VendorData += ",\n"; + p.VendorData += jVendorNotificationItem["data"].Value(); + + var biz = PurchaseBiz.GetBiz(ct); + await biz.PutAsync(p); + } + + }// all vendor notifications loop + + + } + #endregion vendor notifications } diff --git a/todo.txt b/todo.txt index 9d8bc94..5b5cac2 100644 --- a/todo.txt +++ b/todo.txt @@ -1,6 +1,6 @@ client - open / edit all the things -import trial requests + import all vendor data packets from shareit into purchases - direct open a case by case number like workorder