Skip to content
Snippets Groups Projects
Select Git revision
  • 9df0b910225776132fa2e2fcade8c6f3d7879891
  • master default
  • renovate/junit-jupiter-engine.version
  • renovate/selenium.version
  • renovate/testcontainer.version
  • demo
  • v1_8_1
  • v2.18.1
  • v2.18.0
  • v2.17.2
  • v2.17.1
  • v2.17.0
  • v2.16.1
  • v2.16.0
  • v2.15.1
  • v2.15.0
  • v2.14.0
  • v2.13.0
  • v2.12.0
  • v2.11.0
  • v2.10.0
  • v2.9.2
  • v2.9.1
  • v2.9.0
  • v2.8.0
  • testPipeline2
  • v2.7.0
27 results

TransactionRepository.java

Blame
  • TransactionRepository.java 1.80 KiB
    package de.deadlocker8.budgetmaster.transactions;
    
    import de.deadlocker8.budgetmaster.categories.Category;
    import de.deadlocker8.budgetmaster.tags.Tag;
    import de.deadlocker8.budgetmaster.accounts.Account;
    import org.joda.time.DateTime;
    import org.springframework.data.jpa.repository.JpaRepository;
    import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
    import org.springframework.data.jpa.repository.Query;
    
    import java.util.List;
    
    
    @SuppressWarnings("SqlResolve")
    public interface TransactionRepository extends JpaRepository<Transaction, Integer>, JpaSpecificationExecutor<Transaction>
    {
    	List<Transaction> findAllByAccountAndDateBetweenOrderByDateDesc(Account account, DateTime startDate, DateTime endDate);
    
    	List<Transaction> findAllByDateBetweenOrderByDateDesc(DateTime startDate, DateTime endDate);
    
    	List<Transaction> findAllByAccount(Account account);
    
    	Long countByCategory(Category category);
    
    	List<Transaction> findAllByTagsContaining(Tag tag);
    
    	@Query(value = "SELECT SUM(t.amount) FROM `transaction` as t WHERE t.account_id = ?1 AND t.transfer_account_id IS NULL AND t.date BETWEEN ?2 AND ?3", nativeQuery = true)
    	Integer getRestForNormalAndRepeating(int accountID, String startDate, String endDate);
    
    	@Query(value = "SELECT SUM(t.amount) FROM `transaction` as t WHERE t.account_id = ?1 AND t.transfer_account_id IS NOT NULL AND t.date BETWEEN ?2 AND ?3", nativeQuery = true)
    	Integer getRestForTransferSource(int accountID, String startDate, String endDate);
    
    	@Query(value = "SELECT SUM(t.amount) FROM `transaction` as t WHERE t.transfer_account_id = ?1 AND t.date BETWEEN ?2 AND ?3", nativeQuery = true)
    	Integer getRestForTransferDestination(int accountID, String startDate, String endDate);
    
    	List<Transaction> findAllByTransferAccount(Account account);
    
    	List<Transaction> findAllByOrderByDateDesc();
    }