Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show VAT as included on invoices (#681)
* Added explicit cast to avoid type mismatch error * Show correct ticket price on invoices #661 This commit fixed the issue with invoices with discounts. The invoice now shows the original ticket price instead of the already discounted price to be consistent with the reservation summary and receipts. * Show VAT as included on invoices #661 Invoices show VAT (in case VAT should be shown), but when the amount already includes it, the invoices don’t mention it. This commit makes invoices differentiate between included and not included VAT when displaying it. * Show VAT as included on invoices #661 Invoices show VAT (in case VAT should be shown), but when the amount already includes it, the invoices don’t mention it. This commit makes invoices differentiate between included and not included VAT when displaying it. * Fixed summary price calculation * Added license to SummaryPriceContainerTest
- Loading branch information
Showing
4 changed files
with
240 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** | ||
* This file is part of alf.io. | ||
* | ||
* alf.io is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* alf.io is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with alf.io. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package alfio.model; | ||
|
||
import static org.hamcrest.CoreMatchers.equalTo; | ||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
import java.math.BigDecimal; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.IntStream; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import alfio.model.decorator.TicketPriceContainer; | ||
|
||
public class SummaryPriceContainerTest { | ||
|
||
@Test | ||
public void testSummaryPriceBeforeVatIncluded() { | ||
List<TicketPriceContainer> items = IntStream.range(0, 10) | ||
.mapToObj(i -> vatIncludedPriceContainer()).collect(Collectors.toList()); | ||
|
||
int summaryPrice = SummaryPriceContainer.getSummaryPriceBeforeVatCts(items); | ||
|
||
assertThat(summaryPrice, is(equalTo(8264))); | ||
} | ||
|
||
@Test | ||
public void testSummaryPriceBeforeVatExcluded() { | ||
List<TicketPriceContainer> items = IntStream.range(0, 10) | ||
.mapToObj(i -> vatExcludedPriceContainer()).collect(Collectors.toList()); | ||
|
||
int summaryPrice = SummaryPriceContainer.getSummaryPriceBeforeVatCts(items); | ||
|
||
assertThat(summaryPrice, is(equalTo(10000))); | ||
} | ||
|
||
private TicketPriceContainer vatIncludedPriceContainer() { | ||
var ticket = createPriceContainer(); | ||
when(ticket.getVatStatus()).thenReturn(PriceContainer.VatStatus.INCLUDED); | ||
|
||
return ticket; | ||
} | ||
|
||
private TicketPriceContainer vatExcludedPriceContainer() { | ||
var ticket = createPriceContainer(); | ||
when(ticket.getVatStatus()).thenReturn(PriceContainer.VatStatus.NOT_INCLUDED); | ||
|
||
return ticket; | ||
} | ||
|
||
private TicketPriceContainer createPriceContainer() { | ||
var ticket = mock(TicketPriceContainer.class); | ||
when(ticket.getCurrencyCode()).thenReturn("EUR"); | ||
when(ticket.getSrcPriceCts()).thenReturn(1000); | ||
when(ticket.getVatPercentageOrZero()).thenReturn(new BigDecimal("21.00")); | ||
|
||
return ticket; | ||
} | ||
} |