[WebApi]修改水電報表小Bug & 修改匯出pdf總價計算方式並加上計算公式
This commit is contained in:
		
							parent
							
								
									1bfea12fcc
								
							
						
					
					
						commit
						050db7dda5
					
				@ -401,7 +401,7 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                List<TenantBill> tenantBill = new List<TenantBill>();
 | 
					                List<TenantBill> tenantBill = new List<TenantBill>();
 | 
				
			||||||
                try
 | 
					                try
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    string sqlString = $@"select * from {TenantBilltable} WHERE tenant_guid= '{tb.tenant_guid}' and a.deleted = 0";
 | 
					                    string sqlString = $@"select * from {TenantBilltable} WHERE tenant_guid= '{tb.tenant_guid}' and deleted = 0";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    tenantBill = await backendRepository.GetAllAsync<TenantBill>(sqlString);
 | 
					                    tenantBill = await backendRepository.GetAllAsync<TenantBill>(sqlString);
 | 
				
			||||||
                    if (tenantBill.Count > 1)
 | 
					                    if (tenantBill.Count > 1)
 | 
				
			||||||
@ -445,7 +445,7 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            try
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                string sqlString = $@"select * from {TenantBilltable} WHERE tenant_guid= '{tb.tenant_guid}' and a.deleted = 0";
 | 
					                string sqlString = $@"select * from {TenantBilltable} WHERE tenant_guid= '{tb.tenant_guid}' and deleted = 0";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                tenantBill = await backendRepository.GetAllAsync<TenantBill>(sqlString);
 | 
					                tenantBill = await backendRepository.GetAllAsync<TenantBill>(sqlString);
 | 
				
			||||||
                foreach (TenantBill t in tenantBill)
 | 
					                foreach (TenantBill t in tenantBill)
 | 
				
			||||||
@ -507,21 +507,31 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                {
 | 
					                {
 | 
				
			||||||
                    string sqlString =
 | 
					                    string sqlString =
 | 
				
			||||||
                        $@"SELECT 
 | 
					                        $@"SELECT 
 | 
				
			||||||
 | 
					                                tenant_name,
 | 
				
			||||||
 | 
					                                start_timestamp,
 | 
				
			||||||
 | 
					                                end_timestamp,
 | 
				
			||||||
 | 
					                                bill_perKWH,
 | 
				
			||||||
 | 
					                                bill_perRCV,
 | 
				
			||||||
 | 
					                                elec_result,
 | 
				
			||||||
 | 
					                                water_result,
 | 
				
			||||||
 | 
					                                bill_perKWH * elec_result AS elec_bill,
 | 
				
			||||||
 | 
					                                bill_perRCV * water_result AS water_bill,
 | 
				
			||||||
 | 
					                                ROUND(bill_perKWH * elec_result + bill_perRCV * water_result) AS total_bill
 | 
				
			||||||
 | 
					                            FROM (
 | 
				
			||||||
 | 
					                                SELECT 
 | 
				
			||||||
                                    a.tenant_name,
 | 
					                                    a.tenant_name,
 | 
				
			||||||
                                    MIN(NULLIF(a.start_timestamp, '')) AS start_timestamp,
 | 
					                                    MIN(NULLIF(a.start_timestamp, '')) AS start_timestamp,
 | 
				
			||||||
                                    MAX(NULLIF(a.end_timestamp, '')) AS end_timestamp,
 | 
					                                    MAX(NULLIF(a.end_timestamp, '')) AS end_timestamp,
 | 
				
			||||||
                                    bill_perKWH,
 | 
					                                    bill_perKWH,
 | 
				
			||||||
                                    bill_perRCV,
 | 
					                                    bill_perRCV,
 | 
				
			||||||
                                    SUM(CASE WHEN a.device_name_tag = 'E4' THEN result ELSE 0 END) AS elec_result,
 | 
					                                    SUM(CASE WHEN a.device_name_tag = 'E4' THEN result ELSE 0 END) AS elec_result,
 | 
				
			||||||
                           SUM(CASE WHEN a.device_name_tag = 'W1' THEN result ELSE 0 END) AS water_result,
 | 
					                                    SUM(CASE WHEN a.device_name_tag = 'W1' THEN result ELSE 0 END) AS water_result
 | 
				
			||||||
                           SUM(CASE WHEN a.device_name_tag = 'E4' THEN bill ELSE 0 END) AS elec_bill,
 | 
					 | 
				
			||||||
                           SUM(CASE WHEN a.device_name_tag = 'W1' THEN bill ELSE 0 END) AS water_bill,
 | 
					 | 
				
			||||||
                           SUM(bill) AS total_bill
 | 
					 | 
				
			||||||
                                FROM archive_electric_meter_tenant_bill a
 | 
					                                FROM archive_electric_meter_tenant_bill a
 | 
				
			||||||
                                JOIN archive_electric_meter_tenant_list b ON a.tenant_guid = b.tenant_guid 
 | 
					                                JOIN archive_electric_meter_tenant_list b ON a.tenant_guid = b.tenant_guid 
 | 
				
			||||||
					   join device c on a.device_number = c.device_number 
 | 
					                                JOIN device c ON a.device_number = c.device_number 
 | 
				
			||||||
					   where {building_tag} 
 | 
					                                WHERE {building_tag} 
 | 
				
			||||||
                       GROUP BY a.tenant_name;";
 | 
					                                GROUP BY a.tenant_name
 | 
				
			||||||
 | 
					                            ) subquery_alias";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    outputBill = await backendRepository.GetAllAsync<OutputBill>(sqlString);
 | 
					                    outputBill = await backendRepository.GetAllAsync<OutputBill>(sqlString);
 | 
				
			||||||
                    string filePath = CreateOutputForm(outputBill);
 | 
					                    string filePath = CreateOutputForm(outputBill);
 | 
				
			||||||
@ -660,6 +670,7 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                        $"                    <td><strong>水費總計: </strong>{item.water_bill}元</td> " +
 | 
					                        $"                    <td><strong>水費總計: </strong>{item.water_bill}元</td> " +
 | 
				
			||||||
                        $"                </tr> " +
 | 
					                        $"                </tr> " +
 | 
				
			||||||
                        $"            </table> " +
 | 
					                        $"            </table> " +
 | 
				
			||||||
 | 
					                        $"            <p style=\"font-size: larger; color: red; text-align: right; margin: 0; padding: 0;\"><strong>總計(費用):各電/水量加總 * 單價</p> " +
 | 
				
			||||||
                        $"        </div> " +
 | 
					                        $"        </div> " +
 | 
				
			||||||
                        $"        <div class=\"total\"> " +
 | 
					                        $"        <div class=\"total\"> " +
 | 
				
			||||||
                        $"            <div class=\"total-area\"> " +
 | 
					                        $"            <div class=\"total-area\"> " +
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user