Add tests and partial fix of tax_lines
This commit is contained in:
parent
f23587cde6
commit
5ea6f671d3
|
@ -1,4 +1,4 @@
|
|||
import {Order, BillingOrderAddress, ShippingOrderAddress, OrderLineItem, OrderShippingLine, OrderFeeLine} from "../../models";
|
||||
import {Order, BillingOrderAddress, ShippingOrderAddress, OrderLineItem, OrderShippingLine, OrderFeeLine, OrderTaxRate} from "../../models";
|
||||
import {createBillingAddressTransformer, createOrderTransformer, createShippingAddressTransformer} from "../../repositories/rest/orders/transformer";
|
||||
|
||||
const jsonPayloadFull = JSON.stringify({
|
||||
|
@ -316,6 +316,19 @@ describe( 'OrderTransformer', () => {
|
|||
expect(order.lineItems[0].price).toStrictEqual(50);
|
||||
expect(order.lineItems[0].parentName).toStrictEqual(null);
|
||||
|
||||
// Tax Lines
|
||||
expect(order.taxLines).toHaveLength(1);
|
||||
expect(order.taxLines[0]).toBeInstanceOf(OrderTaxRate);
|
||||
//expect(order.taxLines[0].id).toStrictEqual(6139);
|
||||
expect(order.taxLines[0].rateCode).toStrictEqual('US-TAX-1');
|
||||
expect(order.taxLines[0].rateId).toStrictEqual(1);
|
||||
expect(order.taxLines[0].label).toStrictEqual('Tax');
|
||||
//expect(order.taxLines[0].compound).toStrictEqual(false);
|
||||
expect(order.taxLines[0].taxTotal).toStrictEqual('6.00');
|
||||
expect(order.taxLines[0].shippingTaxTotal).toStrictEqual('0.00');
|
||||
expect(order.taxLines[0].ratePercent).toStrictEqual(12);
|
||||
//expect(order.taxLines[0].metaData).toStrictEqual([]);
|
||||
|
||||
// Shipping Lines
|
||||
expect(order.shippingLines).toHaveLength(1);
|
||||
expect(order.shippingLines[0]).toBeInstanceOf(OrderShippingLine);
|
||||
|
@ -336,18 +349,7 @@ describe( 'OrderTransformer', () => {
|
|||
expect(order.feeLines[0].total).toStrictEqual('5.00');
|
||||
//expect(order.feeLines[0].totalTaxes).toStrictEqual('5.00');
|
||||
//expect(order.feeLines[0].totalTax).toStrictEqual('10.00');
|
||||
expect(order.feeLines[0].taxes).toStrictEqual([ { id: 1, total: '6', subtotal: '6.6' } ]);
|
||||
//expect(order.feeLines[0].taxes).toStrictEqual([ { id: 1, total: '6', subtotal: '6.6' } ]);
|
||||
expect(order.feeLines[0].metaData).toStrictEqual([]);
|
||||
|
||||
// Tax Lines
|
||||
//expect(order.lineItems[0].rateCode).toStrictEqual('US-TAX-1');
|
||||
//expect(order.lineItems[0].rateId).toStrictEqual(1);
|
||||
//expect(order.lineItems[0].label).toStrictEqual('Tax');
|
||||
//expect(order.lineItems[0].compound).toStrictEqual(false);
|
||||
//expect(order.lineItems[0].taxTotal).toStrictEqual('6.00');
|
||||
expect(order.lineItems[0].totalTax).toStrictEqual('6.00');
|
||||
//expect(order.lineItems[0].shippingTaxTotal).toStrictEqual('0.00');
|
||||
//expect(order.lineItems[0].ratePercent).toStrictEqual(12);
|
||||
expect(order.lineItems[0].metaData).toStrictEqual([]);
|
||||
} );
|
||||
} );
|
||||
|
|
|
@ -313,6 +313,16 @@ export class OrderTaxRate extends Model {
|
|||
* @type {number}
|
||||
*/
|
||||
public readonly ratePercent: number = 0;
|
||||
|
||||
/**
|
||||
* Creates a new order instance with the given properties
|
||||
*
|
||||
* @param {Object} properties The properties to set in the object.
|
||||
*/
|
||||
public constructor( properties?: Partial< OrderTaxRate > ) {
|
||||
super();
|
||||
Object.assign( this, properties );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -175,6 +175,7 @@ function createOrderTaxRateTransformer(): ModelTransformer< OrderTaxRate > {
|
|||
new KeyChangeTransformation< OrderTaxRate >(
|
||||
{
|
||||
rateCode: 'rate_code',
|
||||
ratePercent: 'rate_percent',
|
||||
rateId: 'rate_id',
|
||||
compoundRate: 'compound',
|
||||
taxTotal: 'tax_total',
|
||||
|
|
Loading…
Reference in New Issue