@@ -326,27 +326,6 @@ define([
326
326
getEmail : function ( ) {
327
327
return quote . guestEmail ? quote . guestEmail : window . checkoutConfig . customerData . email ;
328
328
} ,
329
- calculateTaxSubtotals : function ( lineItems ) {
330
- const taxSubtotals = { } ;
331
-
332
- lineItems . forEach ( ( item ) => {
333
- const taxRate = parseFloat ( item . tax_rate ) ;
334
- const taxAmount = parseFloat ( item . tax_amount ) ;
335
- const taxableAmount = parseFloat ( item . net_amount ) ;
336
-
337
- if ( ! taxSubtotals [ taxRate ] ) {
338
- taxSubtotals [ taxRate ] = {
339
- tax_amount : 0 ,
340
- taxable_amount : 0 ,
341
- tax_rate : taxRate
342
- } ;
343
- }
344
- taxSubtotals [ taxRate ] . tax_amount += taxAmount ;
345
- taxSubtotals [ taxRate ] . taxable_amount += taxableAmount ;
346
- } ) ;
347
-
348
- return Object . values ( taxSubtotals ) ;
349
- } ,
350
329
placeOrderIntent : function ( ) {
351
330
let totals = quote . getTotals ( ) ( ) ,
352
331
billingAddress = quote . billingAddress ( ) ,
@@ -368,13 +347,33 @@ define([
368
347
type : item [ 'is_virtual' ] === '0' ? 'PHYSICAL' : 'DIGITAL'
369
348
} ) ;
370
349
} ) ;
350
+ lineItems . push ( {
351
+ name : 'Shipping' ,
352
+ description : 'Shipping fee' ,
353
+ gross_amount : parseFloat ( totals [ 'shipping_incl_tax' ] ) . toFixed ( 2 ) ,
354
+ net_amount : parseFloat ( totals [ 'shipping_amount' ] ) . toFixed ( 2 ) ,
355
+ quantity : 1 ,
356
+ unit_price : parseFloat ( totals [ 'shipping_amount' ] ) . toFixed ( 2 ) ,
357
+ tax_amount : parseFloat ( totals [ 'shipping_tax_amount' ] ) . toFixed ( 2 ) ,
358
+ tax_rate : (
359
+ parseFloat ( totals [ 'shipping_tax_amount' ] ) /
360
+ parseFloat ( totals [ 'shipping_amount' ] )
361
+ ) . toFixed ( 6 ) ,
362
+ tax_class_name : '' ,
363
+ quality_unit : config . orderIntentConfig . weightUnit ,
364
+ type : 'SHIPPING_FEE'
365
+ } ) ;
371
366
367
+ const gross_amount = parseFloat ( totals [ 'grand_total' ] ) ;
368
+ const tax_amount =
369
+ parseFloat ( totals [ 'tax_amount' ] ) + parseFloat ( totals [ 'shipping_tax_amount' ] ) ;
370
+ const net_amount = gross_amount - tax_amount ;
372
371
const orderIntentRequestBody = {
373
- gross_amount : parseFloat ( totals [ 'grand_total' ] ) . toFixed ( 2 ) ,
374
- invoice_type : config . orderIntentConfig . invoiceType ,
375
- currency : totals [ 'base_currency_code' ] ,
372
+ gross_amount : gross_amount . toFixed ( 2 ) ,
373
+ net_amount : net_amount . toFixed ( 2 ) ,
374
+ tax_amount : tax_amount . toFixed ( 2 ) ,
375
+ currency : totals [ 'quote_currency_code' ] ,
376
376
line_items : lineItems ,
377
- tax_subtotals : this . calculateTaxSubtotals ( lineItems ) ,
378
377
buyer : {
379
378
company : {
380
379
organization_number : this . companyId ( ) ,
0 commit comments