@esolve/ng-esolve-connect 0.24.2 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/lib/account/esolve-account.service.mjs +35 -2
- package/esm2020/lib/account/user-account/esolve-user-account-record.interface.mjs +1 -1
- package/esm2020/lib/account/user-account/esolve-user-account.model.mjs +1 -1
- package/esm2020/lib/account/user-account/esolve-user-client-account-balances-record.interface.mjs +2 -0
- package/esm2020/lib/account/user-account/esolve-user-client-account-balances.model.mjs +13 -0
- package/esm2020/lib/account/user-account/esolve-user-client-account-record.interface.mjs +2 -0
- package/esm2020/lib/account/user-account/esolve-user-client-account.model.mjs +42 -0
- package/esm2020/lib/account/user-account/index.mjs +5 -1
- package/fesm2015/esolve-ng-esolve-connect.mjs +465 -378
- package/fesm2015/esolve-ng-esolve-connect.mjs.map +1 -1
- package/fesm2020/esolve-ng-esolve-connect.mjs +462 -376
- package/fesm2020/esolve-ng-esolve-connect.mjs.map +1 -1
- package/lib/account/esolve-account.service.d.ts +3 -0
- package/lib/account/user-account/esolve-user-account-record.interface.d.ts +2 -0
- package/lib/account/user-account/esolve-user-account.model.d.ts +2 -0
- package/lib/account/user-account/esolve-user-client-account-balances-record.interface.d.ts +11 -0
- package/lib/account/user-account/esolve-user-client-account-balances.model.d.ts +12 -0
- package/lib/account/user-account/esolve-user-client-account-record.interface.d.ts +39 -0
- package/lib/account/user-account/esolve-user-client-account.model.d.ts +40 -0
- package/lib/account/user-account/index.d.ts +4 -0
- package/package.json +1 -1
|
@@ -1905,6 +1905,61 @@ class EsolveUserAccountContact {
|
|
|
1905
1905
|
}
|
|
1906
1906
|
}
|
|
1907
1907
|
|
|
1908
|
+
class EsolveUserClientAccount {
|
|
1909
|
+
constructor(account, branch_code, account_group, pricing_group, price_list, loyalty_classification_id, company_name, client_contact_person, client_firstname, client_surname, client_email, client_contact_number, client_fax_number, client_cellphone_number, client_id_number, address_description, street, suburb, city, province, country, postal_code, postal_address, delivery_address, latitude, longitude, vat_number, credit_limit, pending_invoice_balance, external_account_balance, ageing, balance_last_updated, default_sellprice, client_classification, override_stock_listing_identifiers, requires_transaction_approval, is_active) {
|
|
1910
|
+
this.account = account;
|
|
1911
|
+
this.branch_code = branch_code;
|
|
1912
|
+
this.account_group = account_group;
|
|
1913
|
+
this.pricing_group = pricing_group;
|
|
1914
|
+
this.price_list = price_list;
|
|
1915
|
+
this.loyalty_classification_id = loyalty_classification_id;
|
|
1916
|
+
this.company_name = company_name;
|
|
1917
|
+
this.client_contact_person = client_contact_person;
|
|
1918
|
+
this.client_firstname = client_firstname;
|
|
1919
|
+
this.client_surname = client_surname;
|
|
1920
|
+
this.client_email = client_email;
|
|
1921
|
+
this.client_contact_number = client_contact_number;
|
|
1922
|
+
this.client_fax_number = client_fax_number;
|
|
1923
|
+
this.client_cellphone_number = client_cellphone_number;
|
|
1924
|
+
this.client_id_number = client_id_number;
|
|
1925
|
+
this.address_description = address_description;
|
|
1926
|
+
this.street = street;
|
|
1927
|
+
this.suburb = suburb;
|
|
1928
|
+
this.city = city;
|
|
1929
|
+
this.province = province;
|
|
1930
|
+
this.country = country;
|
|
1931
|
+
this.postal_code = postal_code;
|
|
1932
|
+
this.postal_address = postal_address;
|
|
1933
|
+
this.delivery_address = delivery_address;
|
|
1934
|
+
this.latitude = latitude;
|
|
1935
|
+
this.longitude = longitude;
|
|
1936
|
+
this.vat_number = vat_number;
|
|
1937
|
+
this.credit_limit = credit_limit;
|
|
1938
|
+
this.pending_invoice_balance = pending_invoice_balance;
|
|
1939
|
+
this.external_account_balance = external_account_balance;
|
|
1940
|
+
this.ageing = ageing;
|
|
1941
|
+
this.balance_last_updated = balance_last_updated;
|
|
1942
|
+
this.default_sellprice = default_sellprice;
|
|
1943
|
+
this.client_classification = client_classification;
|
|
1944
|
+
this.override_stock_listing_identifiers = override_stock_listing_identifiers;
|
|
1945
|
+
this.requires_transaction_approval = requires_transaction_approval;
|
|
1946
|
+
this.is_active = is_active;
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
class EsolveUserClientAccountBalances {
|
|
1951
|
+
constructor(clients_id, account, cart_totals, credit_limit, external_account_balance, external_available_balance, new_external_available_balance, credit_limit_okay) {
|
|
1952
|
+
this.clients_id = clients_id;
|
|
1953
|
+
this.account = account;
|
|
1954
|
+
this.cart_totals = cart_totals;
|
|
1955
|
+
this.credit_limit = credit_limit;
|
|
1956
|
+
this.external_account_balance = external_account_balance;
|
|
1957
|
+
this.external_available_balance = external_available_balance;
|
|
1958
|
+
this.new_external_available_balance = new_external_available_balance;
|
|
1959
|
+
this.credit_limit_okay = credit_limit_okay;
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
|
|
1908
1963
|
class EsolveTransactionAddress {
|
|
1909
1964
|
constructor(recipient, address_type, address_description, street_number, street, suburb, city, province, country, postal_code, pobox) {
|
|
1910
1965
|
this.recipient = recipient;
|
|
@@ -2286,99 +2341,416 @@ class EsolveLocationUpdateResult extends EsolveResponseResult {
|
|
|
2286
2341
|
}
|
|
2287
2342
|
}
|
|
2288
2343
|
|
|
2289
|
-
class
|
|
2290
|
-
constructor(
|
|
2344
|
+
class EsolveCheckoutResult extends EsolveResponseResult {
|
|
2345
|
+
constructor(response) {
|
|
2346
|
+
var _a;
|
|
2347
|
+
super(response);
|
|
2348
|
+
this.id = 0;
|
|
2349
|
+
this.id = +response.esolve_id;
|
|
2350
|
+
this.process_payment = (_a = response.process_payment) !== null && _a !== void 0 ? _a : false;
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
|
|
2354
|
+
class EsolveCartItem {
|
|
2355
|
+
constructor(id, stock_item, qty, delivery_category, type, price, discount, discount_interval, vat_rate, allow_quotes, allow_orders, must_collect, requested_assembly, price_incl, discount_price, discount_price_incl, discount_total, vat_total, total, total_incl) {
|
|
2356
|
+
this.id = id;
|
|
2357
|
+
this.stock_item = stock_item;
|
|
2358
|
+
this.qty = qty;
|
|
2359
|
+
this.delivery_category = delivery_category;
|
|
2360
|
+
this.type = type;
|
|
2361
|
+
this.price = price;
|
|
2362
|
+
this.discount = discount;
|
|
2363
|
+
this.discount_interval = discount_interval;
|
|
2364
|
+
this.vat_rate = vat_rate;
|
|
2365
|
+
this.allow_quotes = allow_quotes;
|
|
2366
|
+
this.allow_orders = allow_orders;
|
|
2367
|
+
this.must_collect = must_collect;
|
|
2368
|
+
this.requested_assembly = requested_assembly;
|
|
2369
|
+
this.price_incl = price_incl;
|
|
2370
|
+
this.discount_price = discount_price;
|
|
2371
|
+
this.discount_price_incl = discount_price_incl;
|
|
2372
|
+
this.discount_total = discount_total;
|
|
2373
|
+
this.vat_total = vat_total;
|
|
2374
|
+
this.total = total;
|
|
2375
|
+
this.total_incl = total_incl;
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2379
|
+
class EsolveCartStockItem {
|
|
2380
|
+
constructor(code, name, sef_name, description, active, items_in_pack, delivery_category, onhand, image_name) {
|
|
2381
|
+
this.code = code;
|
|
2382
|
+
this.name = name;
|
|
2383
|
+
this.sef_name = sef_name;
|
|
2384
|
+
this.description = description;
|
|
2385
|
+
this.active = active;
|
|
2386
|
+
this.items_in_pack = items_in_pack;
|
|
2387
|
+
this.delivery_category = delivery_category;
|
|
2388
|
+
this.onhand = onhand;
|
|
2389
|
+
this.image_name = image_name;
|
|
2390
|
+
}
|
|
2391
|
+
/**
|
|
2392
|
+
* Path to tiny stock image
|
|
2393
|
+
*/
|
|
2394
|
+
get tiny_image_src() {
|
|
2395
|
+
return this.getImagePath('tiny');
|
|
2396
|
+
}
|
|
2397
|
+
/**
|
|
2398
|
+
* Path to thumbnail stock image
|
|
2399
|
+
*/
|
|
2400
|
+
get thumbnail_image_src() {
|
|
2401
|
+
return this.getImagePath('thumb');
|
|
2402
|
+
}
|
|
2403
|
+
/**
|
|
2404
|
+
* Path to small stock image
|
|
2405
|
+
*/
|
|
2406
|
+
get small_image_src() {
|
|
2407
|
+
return this.getImagePath('small');
|
|
2408
|
+
}
|
|
2409
|
+
/**
|
|
2410
|
+
* Path to big stock image
|
|
2411
|
+
*/
|
|
2412
|
+
get big_image_src() {
|
|
2413
|
+
return this.getImagePath('big');
|
|
2414
|
+
}
|
|
2415
|
+
/**
|
|
2416
|
+
* Path to original stock image
|
|
2417
|
+
*/
|
|
2418
|
+
get original_image_src() {
|
|
2419
|
+
return this.getImagePath('original');
|
|
2420
|
+
}
|
|
2421
|
+
getImagePath(image_size) {
|
|
2422
|
+
if (this.image_name !== '') {
|
|
2423
|
+
return `/images/stock/${image_size}/${this.image_name}`;
|
|
2424
|
+
}
|
|
2425
|
+
return '';
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
|
|
2429
|
+
/**
|
|
2430
|
+
* Totals in cart
|
|
2431
|
+
*/
|
|
2432
|
+
class EsolveCartTotals {
|
|
2433
|
+
constructor(
|
|
2434
|
+
/**
|
|
2435
|
+
* Number of unique records in cart
|
|
2436
|
+
*/
|
|
2437
|
+
records = 0,
|
|
2438
|
+
/**
|
|
2439
|
+
* Total quantity of all items in a cart
|
|
2440
|
+
*/
|
|
2441
|
+
items = 0,
|
|
2442
|
+
/**
|
|
2443
|
+
* Total in cart before discount and VAT is added
|
|
2444
|
+
*/
|
|
2445
|
+
sub_total = 0,
|
|
2446
|
+
/**
|
|
2447
|
+
* Total VAT of all the items in the cart
|
|
2448
|
+
*/
|
|
2449
|
+
vat_total = 0,
|
|
2450
|
+
/**
|
|
2451
|
+
* Total discount of all the item in the cart
|
|
2452
|
+
*/
|
|
2453
|
+
discount_total = 0) {
|
|
2454
|
+
this.records = records;
|
|
2455
|
+
this.items = items;
|
|
2456
|
+
this.sub_total = sub_total;
|
|
2457
|
+
this.vat_total = vat_total;
|
|
2458
|
+
this.discount_total = discount_total;
|
|
2459
|
+
}
|
|
2460
|
+
/**
|
|
2461
|
+
* Grand total of cart which includes discount and VAT (NOTE: shipping and insurance is not included)
|
|
2462
|
+
*/
|
|
2463
|
+
get total() {
|
|
2464
|
+
return this.sub_total + this.vat_total - this.discount_total;
|
|
2465
|
+
}
|
|
2466
|
+
}
|
|
2467
|
+
|
|
2468
|
+
class EsolveEmptyCartResult extends EsolveResponseResult {
|
|
2469
|
+
}
|
|
2470
|
+
|
|
2471
|
+
class EsolveCartService {
|
|
2472
|
+
constructor(config, http, errorHandler, responseHandler) {
|
|
2291
2473
|
this.config = config;
|
|
2292
2474
|
this.http = http;
|
|
2293
|
-
this.sessionService = sessionService;
|
|
2294
2475
|
this.errorHandler = errorHandler;
|
|
2295
2476
|
this.responseHandler = responseHandler;
|
|
2296
|
-
this.
|
|
2297
|
-
this.sessionService.session.subscribe((session) => {
|
|
2298
|
-
if (session.key !== '') {
|
|
2299
|
-
this.user_id = session.id;
|
|
2300
|
-
}
|
|
2301
|
-
});
|
|
2302
|
-
}
|
|
2303
|
-
get user_id() {
|
|
2304
|
-
return this._user_id;
|
|
2477
|
+
this._cached_tracking = 0;
|
|
2305
2478
|
}
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2479
|
+
/**
|
|
2480
|
+
* Retrieves the current cart
|
|
2481
|
+
*
|
|
2482
|
+
* @returns An `Observable` with an array of cart items
|
|
2483
|
+
*/
|
|
2484
|
+
getCart() {
|
|
2485
|
+
return this.http
|
|
2486
|
+
.get(`${this.config.api_url}/get-cart.php`)
|
|
2487
|
+
.pipe(map((response) => {
|
|
2488
|
+
if (response.records === undefined) {
|
|
2489
|
+
throw response;
|
|
2490
|
+
}
|
|
2491
|
+
return this.processCart(response.records);
|
|
2492
|
+
}));
|
|
2311
2493
|
}
|
|
2312
|
-
|
|
2494
|
+
/**
|
|
2495
|
+
* Updates the cart by preforming various actions, such as adding, editing or removing items from the cart.
|
|
2496
|
+
*
|
|
2497
|
+
* @param items An array of options to update the cart
|
|
2498
|
+
* @param action The default action to preform
|
|
2499
|
+
* @returns An `Observable` with an array of responses that gives feedback on the requested changes
|
|
2500
|
+
*/
|
|
2501
|
+
setCart(items, action = 'add') {
|
|
2313
2502
|
const body = {
|
|
2314
|
-
|
|
2503
|
+
items,
|
|
2504
|
+
action,
|
|
2315
2505
|
};
|
|
2316
2506
|
return this.http
|
|
2317
|
-
.post(`${this.config.api_url}/set-
|
|
2507
|
+
.post(`${this.config.api_url}/set-cart-item.php`, body, {
|
|
2318
2508
|
headers: {
|
|
2319
2509
|
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
|
|
2320
2510
|
},
|
|
2321
2511
|
responseType: 'json',
|
|
2322
2512
|
observe: 'body',
|
|
2323
2513
|
})
|
|
2324
|
-
.pipe(map((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => new EsolveUserAccountResult(response))), catchError((errorRes) => {
|
|
2325
|
-
return this.errorHandler.handleHttpPostError('set-user-account', errorRes);
|
|
2326
|
-
}));
|
|
2327
|
-
}
|
|
2328
|
-
getUserAccount() {
|
|
2329
|
-
return this.http
|
|
2330
|
-
.get(`${this.config.api_url}/get-account.php`)
|
|
2331
2514
|
.pipe(map((response) => {
|
|
2332
|
-
if (
|
|
2333
|
-
(response.records.length === 0)) {
|
|
2515
|
+
if (response.responses === undefined) {
|
|
2334
2516
|
throw response;
|
|
2335
2517
|
}
|
|
2336
|
-
|
|
2337
|
-
return this.processUserAccount(record);
|
|
2518
|
+
return response.responses;
|
|
2338
2519
|
}));
|
|
2339
2520
|
}
|
|
2340
|
-
|
|
2521
|
+
setCartEmpty(type, additional_where) {
|
|
2341
2522
|
const body = {
|
|
2342
|
-
|
|
2523
|
+
type,
|
|
2524
|
+
additional_where,
|
|
2343
2525
|
};
|
|
2344
2526
|
return this.http
|
|
2345
|
-
.post(`${this.config.api_url}/set-
|
|
2527
|
+
.post(`${this.config.api_url}/set-cart-empty.php`, body, {
|
|
2346
2528
|
headers: {
|
|
2347
2529
|
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
|
|
2348
2530
|
},
|
|
2349
2531
|
responseType: 'json',
|
|
2350
2532
|
observe: 'body',
|
|
2351
2533
|
})
|
|
2352
|
-
.pipe(map((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) =>
|
|
2353
|
-
|
|
2534
|
+
.pipe(map((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => {
|
|
2535
|
+
this._cached_tracking = 0;
|
|
2536
|
+
return new EsolveEmptyCartResult(response);
|
|
2537
|
+
})), catchError((errorRes) => {
|
|
2538
|
+
return this.errorHandler.handleHttpPostError('set-cart-empty', errorRes);
|
|
2354
2539
|
}));
|
|
2355
2540
|
}
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
})
|
|
2363
|
-
.pipe(map((response) => {
|
|
2364
|
-
if (response.records === undefined) {
|
|
2365
|
-
throw response;
|
|
2366
|
-
}
|
|
2367
|
-
return this.processUserAddress(response.records);
|
|
2368
|
-
}));
|
|
2369
|
-
}
|
|
2370
|
-
catch (error) {
|
|
2371
|
-
return throwError(() => error);
|
|
2372
|
-
}
|
|
2373
|
-
}
|
|
2374
|
-
deleteAddress(id) {
|
|
2541
|
+
/**
|
|
2542
|
+
* Retrieves the totals of the cart with all the totals calculated
|
|
2543
|
+
*
|
|
2544
|
+
* @returns An `Observable` with an object containing cart totals
|
|
2545
|
+
*/
|
|
2546
|
+
getTotals(type) {
|
|
2375
2547
|
return this.http
|
|
2376
|
-
.
|
|
2377
|
-
params: {
|
|
2378
|
-
|
|
2379
|
-
|
|
2548
|
+
.get(`${this.config.api_url}/get-cart-totals.php`, {
|
|
2549
|
+
params: {
|
|
2550
|
+
type: type !== null && type !== void 0 ? type : '',
|
|
2551
|
+
},
|
|
2380
2552
|
})
|
|
2381
|
-
.pipe(map((
|
|
2553
|
+
.pipe(map((response) => {
|
|
2554
|
+
if (response.records === undefined) {
|
|
2555
|
+
throw response;
|
|
2556
|
+
}
|
|
2557
|
+
return this.processCartTotals(response.records);
|
|
2558
|
+
}));
|
|
2559
|
+
}
|
|
2560
|
+
/**
|
|
2561
|
+
* Retrieves a tracking code for the cart
|
|
2562
|
+
*
|
|
2563
|
+
* @returns An `Observable` with the cart tracking code
|
|
2564
|
+
*/
|
|
2565
|
+
getTrackingCode() {
|
|
2566
|
+
return iif(() => this._cached_tracking > 0, of(this._cached_tracking), this.http
|
|
2567
|
+
.get(`${this.config.api_url}/get-checkout-tracking.php`)
|
|
2568
|
+
.pipe(map((response) => {
|
|
2569
|
+
if (response.records === undefined) {
|
|
2570
|
+
throw response;
|
|
2571
|
+
}
|
|
2572
|
+
this._cached_tracking = response.records.tracking;
|
|
2573
|
+
return response.records.tracking;
|
|
2574
|
+
})));
|
|
2575
|
+
}
|
|
2576
|
+
/**
|
|
2577
|
+
* Initiates checkout of the cart items
|
|
2578
|
+
*
|
|
2579
|
+
* @param type The cart type that needs to be checked out
|
|
2580
|
+
* @param addresses_id The ID of the delivery address
|
|
2581
|
+
* @param shipping_id The ID of the shipping method
|
|
2582
|
+
* @param payment_method_id The ID of the selected payment method
|
|
2583
|
+
* @param location_id The ID of the selected branch from with shipping needs to be calculated
|
|
2584
|
+
* @param comments Additional comments on the cart
|
|
2585
|
+
* @returns An `Observable` with the transaction ID
|
|
2586
|
+
*/
|
|
2587
|
+
checkout(type, addresses_id, shipping_id, payment_method_id = 0, location_id = 0, comments = '') {
|
|
2588
|
+
const body = {
|
|
2589
|
+
type,
|
|
2590
|
+
addresses_id,
|
|
2591
|
+
shipping_id,
|
|
2592
|
+
payment_method_id,
|
|
2593
|
+
location_id,
|
|
2594
|
+
comments,
|
|
2595
|
+
tracking: 0,
|
|
2596
|
+
};
|
|
2597
|
+
return this.getTrackingCode().pipe(switchMap((tracking) => {
|
|
2598
|
+
if (tracking <= 0) {
|
|
2599
|
+
throw tracking;
|
|
2600
|
+
}
|
|
2601
|
+
body.tracking = tracking;
|
|
2602
|
+
return this.http
|
|
2603
|
+
.post(`${this.config.api_url}/set-checkout.php`, body, {
|
|
2604
|
+
headers: {
|
|
2605
|
+
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
|
|
2606
|
+
},
|
|
2607
|
+
responseType: 'json',
|
|
2608
|
+
observe: 'body',
|
|
2609
|
+
})
|
|
2610
|
+
.pipe(map((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => {
|
|
2611
|
+
this._cached_tracking = 0;
|
|
2612
|
+
return new EsolveCheckoutResult(response);
|
|
2613
|
+
})), catchError((errorRes) => {
|
|
2614
|
+
return this.errorHandler.handleHttpPostError('set-checkout', errorRes);
|
|
2615
|
+
}));
|
|
2616
|
+
}));
|
|
2617
|
+
}
|
|
2618
|
+
/**
|
|
2619
|
+
* Processes the eSolve tree records
|
|
2620
|
+
*
|
|
2621
|
+
* @param cart_item_records Records to process
|
|
2622
|
+
* @returns An array of processed cart items
|
|
2623
|
+
*/
|
|
2624
|
+
processCart(cart_item_records) {
|
|
2625
|
+
const cart_items = [];
|
|
2626
|
+
if (cart_item_records) {
|
|
2627
|
+
for (const cart_item_record of cart_item_records) {
|
|
2628
|
+
const cart_stock_item = new EsolveCartStockItem(cart_item_record.code, cart_item_record.name, cart_item_record.sef_name, cart_item_record.description, cart_item_record.is_active, +cart_item_record.items_in_pack, cart_item_record.delivery_category, +cart_item_record.onhand, cart_item_record.image_name);
|
|
2629
|
+
cart_items.push(new EsolveCartItem(+cart_item_record.id, cart_stock_item, +cart_item_record.qty, cart_item_record.delivery_category, cart_item_record.type, +cart_item_record.price, +cart_item_record.discount, +cart_item_record.discount_interval, cart_item_record.vat_rate, cart_item_record.allow_quotes, cart_item_record.allow_orders, cart_item_record.must_collect, cart_item_record.requested_assembly, +cart_item_record.price_incl, +cart_item_record.discount_price, +cart_item_record.discount_price_incl, +cart_item_record.discount_total, +cart_item_record.vat_total, +cart_item_record.line_total, +cart_item_record.line_total_incl));
|
|
2630
|
+
}
|
|
2631
|
+
}
|
|
2632
|
+
return cart_items;
|
|
2633
|
+
}
|
|
2634
|
+
/**
|
|
2635
|
+
* Processes the eSolve cart totals
|
|
2636
|
+
*
|
|
2637
|
+
* @param record Data to process
|
|
2638
|
+
* @returns Processed cart totals
|
|
2639
|
+
*/
|
|
2640
|
+
processCartTotals(record) {
|
|
2641
|
+
const cart_totals = new EsolveCartTotals(+record.records, +record.items, +record.total, +record.vat, +record.discount);
|
|
2642
|
+
return cart_totals;
|
|
2643
|
+
}
|
|
2644
|
+
}
|
|
2645
|
+
EsolveCartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: EsolveCartService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }, { token: EsolveErrorHandlerService }, { token: EsolveResponseHandlerService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2646
|
+
EsolveCartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: EsolveCartService, providedIn: 'root' });
|
|
2647
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: EsolveCartService, decorators: [{
|
|
2648
|
+
type: Injectable,
|
|
2649
|
+
args: [{
|
|
2650
|
+
providedIn: 'root',
|
|
2651
|
+
}]
|
|
2652
|
+
}], ctorParameters: function () {
|
|
2653
|
+
return [{ type: undefined, decorators: [{
|
|
2654
|
+
type: Inject,
|
|
2655
|
+
args: [ESOLVE_CONNECT_CONFIG]
|
|
2656
|
+
}] }, { type: i1$2.HttpClient }, { type: EsolveErrorHandlerService }, { type: EsolveResponseHandlerService }];
|
|
2657
|
+
} });
|
|
2658
|
+
|
|
2659
|
+
// TODO: Spilt folder to file types
|
|
2660
|
+
|
|
2661
|
+
class EsolveAccountService {
|
|
2662
|
+
constructor(config, http, sessionService, errorHandler, responseHandler) {
|
|
2663
|
+
this.config = config;
|
|
2664
|
+
this.http = http;
|
|
2665
|
+
this.sessionService = sessionService;
|
|
2666
|
+
this.errorHandler = errorHandler;
|
|
2667
|
+
this.responseHandler = responseHandler;
|
|
2668
|
+
this._user_id = 0;
|
|
2669
|
+
this.sessionService.session.subscribe((session) => {
|
|
2670
|
+
if (session.key !== '') {
|
|
2671
|
+
this.user_id = session.id;
|
|
2672
|
+
}
|
|
2673
|
+
});
|
|
2674
|
+
}
|
|
2675
|
+
get user_id() {
|
|
2676
|
+
return this._user_id;
|
|
2677
|
+
}
|
|
2678
|
+
set user_id(value) {
|
|
2679
|
+
value = ((value > 0) ? value : 0);
|
|
2680
|
+
if (this._user_id !== value) {
|
|
2681
|
+
this._user_id = value;
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2684
|
+
updateUserAccount(user_account_data) {
|
|
2685
|
+
const body = {
|
|
2686
|
+
account: user_account_data,
|
|
2687
|
+
};
|
|
2688
|
+
return this.http
|
|
2689
|
+
.post(`${this.config.api_url}/set-user-account.php`, body, {
|
|
2690
|
+
headers: {
|
|
2691
|
+
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
|
|
2692
|
+
},
|
|
2693
|
+
responseType: 'json',
|
|
2694
|
+
observe: 'body',
|
|
2695
|
+
})
|
|
2696
|
+
.pipe(map((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => new EsolveUserAccountResult(response))), catchError((errorRes) => {
|
|
2697
|
+
return this.errorHandler.handleHttpPostError('set-user-account', errorRes);
|
|
2698
|
+
}));
|
|
2699
|
+
}
|
|
2700
|
+
getUserAccount() {
|
|
2701
|
+
return this.http
|
|
2702
|
+
.get(`${this.config.api_url}/get-account.php`)
|
|
2703
|
+
.pipe(map((response) => {
|
|
2704
|
+
if ((response.records === undefined) ||
|
|
2705
|
+
(response.records.length === 0)) {
|
|
2706
|
+
throw response;
|
|
2707
|
+
}
|
|
2708
|
+
const record = response.records[0];
|
|
2709
|
+
return this.processUserAccount(record);
|
|
2710
|
+
}));
|
|
2711
|
+
}
|
|
2712
|
+
setAddress(address_post_data) {
|
|
2713
|
+
const body = {
|
|
2714
|
+
address: address_post_data,
|
|
2715
|
+
};
|
|
2716
|
+
return this.http
|
|
2717
|
+
.post(`${this.config.api_url}/set-address.php`, body, {
|
|
2718
|
+
headers: {
|
|
2719
|
+
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
|
|
2720
|
+
},
|
|
2721
|
+
responseType: 'json',
|
|
2722
|
+
observe: 'body',
|
|
2723
|
+
})
|
|
2724
|
+
.pipe(map((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => new EsolveAddressResult(response))), catchError((errorRes) => {
|
|
2725
|
+
return this.errorHandler.handleHttpPostError('set-registration', errorRes);
|
|
2726
|
+
}));
|
|
2727
|
+
}
|
|
2728
|
+
getAddresses() {
|
|
2729
|
+
try {
|
|
2730
|
+
this.loginGuard();
|
|
2731
|
+
return this.http
|
|
2732
|
+
.get(`${this.config.api_url}/get-addresses.php`, {
|
|
2733
|
+
params: { user_id: this.user_id },
|
|
2734
|
+
})
|
|
2735
|
+
.pipe(map((response) => {
|
|
2736
|
+
if (response.records === undefined) {
|
|
2737
|
+
throw response;
|
|
2738
|
+
}
|
|
2739
|
+
return this.processUserAddress(response.records);
|
|
2740
|
+
}));
|
|
2741
|
+
}
|
|
2742
|
+
catch (error) {
|
|
2743
|
+
return throwError(() => error);
|
|
2744
|
+
}
|
|
2745
|
+
}
|
|
2746
|
+
deleteAddress(id) {
|
|
2747
|
+
return this.http
|
|
2748
|
+
.delete(`${this.config.api_url}/delete-address.php`, {
|
|
2749
|
+
params: { id },
|
|
2750
|
+
responseType: 'json',
|
|
2751
|
+
observe: 'body',
|
|
2752
|
+
})
|
|
2753
|
+
.pipe(map((http_response) => {
|
|
2382
2754
|
if ((http_response.result === undefined) ||
|
|
2383
2755
|
(http_response.result === null) ||
|
|
2384
2756
|
(http_response.result.status !== 'success')) {
|
|
@@ -2562,7 +2934,24 @@ class EsolveAccountService {
|
|
|
2562
2934
|
return throwError(() => error);
|
|
2563
2935
|
}
|
|
2564
2936
|
}
|
|
2937
|
+
getClientAccountBalances() {
|
|
2938
|
+
try {
|
|
2939
|
+
this.loginGuard();
|
|
2940
|
+
return this.http
|
|
2941
|
+
.get(`${this.config.api_url}/get-client-account-balances.php`)
|
|
2942
|
+
.pipe(map((response) => {
|
|
2943
|
+
if (response.records === undefined) {
|
|
2944
|
+
throw response;
|
|
2945
|
+
}
|
|
2946
|
+
return this.processClientBalances(response.records);
|
|
2947
|
+
}));
|
|
2948
|
+
}
|
|
2949
|
+
catch (error) {
|
|
2950
|
+
return throwError(() => error);
|
|
2951
|
+
}
|
|
2952
|
+
}
|
|
2565
2953
|
processUserAccount(record) {
|
|
2954
|
+
var _a;
|
|
2566
2955
|
if (!record) {
|
|
2567
2956
|
throw new Error('Invalid record');
|
|
2568
2957
|
}
|
|
@@ -2572,6 +2961,11 @@ class EsolveAccountService {
|
|
|
2572
2961
|
const user_account = new EsolveUserAccount(+record.userid, record.email, record.registration_type, record.title, record.firstname, record.surname, record.initials, record.gender, record.idnumber);
|
|
2573
2962
|
user_account.contact_details = new EsolveUserAccountContact(record.telnumber, record.cellnumber, record.fax);
|
|
2574
2963
|
user_account.business_details = new EsolveUserAccountBusiness(record.busname, record.vatnum, record.busdescript, record.business_type);
|
|
2964
|
+
if (record.client_details != undefined) {
|
|
2965
|
+
if (((_a = record.client_details) === null || _a === void 0 ? void 0 : _a.account) !== '') {
|
|
2966
|
+
user_account.client_details = new EsolveUserClientAccount(record.client_details.account, record.client_details.branch_code, record.client_details.account_group, record.client_details.pricing_group, +record.client_details.price_list, +record.client_details.loyalty_classification_id, record.client_details.company_name, record.client_details.client_contact_person, record.client_details.client_firstname, record.client_details.client_surname, record.client_details.client_email, record.client_details.client_contact_number, record.client_details.client_fax_number, record.client_details.client_cellphone_number, record.client_details.client_id_number, record.client_details.address_description, record.client_details.street, record.client_details.suburb, record.client_details.city, record.client_details.province, record.client_details.country, record.client_details.postal_code, record.client_details.postal_address, record.client_details.delivery_address, +record.client_details.latitude, +record.client_details.longitude, record.client_details.vat_number, +record.client_details.credit_limit, +record.client_details.pending_invoice_balance, +record.client_details.external_account_balance, record.client_details.ageing, record.client_details.balance_last_updated, +record.client_details.default_sellprice, record.client_details.client_classification, record.client_details.override_stock_listing_identifiers, record.client_details.requires_transaction_approval, record.client_details.is_active);
|
|
2967
|
+
}
|
|
2968
|
+
}
|
|
2575
2969
|
return user_account;
|
|
2576
2970
|
}
|
|
2577
2971
|
processUserAddress(records) {
|
|
@@ -2597,6 +2991,16 @@ class EsolveAccountService {
|
|
|
2597
2991
|
}
|
|
2598
2992
|
return transactions;
|
|
2599
2993
|
}
|
|
2994
|
+
processClientBalances(records) {
|
|
2995
|
+
for (const record of records) {
|
|
2996
|
+
if (!(+record.clients_id > 0)) {
|
|
2997
|
+
return undefined;
|
|
2998
|
+
}
|
|
2999
|
+
const cart_totals = new EsolveCartTotals(record.cart_totals.records, +record.cart_totals.items, +record.cart_totals.total, +record.cart_totals.vat, +record.cart_totals.discount);
|
|
3000
|
+
return new EsolveUserClientAccountBalances(+record.clients_id, record.account, cart_totals, +record.credit_limit, +record.external_account_balance, +record.external_available_balance, +record.new_external_available_balance, record.credit_limit_okay);
|
|
3001
|
+
}
|
|
3002
|
+
return undefined;
|
|
3003
|
+
}
|
|
2600
3004
|
loginGuard() {
|
|
2601
3005
|
if (this.user_id <= 0) {
|
|
2602
3006
|
this.errorHandler.throwError('login_required', 'Login is required');
|
|
@@ -4004,323 +4408,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
|
4004
4408
|
}] }, { type: i1$2.HttpClient }];
|
|
4005
4409
|
} });
|
|
4006
4410
|
|
|
4007
|
-
class EsolveCheckoutResult extends EsolveResponseResult {
|
|
4008
|
-
constructor(response) {
|
|
4009
|
-
var _a;
|
|
4010
|
-
super(response);
|
|
4011
|
-
this.id = 0;
|
|
4012
|
-
this.id = +response.esolve_id;
|
|
4013
|
-
this.process_payment = (_a = response.process_payment) !== null && _a !== void 0 ? _a : false;
|
|
4014
|
-
}
|
|
4015
|
-
}
|
|
4016
|
-
|
|
4017
|
-
class EsolveCartItem {
|
|
4018
|
-
constructor(id, stock_item, qty, delivery_category, type, price, discount, discount_interval, vat_rate, allow_quotes, allow_orders, must_collect, requested_assembly, price_incl, discount_price, discount_price_incl, discount_total, vat_total, total, total_incl) {
|
|
4019
|
-
this.id = id;
|
|
4020
|
-
this.stock_item = stock_item;
|
|
4021
|
-
this.qty = qty;
|
|
4022
|
-
this.delivery_category = delivery_category;
|
|
4023
|
-
this.type = type;
|
|
4024
|
-
this.price = price;
|
|
4025
|
-
this.discount = discount;
|
|
4026
|
-
this.discount_interval = discount_interval;
|
|
4027
|
-
this.vat_rate = vat_rate;
|
|
4028
|
-
this.allow_quotes = allow_quotes;
|
|
4029
|
-
this.allow_orders = allow_orders;
|
|
4030
|
-
this.must_collect = must_collect;
|
|
4031
|
-
this.requested_assembly = requested_assembly;
|
|
4032
|
-
this.price_incl = price_incl;
|
|
4033
|
-
this.discount_price = discount_price;
|
|
4034
|
-
this.discount_price_incl = discount_price_incl;
|
|
4035
|
-
this.discount_total = discount_total;
|
|
4036
|
-
this.vat_total = vat_total;
|
|
4037
|
-
this.total = total;
|
|
4038
|
-
this.total_incl = total_incl;
|
|
4039
|
-
}
|
|
4040
|
-
}
|
|
4041
|
-
|
|
4042
|
-
class EsolveCartStockItem {
|
|
4043
|
-
constructor(code, name, sef_name, description, active, items_in_pack, delivery_category, onhand, image_name) {
|
|
4044
|
-
this.code = code;
|
|
4045
|
-
this.name = name;
|
|
4046
|
-
this.sef_name = sef_name;
|
|
4047
|
-
this.description = description;
|
|
4048
|
-
this.active = active;
|
|
4049
|
-
this.items_in_pack = items_in_pack;
|
|
4050
|
-
this.delivery_category = delivery_category;
|
|
4051
|
-
this.onhand = onhand;
|
|
4052
|
-
this.image_name = image_name;
|
|
4053
|
-
}
|
|
4054
|
-
/**
|
|
4055
|
-
* Path to tiny stock image
|
|
4056
|
-
*/
|
|
4057
|
-
get tiny_image_src() {
|
|
4058
|
-
return this.getImagePath('tiny');
|
|
4059
|
-
}
|
|
4060
|
-
/**
|
|
4061
|
-
* Path to thumbnail stock image
|
|
4062
|
-
*/
|
|
4063
|
-
get thumbnail_image_src() {
|
|
4064
|
-
return this.getImagePath('thumb');
|
|
4065
|
-
}
|
|
4066
|
-
/**
|
|
4067
|
-
* Path to small stock image
|
|
4068
|
-
*/
|
|
4069
|
-
get small_image_src() {
|
|
4070
|
-
return this.getImagePath('small');
|
|
4071
|
-
}
|
|
4072
|
-
/**
|
|
4073
|
-
* Path to big stock image
|
|
4074
|
-
*/
|
|
4075
|
-
get big_image_src() {
|
|
4076
|
-
return this.getImagePath('big');
|
|
4077
|
-
}
|
|
4078
|
-
/**
|
|
4079
|
-
* Path to original stock image
|
|
4080
|
-
*/
|
|
4081
|
-
get original_image_src() {
|
|
4082
|
-
return this.getImagePath('original');
|
|
4083
|
-
}
|
|
4084
|
-
getImagePath(image_size) {
|
|
4085
|
-
if (this.image_name !== '') {
|
|
4086
|
-
return `/images/stock/${image_size}/${this.image_name}`;
|
|
4087
|
-
}
|
|
4088
|
-
return '';
|
|
4089
|
-
}
|
|
4090
|
-
}
|
|
4091
|
-
|
|
4092
|
-
/**
|
|
4093
|
-
* Totals in cart
|
|
4094
|
-
*/
|
|
4095
|
-
class EsolveCartTotals {
|
|
4096
|
-
constructor(
|
|
4097
|
-
/**
|
|
4098
|
-
* Number of unique records in cart
|
|
4099
|
-
*/
|
|
4100
|
-
records = 0,
|
|
4101
|
-
/**
|
|
4102
|
-
* Total quantity of all items in a cart
|
|
4103
|
-
*/
|
|
4104
|
-
items = 0,
|
|
4105
|
-
/**
|
|
4106
|
-
* Total in cart before discount and VAT is added
|
|
4107
|
-
*/
|
|
4108
|
-
sub_total = 0,
|
|
4109
|
-
/**
|
|
4110
|
-
* Total VAT of all the items in the cart
|
|
4111
|
-
*/
|
|
4112
|
-
vat_total = 0,
|
|
4113
|
-
/**
|
|
4114
|
-
* Total discount of all the item in the cart
|
|
4115
|
-
*/
|
|
4116
|
-
discount_total = 0) {
|
|
4117
|
-
this.records = records;
|
|
4118
|
-
this.items = items;
|
|
4119
|
-
this.sub_total = sub_total;
|
|
4120
|
-
this.vat_total = vat_total;
|
|
4121
|
-
this.discount_total = discount_total;
|
|
4122
|
-
}
|
|
4123
|
-
/**
|
|
4124
|
-
* Grand total of cart which includes discount and VAT (NOTE: shipping and insurance is not included)
|
|
4125
|
-
*/
|
|
4126
|
-
get total() {
|
|
4127
|
-
return this.sub_total + this.vat_total - this.discount_total;
|
|
4128
|
-
}
|
|
4129
|
-
}
|
|
4130
|
-
|
|
4131
|
-
class EsolveEmptyCartResult extends EsolveResponseResult {
|
|
4132
|
-
}
|
|
4133
|
-
|
|
4134
|
-
class EsolveCartService {
|
|
4135
|
-
constructor(config, http, errorHandler, responseHandler) {
|
|
4136
|
-
this.config = config;
|
|
4137
|
-
this.http = http;
|
|
4138
|
-
this.errorHandler = errorHandler;
|
|
4139
|
-
this.responseHandler = responseHandler;
|
|
4140
|
-
this._cached_tracking = 0;
|
|
4141
|
-
}
|
|
4142
|
-
/**
|
|
4143
|
-
* Retrieves the current cart
|
|
4144
|
-
*
|
|
4145
|
-
* @returns An `Observable` with an array of cart items
|
|
4146
|
-
*/
|
|
4147
|
-
getCart() {
|
|
4148
|
-
return this.http
|
|
4149
|
-
.get(`${this.config.api_url}/get-cart.php`)
|
|
4150
|
-
.pipe(map((response) => {
|
|
4151
|
-
if (response.records === undefined) {
|
|
4152
|
-
throw response;
|
|
4153
|
-
}
|
|
4154
|
-
return this.processCart(response.records);
|
|
4155
|
-
}));
|
|
4156
|
-
}
|
|
4157
|
-
/**
|
|
4158
|
-
* Updates the cart by preforming various actions, such as adding, editing or removing items from the cart.
|
|
4159
|
-
*
|
|
4160
|
-
* @param items An array of options to update the cart
|
|
4161
|
-
* @param action The default action to preform
|
|
4162
|
-
* @returns An `Observable` with an array of responses that gives feedback on the requested changes
|
|
4163
|
-
*/
|
|
4164
|
-
setCart(items, action = 'add') {
|
|
4165
|
-
const body = {
|
|
4166
|
-
items,
|
|
4167
|
-
action,
|
|
4168
|
-
};
|
|
4169
|
-
return this.http
|
|
4170
|
-
.post(`${this.config.api_url}/set-cart-item.php`, body, {
|
|
4171
|
-
headers: {
|
|
4172
|
-
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
|
|
4173
|
-
},
|
|
4174
|
-
responseType: 'json',
|
|
4175
|
-
observe: 'body',
|
|
4176
|
-
})
|
|
4177
|
-
.pipe(map((response) => {
|
|
4178
|
-
if (response.responses === undefined) {
|
|
4179
|
-
throw response;
|
|
4180
|
-
}
|
|
4181
|
-
return response.responses;
|
|
4182
|
-
}));
|
|
4183
|
-
}
|
|
4184
|
-
setCartEmpty(type, additional_where) {
|
|
4185
|
-
const body = {
|
|
4186
|
-
type,
|
|
4187
|
-
additional_where,
|
|
4188
|
-
};
|
|
4189
|
-
return this.http
|
|
4190
|
-
.post(`${this.config.api_url}/set-cart-empty.php`, body, {
|
|
4191
|
-
headers: {
|
|
4192
|
-
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
|
|
4193
|
-
},
|
|
4194
|
-
responseType: 'json',
|
|
4195
|
-
observe: 'body',
|
|
4196
|
-
})
|
|
4197
|
-
.pipe(map((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => {
|
|
4198
|
-
this._cached_tracking = 0;
|
|
4199
|
-
return new EsolveEmptyCartResult(response);
|
|
4200
|
-
})), catchError((errorRes) => {
|
|
4201
|
-
return this.errorHandler.handleHttpPostError('set-cart-empty', errorRes);
|
|
4202
|
-
}));
|
|
4203
|
-
}
|
|
4204
|
-
/**
|
|
4205
|
-
* Retrieves the totals of the cart with all the totals calculated
|
|
4206
|
-
*
|
|
4207
|
-
* @returns An `Observable` with an object containing cart totals
|
|
4208
|
-
*/
|
|
4209
|
-
getTotals(type) {
|
|
4210
|
-
return this.http
|
|
4211
|
-
.get(`${this.config.api_url}/get-cart-totals.php`, {
|
|
4212
|
-
params: {
|
|
4213
|
-
type: type !== null && type !== void 0 ? type : '',
|
|
4214
|
-
},
|
|
4215
|
-
})
|
|
4216
|
-
.pipe(map((response) => {
|
|
4217
|
-
if (response.records === undefined) {
|
|
4218
|
-
throw response;
|
|
4219
|
-
}
|
|
4220
|
-
return this.processCartTotals(response.records);
|
|
4221
|
-
}));
|
|
4222
|
-
}
|
|
4223
|
-
/**
|
|
4224
|
-
* Retrieves a tracking code for the cart
|
|
4225
|
-
*
|
|
4226
|
-
* @returns An `Observable` with the cart tracking code
|
|
4227
|
-
*/
|
|
4228
|
-
getTrackingCode() {
|
|
4229
|
-
return iif(() => this._cached_tracking > 0, of(this._cached_tracking), this.http
|
|
4230
|
-
.get(`${this.config.api_url}/get-checkout-tracking.php`)
|
|
4231
|
-
.pipe(map((response) => {
|
|
4232
|
-
if (response.records === undefined) {
|
|
4233
|
-
throw response;
|
|
4234
|
-
}
|
|
4235
|
-
this._cached_tracking = response.records.tracking;
|
|
4236
|
-
return response.records.tracking;
|
|
4237
|
-
})));
|
|
4238
|
-
}
|
|
4239
|
-
/**
|
|
4240
|
-
* Initiates checkout of the cart items
|
|
4241
|
-
*
|
|
4242
|
-
* @param type The cart type that needs to be checked out
|
|
4243
|
-
* @param addresses_id The ID of the delivery address
|
|
4244
|
-
* @param shipping_id The ID of the shipping method
|
|
4245
|
-
* @param payment_method_id The ID of the selected payment method
|
|
4246
|
-
* @param location_id The ID of the selected branch from with shipping needs to be calculated
|
|
4247
|
-
* @param comments Additional comments on the cart
|
|
4248
|
-
* @returns An `Observable` with the transaction ID
|
|
4249
|
-
*/
|
|
4250
|
-
checkout(type, addresses_id, shipping_id, payment_method_id = 0, location_id = 0, comments = '') {
|
|
4251
|
-
const body = {
|
|
4252
|
-
type,
|
|
4253
|
-
addresses_id,
|
|
4254
|
-
shipping_id,
|
|
4255
|
-
payment_method_id,
|
|
4256
|
-
location_id,
|
|
4257
|
-
comments,
|
|
4258
|
-
tracking: 0,
|
|
4259
|
-
};
|
|
4260
|
-
return this.getTrackingCode().pipe(switchMap((tracking) => {
|
|
4261
|
-
if (tracking <= 0) {
|
|
4262
|
-
throw tracking;
|
|
4263
|
-
}
|
|
4264
|
-
body.tracking = tracking;
|
|
4265
|
-
return this.http
|
|
4266
|
-
.post(`${this.config.api_url}/set-checkout.php`, body, {
|
|
4267
|
-
headers: {
|
|
4268
|
-
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
|
|
4269
|
-
},
|
|
4270
|
-
responseType: 'json',
|
|
4271
|
-
observe: 'body',
|
|
4272
|
-
})
|
|
4273
|
-
.pipe(map((http_response) => this.responseHandler.validateSingleHttpResponse(http_response, (response) => {
|
|
4274
|
-
this._cached_tracking = 0;
|
|
4275
|
-
return new EsolveCheckoutResult(response);
|
|
4276
|
-
})), catchError((errorRes) => {
|
|
4277
|
-
return this.errorHandler.handleHttpPostError('set-checkout', errorRes);
|
|
4278
|
-
}));
|
|
4279
|
-
}));
|
|
4280
|
-
}
|
|
4281
|
-
/**
|
|
4282
|
-
* Processes the eSolve tree records
|
|
4283
|
-
*
|
|
4284
|
-
* @param cart_item_records Records to process
|
|
4285
|
-
* @returns An array of processed cart items
|
|
4286
|
-
*/
|
|
4287
|
-
processCart(cart_item_records) {
|
|
4288
|
-
const cart_items = [];
|
|
4289
|
-
if (cart_item_records) {
|
|
4290
|
-
for (const cart_item_record of cart_item_records) {
|
|
4291
|
-
const cart_stock_item = new EsolveCartStockItem(cart_item_record.code, cart_item_record.name, cart_item_record.sef_name, cart_item_record.description, cart_item_record.is_active, +cart_item_record.items_in_pack, cart_item_record.delivery_category, +cart_item_record.onhand, cart_item_record.image_name);
|
|
4292
|
-
cart_items.push(new EsolveCartItem(+cart_item_record.id, cart_stock_item, +cart_item_record.qty, cart_item_record.delivery_category, cart_item_record.type, +cart_item_record.price, +cart_item_record.discount, +cart_item_record.discount_interval, cart_item_record.vat_rate, cart_item_record.allow_quotes, cart_item_record.allow_orders, cart_item_record.must_collect, cart_item_record.requested_assembly, +cart_item_record.price_incl, +cart_item_record.discount_price, +cart_item_record.discount_price_incl, +cart_item_record.discount_total, +cart_item_record.vat_total, +cart_item_record.line_total, +cart_item_record.line_total_incl));
|
|
4293
|
-
}
|
|
4294
|
-
}
|
|
4295
|
-
return cart_items;
|
|
4296
|
-
}
|
|
4297
|
-
/**
|
|
4298
|
-
* Processes the eSolve cart totals
|
|
4299
|
-
*
|
|
4300
|
-
* @param record Data to process
|
|
4301
|
-
* @returns Processed cart totals
|
|
4302
|
-
*/
|
|
4303
|
-
processCartTotals(record) {
|
|
4304
|
-
const cart_totals = new EsolveCartTotals(+record.records, +record.items, +record.total, +record.vat, +record.discount);
|
|
4305
|
-
return cart_totals;
|
|
4306
|
-
}
|
|
4307
|
-
}
|
|
4308
|
-
EsolveCartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: EsolveCartService, deps: [{ token: ESOLVE_CONNECT_CONFIG }, { token: i1$2.HttpClient }, { token: EsolveErrorHandlerService }, { token: EsolveResponseHandlerService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4309
|
-
EsolveCartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: EsolveCartService, providedIn: 'root' });
|
|
4310
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: EsolveCartService, decorators: [{
|
|
4311
|
-
type: Injectable,
|
|
4312
|
-
args: [{
|
|
4313
|
-
providedIn: 'root',
|
|
4314
|
-
}]
|
|
4315
|
-
}], ctorParameters: function () {
|
|
4316
|
-
return [{ type: undefined, decorators: [{
|
|
4317
|
-
type: Inject,
|
|
4318
|
-
args: [ESOLVE_CONNECT_CONFIG]
|
|
4319
|
-
}] }, { type: i1$2.HttpClient }, { type: EsolveErrorHandlerService }, { type: EsolveResponseHandlerService }];
|
|
4320
|
-
} });
|
|
4321
|
-
|
|
4322
|
-
// TODO: Spilt folder to file types
|
|
4323
|
-
|
|
4324
4411
|
// Only export the types that are accessible to the public API
|
|
4325
4412
|
|
|
4326
4413
|
class EsolveBankingDetails {
|
|
@@ -5092,5 +5179,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
|
5092
5179
|
* Generated bundle index. Do not edit.
|
|
5093
5180
|
*/
|
|
5094
5181
|
|
|
5095
|
-
export { ESOLVE_CONNECT_CONFIG, EsolveAccountConfirmationResult, EsolveAccountService, EsolveAdditionalStockImage, EsolveAddress, EsolveAddressResult, EsolveAsset, EsolveAssetsService, EsolveAuthService, EsolveBankingDetails, EsolveBanner, EsolveBannerImage, EsolveBannerImageHotspot, EsolveBannerService, EsolveCartItem, EsolveCartService, EsolveCartStockItem, EsolveCartTotals, EsolveCategoryTreeItem, EsolveCategoryTreeService, EsolveChangePasswordResult, EsolveCheckoutResult, EsolveColour, EsolveCookieService, EsolveEmptyCartResult, EsolveEmptyWishlistResult, EsolveEnquiryResult, EsolveEnquiryService, EsolveErrorHandlerService, EsolveFilterFactory, EsolveGeocodeAddressResult, EsolveGeocodeCoordsResult, EsolveGeocodeResult, EsolveGeocoderService, EsolveHttpError, EsolveLinkedAsset, EsolveLinkedStockItem, EsolveList, EsolveLocation, EsolveLocationAddress, EsolveLocationContactInfo, EsolveLocationGEO, EsolveLocationPOBoxAddress, EsolveLocationTradingDay, EsolveLocationTradingTimes, EsolveLocationsService, EsolveManufacturer, EsolveManufacturersService, EsolveMediaStockItem, EsolveMenuItem, EsolveMenuService, EsolveMultipleSelectFilter, EsolveNewsArticle, EsolveNewsArticleAuthor, EsolveNewsArticleList, EsolveNewsGroup, EsolveNewsService, EsolvePaymentMethod, EsolvePaymentResult, EsolvePaymentService, EsolveRange, EsolveRangeFilter, EsolveRangesService, EsolveRecipeStockItem, EsolveRegistrationResult, EsolveResetPasswordResult, EsolveResponseHandlerService, EsolveResponseResult, EsolveResult, EsolveSeoInfo, EsolveSeoService, EsolveSession, EsolveSessionService, EsolveShippingCost, EsolveShippingMethod, EsolveShippingService, EsolveShippingTotals, EsolveSingleSelectFilter, EsolveSpecial, EsolveSpecialDates, EsolveSpecialImage, EsolveSpecialImageCollection, EsolveSpecialsService, EsolveStockBadge, EsolveStockGroup, EsolveStockGroupItem, EsolveStockImage, EsolveStockImageCollection, EsolveStockItem, EsolveStockItemBase, EsolveStockItemList, EsolveStockLeadTimes, EsolveStockPrice, EsolveStockService, EsolveSupplier, EsolveSuppliersService, EsolveTag, EsolveTagsService, EsolveTopic, EsolveTopicService, EsolveTransaction, EsolveTransactionAddress, EsolveTransactionClient, EsolveTransactionItem, EsolveTransactionItemPrice, EsolveTransactionList, EsolveTransactionLocation, EsolveTransactionPaymentMethod, EsolveTransactionShippingMethod, EsolveTransactionUser, EsolveUserAccount, EsolveUserAccountBusiness, EsolveUserAccountContact, EsolveUserAccountResult, EsolveVaultItem, EsolveVaultItemResult, EsolveWishlistItem, EsolveWishlistService, NgEsolveConnectModule };
|
|
5182
|
+
export { ESOLVE_CONNECT_CONFIG, EsolveAccountConfirmationResult, EsolveAccountService, EsolveAdditionalStockImage, EsolveAddress, EsolveAddressResult, EsolveAsset, EsolveAssetsService, EsolveAuthService, EsolveBankingDetails, EsolveBanner, EsolveBannerImage, EsolveBannerImageHotspot, EsolveBannerService, EsolveCartItem, EsolveCartService, EsolveCartStockItem, EsolveCartTotals, EsolveCategoryTreeItem, EsolveCategoryTreeService, EsolveChangePasswordResult, EsolveCheckoutResult, EsolveColour, EsolveCookieService, EsolveEmptyCartResult, EsolveEmptyWishlistResult, EsolveEnquiryResult, EsolveEnquiryService, EsolveErrorHandlerService, EsolveFilterFactory, EsolveGeocodeAddressResult, EsolveGeocodeCoordsResult, EsolveGeocodeResult, EsolveGeocoderService, EsolveHttpError, EsolveLinkedAsset, EsolveLinkedStockItem, EsolveList, EsolveLocation, EsolveLocationAddress, EsolveLocationContactInfo, EsolveLocationGEO, EsolveLocationPOBoxAddress, EsolveLocationTradingDay, EsolveLocationTradingTimes, EsolveLocationsService, EsolveManufacturer, EsolveManufacturersService, EsolveMediaStockItem, EsolveMenuItem, EsolveMenuService, EsolveMultipleSelectFilter, EsolveNewsArticle, EsolveNewsArticleAuthor, EsolveNewsArticleList, EsolveNewsGroup, EsolveNewsService, EsolvePaymentMethod, EsolvePaymentResult, EsolvePaymentService, EsolveRange, EsolveRangeFilter, EsolveRangesService, EsolveRecipeStockItem, EsolveRegistrationResult, EsolveResetPasswordResult, EsolveResponseHandlerService, EsolveResponseResult, EsolveResult, EsolveSeoInfo, EsolveSeoService, EsolveSession, EsolveSessionService, EsolveShippingCost, EsolveShippingMethod, EsolveShippingService, EsolveShippingTotals, EsolveSingleSelectFilter, EsolveSpecial, EsolveSpecialDates, EsolveSpecialImage, EsolveSpecialImageCollection, EsolveSpecialsService, EsolveStockBadge, EsolveStockGroup, EsolveStockGroupItem, EsolveStockImage, EsolveStockImageCollection, EsolveStockItem, EsolveStockItemBase, EsolveStockItemList, EsolveStockLeadTimes, EsolveStockPrice, EsolveStockService, EsolveSupplier, EsolveSuppliersService, EsolveTag, EsolveTagsService, EsolveTopic, EsolveTopicService, EsolveTransaction, EsolveTransactionAddress, EsolveTransactionClient, EsolveTransactionItem, EsolveTransactionItemPrice, EsolveTransactionList, EsolveTransactionLocation, EsolveTransactionPaymentMethod, EsolveTransactionShippingMethod, EsolveTransactionUser, EsolveUserAccount, EsolveUserAccountBusiness, EsolveUserAccountContact, EsolveUserAccountResult, EsolveUserClientAccount, EsolveUserClientAccountBalances, EsolveVaultItem, EsolveVaultItemResult, EsolveWishlistItem, EsolveWishlistService, NgEsolveConnectModule };
|
|
5096
5183
|
//# sourceMappingURL=esolve-ng-esolve-connect.mjs.map
|