Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit cc1e099
Author: Alec Ritson <hello@itsalec.co.uk>
Date:   Wed Mar 29 12:19:37 2023 +0100

    Update CHANGELOG.md

commit 48e1820
Author: Alec Ritson <hello@itsalec.co.uk>
Date:   Wed Mar 29 12:14:55 2023 +0100

    Update CalculateTax.php (#905)

commit a25ae05
Author: Alec Ritson <hello@itsalec.co.uk>
Date:   Mon Mar 27 14:49:32 2023 +0100

    Update split_packages.yml

commit 7c9c9c2
Author: Alec Ritson <hello@itsalec.co.uk>
Date:   Fri Mar 24 14:18:08 2023 +0000

    Update changelogs (#900)

commit 04a1887
Author: Alec Ritson <hello@itsalec.co.uk>
Date:   Fri Mar 24 13:51:29 2023 +0000

    :beer:

commit 6f28e8d
Author: Ryan Mitchell <ryan@thoughtcollective.com>
Date:   Fri Mar 24 13:41:56 2023 +0000

    Add max user uses to discounts (#892)

    * Add ability to limit discount uses by users

    * Pint

    * Wrong relation

    * Use $cart->user instead of auth

    * Fix test bug

    * Fix test bugs

    * Change field type

    * Bug fixes

commit aff3916
Author: wychoong <67364036+wychoong@users.noreply.github.com>
Date:   Fri Mar 24 19:49:43 2023 +0800

    Cart meta cast (#895)

    * Squashed commit of the following:

    commit 02c2671
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Fri Feb 10 11:13:49 2023 +0000

        Update lines.blade.php (#849)

    commit 0780a1c
    Author: wychoong <67364036+wychoong@users.noreply.github.com>
    Date:   Fri Feb 10 18:41:36 2023 +0800

        Update CollectionTree.php (#835)

        Co-authored-by: Alec Ritson <hello@itsalec.co.uk>

    commit e558799
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Fri Feb 10 09:47:16 2023 +0000

        :beer:

    commit 8fd4842
    Merge: df6f7f7 51af420
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Fri Feb 10 09:47:03 2023 +0000

        Merge branch '0.2' of github.com:lunarphp/lunar into 0.2

    commit df6f7f7
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Fri Feb 10 09:47:00 2023 +0000

        :beer:

    commit 51af420
    Author: wychoong <67364036+wychoong@users.noreply.github.com>
    Date:   Fri Feb 10 17:43:10 2023 +0800

        [0.2] Hotfix - fix pluck on null (#834)

        * fix pluck on null

        * Update AbstractDiscount.php

        ---------

        Co-authored-by: Alec Ritson <hello@itsalec.co.uk>

    commit 7b5ce85
    Author: wychoong <67364036+wychoong@users.noreply.github.com>
    Date:   Fri Feb 10 17:16:50 2023 +0800

        [0.2] Fix/discount by product (#841)

        * fix

        * add test

        * fix discount minSpend precision

        * fix discount condition logic

        * fix

        * fix coupon check

    commit 72f8454
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Fri Feb 10 09:16:16 2023 +0000

        Hotfix [0.2] - Wrap customer group in array (#846)

        * Wrap customer group in array

        * Update ProductVariantTest.php

    commit b8773d3
    Author: Ryan Mitchell <ryan@thoughtcollective.com>
    Date:   Wed Feb 8 20:43:09 2023 +0000

        When DB::table() is used make sure connection is passed (#826)

    commit 650d9db
    Merge: dcd39cc de20aff
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Wed Feb 1 09:57:04 2023 +0000

        Merge branch 'main' into 0.2

    commit dcd39cc
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Tue Jan 31 07:29:15 2023 +0000

        :beer:

    * Squashed commit of the following:

    commit 1a362cc
    Author: Ivanka Todorova <1038697+fakeheal@users.noreply.github.com>
    Date:   Tue Feb 14 13:25:25 2023 +0200

        Fix validation of attributes of type TranslatedText (#839)

        * fix: validation rules to be applied on elements in `TranslatedText`

        * fix: "reset" the validation rules applied to each sub-field in `TranslatedText`

        * chore: add tests for validating attribute fields (required/optional) and their additional rules

        ---------

        Co-authored-by: Alec Ritson <hello@itsalec.co.uk>

    commit 6c1ab08
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Tue Feb 14 10:58:15 2023 +0000

        [0.2] Hotfix - Fix collection name on creation (#852)

        * Squashed commit of the following:

        commit 02c2671
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Fri Feb 10 11:13:49 2023 +0000

            Update lines.blade.php (#849)

        commit 0780a1c
        Author: wychoong <67364036+wychoong@users.noreply.github.com>
        Date:   Fri Feb 10 18:41:36 2023 +0800

            Update CollectionTree.php (#835)

            Co-authored-by: Alec Ritson <hello@itsalec.co.uk>

        commit e558799
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Fri Feb 10 09:47:16 2023 +0000

            :beer:

        commit 8fd4842
        Merge: df6f7f7 51af420
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Fri Feb 10 09:47:03 2023 +0000

            Merge branch '0.2' of github.com:lunarphp/lunar into 0.2

        commit df6f7f7
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Fri Feb 10 09:47:00 2023 +0000

            :beer:

        commit 51af420
        Author: wychoong <67364036+wychoong@users.noreply.github.com>
        Date:   Fri Feb 10 17:43:10 2023 +0800

            [0.2] Hotfix - fix pluck on null (#834)

            * fix pluck on null

            * Update AbstractDiscount.php

            ---------

            Co-authored-by: Alec Ritson <hello@itsalec.co.uk>

        commit 7b5ce85
        Author: wychoong <67364036+wychoong@users.noreply.github.com>
        Date:   Fri Feb 10 17:16:50 2023 +0800

            [0.2] Fix/discount by product (#841)

            * fix

            * add test

            * fix discount minSpend precision

            * fix discount condition logic

            * fix

            * fix coupon check

        commit 72f8454
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Fri Feb 10 09:16:16 2023 +0000

            Hotfix [0.2] - Wrap customer group in array (#846)

            * Wrap customer group in array

            * Update ProductVariantTest.php

        commit b8773d3
        Author: Ryan Mitchell <ryan@thoughtcollective.com>
        Date:   Wed Feb 8 20:43:09 2023 +0000

            When DB::table() is used make sure connection is passed (#826)

        commit 650d9db
        Merge: dcd39cc de20aff
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Wed Feb 1 09:57:04 2023 +0000

            Merge branch 'main' into 0.2

        commit dcd39cc
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Tue Jan 31 07:29:15 2023 +0000

            :beer:

        * Check for attribute type when creating

    commit 0942397
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Tue Feb 14 10:57:37 2023 +0000

        Update HasImages.php (#853)

    * Release 0.2-rc2 (#873)

    * Update changelogs

    * Update CHANGELOG.md

    * Allow textarea component maxlength to be overridden (#880)

    * Allow textarea component maxlength to be overridden

    * Add changelog

    * Update Cart.php

    ---------

    Co-authored-by: Alec Ritson <hello@itsalec.co.uk>
    Co-authored-by: Ryan Mitchell <ryan@thoughtcollective.com>

commit b6a6a8c
Author: Alec Ritson <hello@itsalec.co.uk>
Date:   Fri Mar 24 11:22:15 2023 +0000

    Add `wire:ignore` to bulk actions list (#888)

commit 76471db
Author: wychoong <67364036+wychoong@users.noreply.github.com>
Date:   Fri Mar 24 19:21:51 2023 +0800

    clear cached properties on model refresh (#896)

    * Update Cart.php

    * Update CachesProperties.php

    * Update Cart.php

    ---------

    Co-authored-by: Glenn Jacobs <glenn@neondigital.co.uk>

commit d9ca112
Author: Alec Ritson <hello@itsalec.co.uk>
Date:   Fri Mar 24 11:13:50 2023 +0000

    Tweak discount logic (#894)

commit a599243
Author: Kyle Anderson <kylekanderson@gmail.com>
Date:   Fri Mar 24 07:09:59 2023 -0400

    calculate cartline unit price based on cart user, rather than Auth::user (#897)

    * Squashed commit of the following:

    commit 02c2671
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Fri Feb 10 11:13:49 2023 +0000

        Update lines.blade.php (#849)

    commit 0780a1c
    Author: wychoong <67364036+wychoong@users.noreply.github.com>
    Date:   Fri Feb 10 18:41:36 2023 +0800

        Update CollectionTree.php (#835)

        Co-authored-by: Alec Ritson <hello@itsalec.co.uk>

    commit e558799
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Fri Feb 10 09:47:16 2023 +0000

        :beer:

    commit 8fd4842
    Merge: df6f7f7 51af420
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Fri Feb 10 09:47:03 2023 +0000

        Merge branch '0.2' of github.com:lunarphp/lunar into 0.2

    commit df6f7f7
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Fri Feb 10 09:47:00 2023 +0000

        :beer:

    commit 51af420
    Author: wychoong <67364036+wychoong@users.noreply.github.com>
    Date:   Fri Feb 10 17:43:10 2023 +0800

        [0.2] Hotfix - fix pluck on null (#834)

        * fix pluck on null

        * Update AbstractDiscount.php

        ---------

        Co-authored-by: Alec Ritson <hello@itsalec.co.uk>

    commit 7b5ce85
    Author: wychoong <67364036+wychoong@users.noreply.github.com>
    Date:   Fri Feb 10 17:16:50 2023 +0800

        [0.2] Fix/discount by product (#841)

        * fix

        * add test

        * fix discount minSpend precision

        * fix discount condition logic

        * fix

        * fix coupon check

    commit 72f8454
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Fri Feb 10 09:16:16 2023 +0000

        Hotfix [0.2] - Wrap customer group in array (#846)

        * Wrap customer group in array

        * Update ProductVariantTest.php

    commit b8773d3
    Author: Ryan Mitchell <ryan@thoughtcollective.com>
    Date:   Wed Feb 8 20:43:09 2023 +0000

        When DB::table() is used make sure connection is passed (#826)

    commit 650d9db
    Merge: dcd39cc de20aff
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Wed Feb 1 09:57:04 2023 +0000

        Merge branch 'main' into 0.2

    commit dcd39cc
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Tue Jan 31 07:29:15 2023 +0000

        :beer:

    * Squashed commit of the following:

    commit 1a362cc
    Author: Ivanka Todorova <1038697+fakeheal@users.noreply.github.com>
    Date:   Tue Feb 14 13:25:25 2023 +0200

        Fix validation of attributes of type TranslatedText (#839)

        * fix: validation rules to be applied on elements in `TranslatedText`

        * fix: "reset" the validation rules applied to each sub-field in `TranslatedText`

        * chore: add tests for validating attribute fields (required/optional) and their additional rules

        ---------

        Co-authored-by: Alec Ritson <hello@itsalec.co.uk>

    commit 6c1ab08
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Tue Feb 14 10:58:15 2023 +0000

        [0.2] Hotfix - Fix collection name on creation (#852)

        * Squashed commit of the following:

        commit 02c2671
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Fri Feb 10 11:13:49 2023 +0000

            Update lines.blade.php (#849)

        commit 0780a1c
        Author: wychoong <67364036+wychoong@users.noreply.github.com>
        Date:   Fri Feb 10 18:41:36 2023 +0800

            Update CollectionTree.php (#835)

            Co-authored-by: Alec Ritson <hello@itsalec.co.uk>

        commit e558799
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Fri Feb 10 09:47:16 2023 +0000

            :beer:

        commit 8fd4842
        Merge: df6f7f7 51af420
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Fri Feb 10 09:47:03 2023 +0000

            Merge branch '0.2' of github.com:lunarphp/lunar into 0.2

        commit df6f7f7
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Fri Feb 10 09:47:00 2023 +0000

            :beer:

        commit 51af420
        Author: wychoong <67364036+wychoong@users.noreply.github.com>
        Date:   Fri Feb 10 17:43:10 2023 +0800

            [0.2] Hotfix - fix pluck on null (#834)

            * fix pluck on null

            * Update AbstractDiscount.php

            ---------

            Co-authored-by: Alec Ritson <hello@itsalec.co.uk>

        commit 7b5ce85
        Author: wychoong <67364036+wychoong@users.noreply.github.com>
        Date:   Fri Feb 10 17:16:50 2023 +0800

            [0.2] Fix/discount by product (#841)

            * fix

            * add test

            * fix discount minSpend precision

            * fix discount condition logic

            * fix

            * fix coupon check

        commit 72f8454
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Fri Feb 10 09:16:16 2023 +0000

            Hotfix [0.2] - Wrap customer group in array (#846)

            * Wrap customer group in array

            * Update ProductVariantTest.php

        commit b8773d3
        Author: Ryan Mitchell <ryan@thoughtcollective.com>
        Date:   Wed Feb 8 20:43:09 2023 +0000

            When DB::table() is used make sure connection is passed (#826)

        commit 650d9db
        Merge: dcd39cc de20aff
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Wed Feb 1 09:57:04 2023 +0000

            Merge branch 'main' into 0.2

        commit dcd39cc
        Author: Alec Ritson <hello@itsalec.co.uk>
        Date:   Tue Jan 31 07:29:15 2023 +0000

            :beer:

        * Check for attribute type when creating

    commit 0942397
    Author: Alec Ritson <hello@itsalec.co.uk>
    Date:   Tue Feb 14 10:57:37 2023 +0000

        Update HasImages.php (#853)

    * Release 0.2-rc2 (#873)

    * Update changelogs

    * Update CHANGELOG.md

    * Allow textarea component maxlength to be overridden (#880)

    * Allow textarea component maxlength to be overridden

    * Add changelog

    * calculate cartline unit price based on cart user, rather than Auth::user

    ---------

    Co-authored-by: Alec Ritson <hello@itsalec.co.uk>
    Co-authored-by: Ryan Mitchell <ryan@thoughtcollective.com>
    Co-authored-by: Kyle Anderson <kyle@creative2.com>

commit 680f317
Author: Ryan Mitchell <ryan@thoughtcollective.com>
Date:   Fri Mar 10 13:40:38 2023 +0000

    Discount breakdown (#884)

    * Add concept of DiscountBreakdown to cart

    * Should have been $rewardLine

    * Bug fix

    * Use a DTO for affected discount lines

    * Line not lines

    * Fix bug

    * Simplify DTOs

    * Apply to `AmountOff` discounts

    * Add discount breakdown to orders

    * 🍺

    * Bug fix

    * Fix up casting... if its not a collection then we dont need to do anything

    * Make discount_breakdown nullable

    * Create method in abstract class for adding breakdowns

    * Tests

    * Place column before discount_total

    * Remove un-used code

    * Use toJson()

    * Avoid duplication in CreateOrder

    * Formatting

    * Add test to ensure discount_breakdown is added to orders

    * Add docs

    * Add changelog

    ---------

    Co-authored-by: Alec Ritson <hello@itsalec.co.uk>

commit e799ab1
Author: Ryan Mitchell <ryan@thoughtcollective.com>
Date:   Fri Mar 10 09:39:06 2023 +0000

    Fix tax breakdown on save (#887)

    * Tax breakdown fix - if total is a price then save its value

    * Implement `SerializesCastableAttributes`

    * Add full param list

    * Update test coverage

    * Use toJson()

    ---------

    Co-authored-by: Alec Ritson <hello@itsalec.co.uk>

commit 86a509c
Author: Ryan Mitchell <ryan@thoughtcollective.com>
Date:   Thu Mar 9 15:06:15 2023 +0000

    Add shipping tax correctly (#889)

commit be5c400
Author: Glenn Jacobs <glenn@neondigital.co.uk>
Date:   Thu Feb 23 10:36:54 2023 +0000

    Adding Validations menu item which was missing
  • Loading branch information
alecritson committed Mar 29, 2023
1 parent dc03f94 commit 534d922
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 6 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Added the ability to specify the maximum length of textarea fields in the admin hub

## 0.2.1

### Fixed

- The `CalculateTax` pipeline should now correctly set the tax breakdown across the cart and lines.

## 0.2-RC3

### Fixed
Expand Down
14 changes: 10 additions & 4 deletions packages/core/src/Pipelines/Cart/CalculateTax.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CalculateTax
*/
public function handle(Cart $cart, Closure $next)
{
$taxBreakDown = new TaxBreakdown;
$taxBreakDownAmounts = collect();

foreach ($cart->lines as $cartLine) {
$subTotal = $cartLine->subTotal?->value;
Expand All @@ -28,22 +28,28 @@ public function handle(Cart $cart, Closure $next)
$subTotal = $cartLine->subTotalDiscounted?->value;
}

$taxBreakDown = Taxes::setShippingAddress($cart->shippingAddress)
$taxBreakDownResult = Taxes::setShippingAddress($cart->shippingAddress)
->setBillingAddress($cart->billingAddress)
->setCurrency($cart->currency)
->setPurchasable($cartLine->purchasable)
->setCartLine($cartLine)
->getBreakdown($subTotal);

$taxTotal = $taxBreakDown->amounts->sum('price.value');
$taxBreakDownAmounts = $taxBreakDownAmounts->merge(
$taxBreakDownResult->amounts
);

$cartLine->taxBreakdown = $taxBreakDown;
$taxTotal = $taxBreakDownResult->amounts->sum('price.value');

$cartLine->taxBreakdown = $taxBreakDownResult;

$cart->taxTotal = new Price($taxTotal, $cart->currency, 1);
$cartLine->taxAmount = new Price($taxTotal, $cart->currency, $unitQuantity);
$cartLine->total = new Price($subTotal + $taxTotal, $cart->currency, $unitQuantity);
}

$taxBreakDown = new TaxBreakdown($taxBreakDownAmounts);

$taxTotal = $cart->lines->sum('taxAmount.value');
$taxBreakDownAmounts = $taxBreakDown->amounts->filter()->flatten();

Expand Down

0 comments on commit 534d922

Please sign in to comment.