Skip to content

Commit

Permalink
fix: applied taxes and applied discounts on line item (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtwichel authored Mar 17, 2024
1 parent f706ec6 commit 65ee954
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
### 2.1.1 March 17th, 2024

- Fixed applied taxes and applied discounts on `OrderLineItem`

### 2.1.0 October 14th, 2023

- Added customer group and customer segment endpoints!

### 2.0.2 October 14th, 2023

- Hot fixed issue with modifier location overrides

### 2.0.1 July 3rd, 2023
Expand Down
4 changes: 2 additions & 2 deletions lib/src/shared_model/order_line_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class OrderLineItem extends Equatable {
final String? catalogObjectId;
final String? variationName;
final List<OrderLineItemModifier>? modifiers;
final List<OrderLineItemTax>? appliedTaxes;
final List<OrderLineItemDiscount>? appliedDiscounts;
final List<OrderLineItemAppliedTax>? appliedTaxes;
final List<OrderLineItemAppliedDiscount>? appliedDiscounts;
final Money? basePriceMoney;
final Money? variationTotalPriceMoney;
final Money? grossSalesMoney;
Expand Down
7 changes: 4 additions & 3 deletions lib/src/shared_model/order_line_item.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions lib/src/shared_model/order_line_item_applied_discount.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:equatable/equatable.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:square_connect/square_connect.dart';

part 'order_line_item_applied_discount.g.dart';

@JsonSerializable()
class OrderLineItemAppliedDiscount extends Equatable {
const OrderLineItemAppliedDiscount({
required this.discountUid,
this.uid,
this.appliedMoney,
});

/// Converts a [Map]<[String], [dynamic]> to a [OrderLineItemAppliedDiscount]
factory OrderLineItemAppliedDiscount.fromJson(Map<String, dynamic> json) =>
_$OrderLineItemAppliedDiscountFromJson(json);

/// Converts a [OrderLineItemAppliedDiscount] to a [Map]<[String], [dynamic]>
Map<String, dynamic> toJson() => _$OrderLineItemAppliedDiscountToJson(this);

final String? uid;
final String discountUid;
final Money? appliedMoney;

@override
List<Object?> get props => [uid, discountUid, appliedMoney];
}
33 changes: 33 additions & 0 deletions lib/src/shared_model/order_line_item_applied_discount.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions lib/src/shared_model/order_line_item_applied_tax.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:equatable/equatable.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:square_connect/square_connect.dart';

part 'order_line_item_applied_tax.g.dart';

@JsonSerializable()
class OrderLineItemAppliedTax extends Equatable {
const OrderLineItemAppliedTax({
required this.taxUid,
this.uid,
this.appliedMoney,
});

/// Converts a [Map] to an [OrderLineItemAppliedTax]
factory OrderLineItemAppliedTax.fromJson(Map<String, dynamic> json) =>
_$OrderLineItemAppliedTaxFromJson(json);

/// Converts a [OrderLineItemAppliedTax] to a [Map]
Map<String, dynamic> toJson() => _$OrderLineItemAppliedTaxToJson(this);

final String? uid;
final String taxUid;
final Money? appliedMoney;

@override
List<Object?> get props => [uid, taxUid, appliedMoney];
}
33 changes: 33 additions & 0 deletions lib/src/shared_model/order_line_item_applied_tax.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions lib/src/shared_model/shared_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ export 'order_fulfillment_shipment_details.dart';
export 'order_fulfillment_state.dart';
export 'order_fulfillment_type.dart';
export 'order_line_item.dart';
export 'order_line_item_applied_discount.dart';
export 'order_line_item_applied_tax.dart';
export 'order_line_item_discount.dart';
export 'order_line_item_discount_scope.dart';
export 'order_line_item_discount_type.dart';
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: square_connect
description: A wrapper for the Square Connect APIs. It's intended use is in a flutter application to manage inventory, catalog, customers, labor, and more on the Square platform.
version: 2.1.0
version: 2.1.1
homepage: https://github.com/mtwichel/square-connect-flutter-library

environment:
Expand Down

0 comments on commit 65ee954

Please sign in to comment.