# Account Transaction Details - Order By

**URL:** <https://forum.sambapos.com/t/account-transaction-details-order-by/26032>\
**Category:** V5 Question\
**Created:** [August 2, 2022, 8:34am UTC](https://forum.sambapos.com/t/account-transaction-details-order-by/26032 "2022-08-02T08:34:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Posflow](https://forum.sambapos.com/user_avatar/forum.sambapos.com/posflow/32/63001_2.png) [@Posflow](https://forum.sambapos.com/u/Posflow)\
**Post date:** [August 2, 2022, 8:34am UTC](https://forum.sambapos.com/t/account-transaction-details-order-by/26032/1 "2022-08-02T08:34:40Z")

</div>

Is there a way I can order account transaction details by date in an ascending or descending order? Its a bit of a mess to read it at the moment

![image](https://forum.sambapos.com/uploads/default/original/3X/9/8/987eaa53bba7ee478b3026428199895db083f3d4.png)

---

<div class="post-metadata">

**Author:** ![Nizam](https://forum.sambapos.com/user_avatar/forum.sambapos.com/nizam/32/53194_2.png) [@Nizam](https://forum.sambapos.com/u/Nizam)\
**Post date:** [August 2, 2022, 9:24am UTC](https://forum.sambapos.com/t/account-transaction-details-order-by/26032/2 "2022-08-02T09:24:23Z")

</div>

Hello @Posflow,

You can use below report code group and adjust it according to your needs;

```auto
[Customer Account Payment Details:2,2,4,2,2]
>Cash Transactions
{REPORT ACCOUNT TRANSACTION DETAILS:T.Date.asc,T.Time,T.TransactionName,T.Amount:(ATT=Customer Cash Payment)}
>Total|||{REPORT ACCOUNT TRANSACTION DETAILS:T.Amount.Sum:(ATT=Customer Cash Payment)}

>Credit Transactions
{REPORT ACCOUNT TRANSACTION DETAILS:T.Date.asc,T.Time,T.TransactionName,T.Amount:(ATT=Customer Credit Card Payment)}
>Total|||{REPORT ACCOUNT TRANSACTION DETAILS:T.Amount.Sum:(ATT=Customer Credit Card Payment)}

```

---

<div class="post-metadata">

**Author:** ![Posflow](https://forum.sambapos.com/user_avatar/forum.sambapos.com/posflow/32/63001_2.png) [@Posflow](https://forum.sambapos.com/u/Posflow)\
**Post date:** [August 5, 2022, 9:29am UTC](https://forum.sambapos.com/t/account-transaction-details-order-by/26032/3 "2022-08-05T09:29:53Z")

</div>

Hey @Nizam I couldnt find this on knowledge base, can you please update it? Also, what expressions can I use here?

Is there a target account expression like (T.Target=“xyz”)?

---

<div class="post-metadata">

**Author:** ![Nizam](https://forum.sambapos.com/user_avatar/forum.sambapos.com/nizam/32/53194_2.png) [@Nizam](https://forum.sambapos.com/u/Nizam)\
**Post date:** [August 5, 2022, 9:40am UTC](https://forum.sambapos.com/t/account-transaction-details-order-by/26032/4 "2022-08-05T09:40:32Z")

</div>

Hello @Posflow,

That is a custom report design therefore it’s not published on the knowledge base.

You can check the below image to see what expressions you can use for this usage.(including Target Account as well)

 ![T.Target-01](https://forum.sambapos.com/uploads/default/original/3X/f/2/f238b1a7c33ddd998cce1c384332b3c3a2657710.jpeg)

---

<div class="post-metadata">

**Author:** ![Posflow](https://forum.sambapos.com/user_avatar/forum.sambapos.com/posflow/32/63001_2.png) [@Posflow](https://forum.sambapos.com/u/Posflow)\
**Post date:** [August 5, 2022, 9:46am UTC](https://forum.sambapos.com/t/account-transaction-details-order-by/26032/5 "2022-08-05T09:46:15Z")

</div>

Hi @Nizam, I think we are misunderstanding each other, I am asking if you can update knowledge base so that the syntax for this is available in docs because  
`{REPORT ACCOUNT TRANSACTION DETAILS:}` syntax is not available in Reports section of SambaPOS Knowledge base docs.

![image](https://forum.sambapos.com/uploads/default/original/3X/8/a/8a5ce751540e081bb0e34e8fb84ad147e79f261e.png)  
I want to constrain `(ATT=Cash Expense) AND (T.Target=Staff Food)` is there an expression for Target account or source account?

---

<div class="post-metadata">

**Author:** ![Nizam](https://forum.sambapos.com/user_avatar/forum.sambapos.com/nizam/32/53194_2.png) [@Nizam](https://forum.sambapos.com/u/Nizam)\
**Post date:** [August 5, 2022, 9:55am UTC](https://forum.sambapos.com/t/account-transaction-details-order-by/26032/6 "2022-08-05T09:55:36Z")

</div>

Hello @Posflow,

Indeed there is a document that includes mentioned report tag;

[https://kb.sambapos.com/en/9-1-5-creating-accounting-reports-with-custom-reporting-tags/](https://kb.sambapos.com/en/9-1-5-creating-accounting-reports-with-custom-reporting-tags/)

---

<div class="post-metadata">

**Author:** ![Posflow](https://forum.sambapos.com/user_avatar/forum.sambapos.com/posflow/32/63001_2.png) [@Posflow](https://forum.sambapos.com/u/Posflow)\
**Post date:** [August 5, 2022, 9:57am UTC](https://forum.sambapos.com/t/account-transaction-details-order-by/26032/7 "2022-08-05T09:57:28Z")

</div>

Ive seen this one, I mean {REPORT ACCOUNT TRANSACTION DETAILS:} specifically, this one is not mentioned anywhere (at least not in easily found topis on the forum), there is no information about what other expression it has available other than (ATT=)

---

<div class="post-metadata">

**Author:** ![Posflow](https://forum.sambapos.com/user_avatar/forum.sambapos.com/posflow/32/63001_2.png) [@Posflow](https://forum.sambapos.com/u/Posflow)\
**Post date:** [August 8, 2022, 10:38am UTC](https://forum.sambapos.com/t/account-transaction-details-order-by/26032/8 "2022-08-08T10:38:23Z")

</div>

Hey @Nizam, I created this script that works the same but I have the control over date/time format and target account

In its essence its mimicking this

```auto
{ACCOUNT TRANSACTION DETAILS:Expense Cash Payment:Staff Food}
{ACCOUNT TRANSACTION DETAILS:Expense Bank Payment:Staff Food}}
{ACCOUNT TRANSACTION DETAILS:Cash Expense by Owner Transaction:Staff Food}}

```

Works the same way, you just pass down the parameters to the script.

```auto
DECLARE @Start DATETIME = CONVERT(VARCHAR(25), '{Start}', 126);
DECLARE @End DATETIME = CONVERT(VARCHAR(25), '{End}', 126);

DECLARE @ATT1 NVARCHAR(50)= '@1';
DECLARE @ATT2 NVARCHAR(50)= '@2';
DECLARE @ATT3 NVARCHAR(50)= '@3';
DECLARE @A1 NVARCHAR(50)= '@4';

SELECT   
		
	FORMAT(atv.Date,'MMM-dd HH:mm') as Date,
	atv.Name,
    atv.Debit AS Amount

  FROM AccountTransactionValues atv

  INNER JOIN AccountTransactionDocuments atd ON atv.AccountTransactionDocumentId = atd.Id
  INNER JOIN AccountTransactionDocumentTypes atdt ON atd.DocumentTypeId = atdt.Id
  INNER JOIN AccountTransactionDocumentTypeAccountTransactionTypes att ON atd.DocumentTypeId = att.AccountTransactionDocumentType_Id
  INNER JOIN AccountTransactionTypes attt ON attt.Id = att.AccountTransactionType_Id
  INNER JOIN Accounts a ON a.Id=atv.AccountId

  WHERE 
  atv.Date >= @Start
  AND
  atv.Date <= @End
  AND
  ( attt.Name = @ATT1 OR attt.Name= @ATT2 OR attt.Name = @ATT3 )
  AND
  a.Name=@A1
  AND
  atv.Debit > 0

  ORDER BY FORMAT(atv.Date,'MMM-dd HH:mm') ASC

```

In the reports you pass the parameters of your Account Transaction Type names the same way, and last one is the account name

Additionally you can put all 3 initial parameters the same name if you dont have 3 unique transaction types, it wont mess up the report.

```auto
[STAFF FOOD-EXPENSE:1,2, 1]
@@opexpenses:Expense Cash Payment,Expense Bank Payment,Cash Expense by Owner Transaction,Staff Food

>Total||[=F((TN('{ACCOUNT TOTAL:Staff Food}')),'#,#0.00')]

```

![image](https://forum.sambapos.com/uploads/default/original/3X/b/9/b90c37706ee4a62fdbd6e9b59e0ac5615d3e1a0d.png)
