Serenity: can help me to get summary line total

Created on 6 Aug 2016  路  8Comments  路  Source: serenity-is/Serenity

hi. can help me to get summary total to this Gross Amt ?
qu1

Most helpful comment

What about this way? Using the same idea from Full Name sample in Movie?

Let's using the same Order in Serene.

Step 1:

  • Open OrderRow.cs
  • After MasterDetail DetailList insert these lines

[DisplayName("Total"), Expression("(select SUM( (ISNULL(Quantity, 0) * ISNULL(UnitPrice,0) - ISNULL(Discount,0))) from [Order Details] AS T1 WHERE T0.ORDERID = T1.ORDERID)")] public Decimal? Total { get { return Fields.Total[this]; } set { Fields.Total[this] = value; } }

Step 2:
In RowFields, locate DetailList property and insert _public DecimalField Total_;

Step 3:

  • Open OrderForm.cs
  • locate DetailList property and _public Decimal Total { get; set; };_

see image below
order total

All 8 comments

There is an example in the Serene demo.
http://serenedemo.azurewebsites.net/BasicSamples/GroupingAndSummariesInGrid
There are links on the page to the source files used; Index.cshtml and GroupingAndSummariesInGrid.ts

What about this way? Using the same idea from Full Name sample in Movie?

Let's using the same Order in Serene.

Step 1:

  • Open OrderRow.cs
  • After MasterDetail DetailList insert these lines

[DisplayName("Total"), Expression("(select SUM( (ISNULL(Quantity, 0) * ISNULL(UnitPrice,0) - ISNULL(Discount,0))) from [Order Details] AS T1 WHERE T0.ORDERID = T1.ORDERID)")] public Decimal? Total { get { return Fields.Total[this]; } set { Fields.Total[this] = value; } }

Step 2:
In RowFields, locate DetailList property and insert _public DecimalField Total_;

Step 3:

  • Open OrderForm.cs
  • locate DetailList property and _public Decimal Total { get; set; };_

see image below
order total

ps.: another way is SetFieldFlags(FieldFlags.ClientSide) and sum total in Type Script, but I don't know how to get listDetail in TypeScript.

Hey @Takecarecom. Is my example fits what you looking for?

Hi @volkanceylan & @rolembergfilho

Do you have a better solution regarding this issue?
One where you do not have to save the master dialog before getting the sum-amount into the field?

I have the exact same field, a sum of rows in detail dialog which I want to be calculated and shown immediately in the master dialog after the detail dialog has been closed.

Is it possible to call a SaveAction which triggers when you close the detail dialog??

Thanks

@rolembergfilho

Your solution works like a charm.

But it returns a zero(empty total field) if you combine several select statement.

I have three tables
Loans
Loans-LoanPayments
Loan-LoanStatuses

table-LoanPayments has a column "AmountPaid"
table-LoanStatuses has a column "StatusFee"

When I run the expression

`
Expression("(T0.TotalLoanAmount) + (select SUM( (ISNULL(LoanStatusFee, 0))) from
[LoanStatuses] AS T1 WHERE T0.LoanId = T1.LoanId) - (select SUM( (ISNULL(AmountPaid, 0))) from [LoanPayments] AS T1 WHERE T0.LoanId = T1.LoanId)")

`
TotalLoanAmount = 1000
Sum(LoanStatusFee) = 0
Sum(AmountPaid) = 100

I get a null value instead of 900.

I solved it with

Expression("(T0.TotalLoanAmount) + (SELECT COALESCE(SUM(LoanStatusFee), 0) from [LoanStatuses] AS T1 WHERE T0.LoanId = T1.LoanId) - (SELECT COALESCE(SUM(AmountPaid), 0) from [LoanPayments] AS T1 WHERE T0.LoanId = T1.LoanId)")

What about this way? Using the same idea from Full Name sample in Movie?

Let's using the same Order in Serene.

Step 1:

  • Open OrderRow.cs
  • After MasterDetail DetailList insert these lines
    [DisplayName("Total"), Expression("(select SUM( (ISNULL(Quantity, 0) * ISNULL(UnitPrice,0) - ISNULL(Discount,0))) from [Order Details] AS T1 WHERE T0.ORDERID = T1.ORDERID)")] public Decimal? Total { get { return Fields.Total[this]; } set { Fields.Total[this] = value; } }

Step 2:
In RowFields, locate DetailList property and insert _public DecimalField Total_;

Step 3:

  • Open OrderForm.cs
  • locate DetailList property and _public Decimal Total { get; set; };_

see image below
order total

thank you for it. but, it doesn't add to database. just shown on column and on update form. what would i do then?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ahsansolution picture ahsansolution  路  3Comments

StefanTheiner picture StefanTheiner  路  3Comments

dudeman972 picture dudeman972  路  3Comments

kilroyFR picture kilroyFR  路  3Comments

Pinellus picture Pinellus  路  3Comments