Skip to content

Commit

Permalink
Removed Tax from item.
Browse files Browse the repository at this point in the history
  • Loading branch information
OsamaRabie committed Sep 11, 2022
1 parent 257105e commit 3a0bc94
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CommonDataModelsKit-iOS.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |spec|
#

spec.name = "CommonDataModelsKit-iOS"
spec.version = "1.0.67"
spec.version = "1.0.68"
spec.summary = "Common data models and enums between different kits"

# This description is used to generate tags and improve search results.
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import Foundation
}
}
/// The discount applied to the item's price
public let discount : AmountModificatorModel?
public let discount : [AmountModificatorModel]?
/// The list of Taxes to be applied to the item's price after discount
public let taxes : [Tax]?
/// The price final amount after applyig discount & taxes
Expand All @@ -73,12 +73,12 @@ import Foundation
- Parameter description: A description of the item
- Parameter price: The raw original price in the original currency
- Parameter quantity: The quantity added to this item
- Parameter discount: The discount applied to the item's price
- Parameter discount: The discounts applied to the item's price
- Parameter taxes: The list of Taxs to be applied to the item's price after discount
- Parameter totalAmount: The price final amount after applyig discount & taxes
- Parameter currency: Item currency
*/
@objc public init(title: String?, description: String?, price: Double = 0, quantity: Double = 0, discount: AmountModificatorModel?,taxes:[Tax]? = nil,totalAmount:Double = 0,currency:TapCurrencyCode = .undefined,productID:String? = "", category:String? = "", vendor:Vendor? = nil, fulfillmentService:String? = "", requiresShipping:Bool = false, itemCode:String? = "", accountCode:String? = "", tags:String? = "" ) {
@objc public init(title: String?, description: String?, price: Double = 0, quantity: Double = 0, discount: [AmountModificatorModel]?,taxes:[Tax]? = nil,totalAmount:Double = 0,currency:TapCurrencyCode = .undefined,productID:String? = "", category:String? = "", vendor:Vendor? = nil, fulfillmentService:String? = "", requiresShipping:Bool = false, itemCode:String? = "", accountCode:String? = "", tags:String? = "" ) {
self.title = title
self.itemDescription = description
self.price = price
Expand Down Expand Up @@ -130,7 +130,7 @@ import Foundation
price = try values.decodeIfPresent(Double.self, forKey: .price)
quantity = try values.decode(Double.self, forKey: .quantity)

discount = try values.decodeIfPresent(AmountModificatorModel.self, forKey: .discount)
discount = try values.decodeIfPresent([AmountModificatorModel].self, forKey: .discount)
taxes = try values.decodeIfPresent([Tax].self, forKey: .taxes)
itemCode = try values.decodeIfPresent (String.self , forKey: .itemCode )
accountCode = try values.decodeIfPresent (String.self , forKey: .accountCode )
Expand All @@ -154,7 +154,9 @@ import Foundation
guard let price = price else { return 0 }

// First apply the discount if any
let discountedItemPrice:Double = price - (discount?.caluclateActualModificationValue(with: price) ?? 0)
let discountedItemPrice:Double = discount?.reduce(price){ $0 - $1.caluclateActualModificationValue(with: price) } ?? price

//price - (discount?.caluclateActualModificationValue(with: price) ?? 0)
// Secondly apply the taxes if any
var discountedWithTaxesPrice:Double = taxes?.reduce(discountedItemPrice) { $0 + $1.amount.caluclateActualModificationValue(with: discountedItemPrice) } ?? discountedItemPrice
// Put in the quantity in action
Expand Down

0 comments on commit 3a0bc94

Please sign in to comment.