• hogehoge
• NEWBIE
• 10 Points
• Member since 2022

• Chatter
Feed
• 0
• 1
• 0
Likes Given
• 11
Questions
• 7
Replies
the graph　Help me
I want to check the transition of last year's data and this year's data on
For example, 1st week of April 2022 and 1st week of April 2023, 2nd week of April 2022 and 2nd week of April 2023, etc.
Is it possible to create two line graphs? Also, is it possible to set the date order regardless of the beginning year?
I want 2022-04-4 and 2021-04-03 to have the same x-axis position
The date type has a form like yyyy-mm-dd, but how can I create an item with only mm-dd information?
Check what week of the year a date is To find out what week of the year a date is in, use the formula: What formula can you have if you want a year to start on April 1st and end on March 31st?
```IF(
CEILING( ( date - DATE( YEAR( date ), 1, 1) + 1) / 7) > 52,
52,
CEILING( ( date - DATE( YEAR( date ), 1, 1) + 1) / 7)
)```
```F(DAY( CloseDate ) / 7 <= 1 , 1 ,
IF(DAY( CloseDate ) / 7 <= 2 , 2 ,
IF(DAY( CloseDate ) / 7 <= 3 , 3 ,
IF(DAY( CloseDate ) / 7 <= 4 , 4 ,
IF(DAY( CloseDate ) / 7 <= 5 , 5 , 0) ))))```
It seems that you are counting the weeks of the month.

I got the following error in process builder:

Invalid formula: syntax error. missing '='
how can i fix it
```CASE(1,

IF(AND(DAY([Opportunity].CloseDate)>= 1,DAY([Opportunity]].CloseDate)<= 7),1,2),”1Weeks”,

IF(AND(DAY([Opportunity]].CloseDate)>= 8,DAY([Opportunity]].CloseDate)<= 14),1,2),”2Weeks”,

IF(AND(DAY([Opportunity]].CloseDate)>= 15,DAY([Opportunity]].CloseDate)<= 21),1,2),”3Weeks”,

IF(AND(DAY([Opportunity]].CloseDate)>= 22,DAY([Opportunity]].CloseDate)<= 28),1,2),”4Weeks”,

“5Weeks”

)```

```global without sharing class ResultFulfillingAggregateScheduler implements Schedulable{

/**
*  *** AcceptanceExpectedDate is divided into 1st half and 2nd half (1st half: April to September, 2nd half: October to next March)
*  *** Split timing is based on execution date
*/
public void execute( SchedulableContext sc ){
// Get record type
String conditonRecordTypeA = 'OrderEstimated';
String conditonRecordTypeB = 'OrderRegistration';
Map<String,Schema.RecordTypeInfo> recordTypeMap = new Map<String,Schema.RecordTypeInfo>();
for( Schema.RecordTypeInfo info : Result__c.SObjectType.getDescribe().getRecordTypeInfos() ){
if( info.getDeveloperName() == conditonRecordTypeA || info.getDeveloperName() == conditonRecordTypeB ){
recordTypeMap.put( info.getDeveloperName() , info );
}
}
/**

*/
// Set String value
List<String> conditionOrderProbabilityRank = new List<String>{ 'A' , 'B' , 'C' };
// Set conditions for first half and second half
Date day = Date.today();
Date startDate = Date.newInstance( day.year() - ( day.month() < 4 ? 1 : 0 ) , ( day.month() >= 4 || day.month() <= 9 ) ? 4 : 10 , 1 );
// execute SOQL
List<Result__c> resultList = [
SELECT OrderProbabilityRank__c , RecordTypeId , DXSolutionDeptFlg__c , PlatformSolutionDeptFlg__c , DSPSSolutionDeptFlg__c , ManagedServiceDeptFlg__c , EastJapanSolutionDeptFlg__c , ChubuSolutionDeptFlg__c , WestJapanSolutionDeptFlg__c ,  LimitProfit__c , LimitIncomePartTarget__c
FROM Result__c
WHERE ( DXSolutionDeptFlg__c = TRUE OR PlatformSolutionDeptFlg__c = TRUE OR DSPSSolutionDeptFlg__c = TRUE OR ManagedServiceDeptFlg__c = TRUE OR EastJapanSolutionDeptFlg__c = TRUE OR ChubuSolutionDeptFlg__c = TRUE OR WestJapanSolutionDeptFlg__c = TRUE )
AND ( FulfillingAggregateFlg__c = FALSE )
AND ( AcceptanceExpectedDate__c >= :startDate AND AcceptanceExpectedDate__c <= :endDate )
AND ( ( RecordType.DeveloperName = :conditonRecordTypeA AND OrderProbabilityRank__c IN :conditionOrderProbabilityRank ) OR RecordType.DeveloperName = :conditonRecordTypeB )
];
// Save records to aggregate
Map<String,Result__c> resultMap = new Map<String,Result__c>();
resultMap.put( '01' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'A' , FulfillingAggregateFlg__c = true , SE3__c = 'AAA' , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'A' && result.DXSolutionDeptFlg__c ){
resultMap.get( '01' ).LimitIncomeAchievementSum__c += result.LimitProfit__c;
resultMap.get( '01' ).LimitIncomeTargetSum__c += result.LimitIncomePartTarget__c;
}

}
// insert record
insert resultMap.values();
}

}```

I want to set "AAA" to the se3__c item in the created record, but it is not reflected.
(1) Order rank = 'A' and DX flag = true amount
⑵Order rank = 'A' and DC flag = true amount
(3) Amount of order rank = 'A' and FV flag = true

I want to write the total amount of the three in a formula, how should I write it?
```global without sharing class ResultFulfillingAggregateScheduler implements Schedulable{

/**
*  *** AcceptanceExpectedDate is divided into 1st half and 2nd half (1st half: April to September, 2nd half: October to next March)
*  *** Split timing is based on execution date
*/
public void execute( SchedulableContext sc ){
// Get record type
String conditonRecordTypeA = 'OrderEstimated';
String conditonRecordTypeB = 'OrderRegistration';
Map<String,Schema.RecordTypeInfo> recordTypeMap = new Map<String,Schema.RecordTypeInfo>();
for( Schema.RecordTypeInfo info : Result__c.SObjectType.getDescribe().getRecordTypeInfos() ){
if( info.getDeveloperName() == conditonRecordTypeA || info.getDeveloperName() == conditonRecordTypeB ){
recordTypeMap.put( info.getDeveloperName() , info );
}
}
/**

*/
// Set String value
List<String> conditionOrderProbabilityRank = new List<String>{ 'A' , 'B' , 'C' };
// Set conditions for first half and second half
Date day = Date.today();
Date startDate = Date.newInstance( day.year() - ( day.month() < 4 ? 1 : 0 ) , ( day.month() >= 4 || day.month() <= 9 ) ? 4 : 10 , 1 );
// execute SOQL
List<Result__c> resultList = [
SELECT OrderProbabilityRank__c , RecordTypeId , DXSolutionDeptFlg__c , PlatformSolutionDeptFlg__c , DSPSSolutionDeptFlg__c , ManagedServiceDeptFlg__c , EastJapanSolutionDeptFlg__c , ChubuSolutionDeptFlg__c , WestJapanSolutionDeptFlg__c ,  LimitProfit__c , LimitIncomePartTarget__c
FROM Result__c
WHERE ( DXSolutionDeptFlg__c = TRUE OR PlatformSolutionDeptFlg__c = TRUE OR DSPSSolutionDeptFlg__c = TRUE OR ManagedServiceDeptFlg__c = TRUE OR EastJapanSolutionDeptFlg__c = TRUE OR ChubuSolutionDeptFlg__c = TRUE OR WestJapanSolutionDeptFlg__c = TRUE )
AND ( FulfillingAggregateFlg__c = FALSE )
AND ( AcceptanceExpectedDate__c >= :startDate AND AcceptanceExpectedDate__c <= :endDate )
AND ( ( RecordType.DeveloperName = :conditonRecordTypeA AND OrderProbabilityRank__c IN :conditionOrderProbabilityRank ) OR RecordType.DeveloperName = :conditonRecordTypeB )
];
// Save records to aggregate
Map<String,Result__c> resultMap = new Map<String,Result__c>();
resultMap.put( '01' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'A' , FulfillingAggregateFlg__c = true , SE3__c = 'AAA' , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '02' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'B' , FulfillingAggregateFlg__c = true , SE3__c = 'AAA' , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '03' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'C' , FulfillingAggregateFlg__c = true , SE3__c = 'AAA' , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '22' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() , FulfillingAggregateFlg__c = true , SE3__c = 'AAA', LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );

// do the aggregation
for( Result__c result : resultList ){

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'A' && result.DXSolutionDeptFlg__c ){
resultMap.get( '01' ).LimitIncomeAchievementSum__c += result.LimitProfit__c;
resultMap.get( '01' ).LimitIncomeTargetSum__c += result.LimitIncomePartTarget__c;
resultMap.get( '01' ).FulfillingAggregateDate__c = day;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'B' && result.DXSolutionDeptFlg__c ){
resultMap.get( '02' ).LimitIncomeAchievementSum__c += result.LimitProfit__c;
resultMap.get( '02' ).LimitIncomeTargetSum__c += result.LimitIncomePartTarget__c;
resultMap.get( '02' ).FulfillingAggregateDate__c = day;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'C' && result.DXSolutionDeptFlg__c ){
resultMap.get( '03' ).LimitIncomeAchievementSum__c += result.LimitProfit__c;
resultMap.get( '03' ).LimitIncomeTargetSum__c += result.LimitIncomePartTarget__c;
resultMap.get( '03' ).FulfillingAggregateDate__c = day;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() && result.DXSolutionDeptFlg__c ){
resultMap.get( '22' ).LimitIncomeAchievementSum__c += result.LimitProfit__c;
resultMap.get( '22' ).LimitIncomeTargetSum__c += result.LimitIncomePartTarget__c;
resultMap.get( '22' ).FulfillingAggregateDate__c = day;
}

}
// insert record
insert resultMap.values();
}

}```

Please tell me how to write the test class.
```trigger ResultCustomerTrigger on Result__c (Before insert,Before update) {

Set<Id> oppIdSet  = new Set<Id>();
for (Result__c m : Trigger.new){
}

List<Opportunity> OpportunityList =[SELECT Id,Vup_No__c,Account.Name FROM Opportunity WHERE Id =: oppIdSet];
Map<Id,Opportunity> OppMap = new Map<Id,Opportunity>();
for (Opportunity opp : OpportunityList){
OppMap.put(opp.Id,opp);
}

for (Result__c m : Trigger.new){
Opportunity opp = (Opportunity)OppMap.get(m.vupOpportunity__c);
if ( opp != null) {
if (m.DeliveryDestination__c == null && m.ProjectNo__c == null) {
m.DeliveryDestination__c = opp.AccountId;
m.ProjectNo__c = opp.Vup_No__c;
}

}

}
}```

Please tell me how to write the test class.
Error message
Method does not exist or incorrect signature: void addMonth(Integer) from the type Date.

How can I fix it?

```​​​​​​​        Date day = Date.today();
Date startDate = Date.newInstance( day.year() - ( day.month() < 4 ? 1 : 0 ) , ( day.month() >= 4 || day.month() <= 9 ) ? 4 : 10 , 1 );

I have created the following code, but I am getting an error.
Where should i fix?

For example
・Unexpected token 'OR'.
・Expecting ';' but was: 'AND'
・Field is not writeable: Result__c.ManagedServiceDeptFlg__c
```global without sharing class ResultFulfillingAggregateScheduler implements Schedulable{

public void execute( SchedulableContext sc ){

String conditonRecordTypeA = 'OrderEstimated';
String conditonRecordTypeB = 'OrderRegistration';
Map<String,Schema.RecordTypeInfo> recordTypeMap = new Map<String,Schema.RecordTypeInfo>();
for( Schema.RecordTypeInfo info : Result__c.SObjectType.getDescribe().getRecordTypeInfos() ){
if( info.getDeveloperName() == conditonRecordTypeA || info.getDeveloperName() == conditonRecordTypeB ){
recordTypeMap.put( info.getDeveloperName() , info );
}
}

List<String> conditionOrderProbabilityRank = new List<String>{ 'A' , 'B' , 'C' };

Date day = Date.today();
Date startDate = Date.newInstance( day.year() - ( day.month() < 4 ? 1 : 0 ) , ( day.month() >= 4 || day.month() <= 9 ) ? 4 : 10 , 1 );

List<Result__c> resultList = [
SELECT OrderProbabilityRank__c , RecordTypeId , DXSolutionDeptFlg__c , PlatformSolutionDeptFlg__c , DSPSSolutionDeptFlg__c , ManagedServiceDeptFlg__c , EastJapanSolutionDeptFlg__c , ChubuSolutionDeptFlg__c , WestJapanSolutionDeptFlg__c ,  LimitProfit__c , LimitIncomePartTarget__c
FROM Result__c
WHERE ( DXSolutionDeptFlg__c = TRUE OR PlatformSolutionDeptFlg__c = TRUE OR DSPSSolutionDept__c = TRUE OR ManagedServiceDeptFlg__c OR EastJapanSolutionDeptFlg__c OR ChubuSolutionDeptFlg__c OR WestJapanSolutionDeptFlg__c )
AND ( FulfillingAggregateFlg__c = FALSE )
AND ( AcceptanceExpectedDate__c >= :startDate AND AcceptanceExpectedDate__c <= :endDate )
AND ( ( RecordType.DeveloperName = :conditonRecordTypeA AND OrderProbabilityRank__c IN :conditionOrderProbabilityRank ) OR RecordType.DeveloperName = :conditonRecordTypeB )
];
// 集計を保存するレコードを準備する（key = 作成条件テーブルナンバー）
Map<String,Result__c> resultMap = new Map<String,Result__c>();
resultMap.put( '01' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'A' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = true  , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '02' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'B' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = true  , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '03' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'C' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = true  , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '04' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'A' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = true  , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '05' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'B' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = true  , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '06' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'C' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = true  , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '07' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'A' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = true  , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '08' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'B' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = true  , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '09' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'C' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = true  , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '10' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'A' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDepFlgt__c = false , ManagedServiceDeptFlg__c = true ,  EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '11' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'B' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = true ,  EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '12' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'C' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = true ,  EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '13' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'A' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDepFlgt__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = true ,  ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '14' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'B' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = true ,  ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '15' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'C' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = true ,  ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '16' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'A' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = true ,  WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '17' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'B' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = true ,  WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '18' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'C' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = true ,  WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '19' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'A' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = true , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '20' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'B' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = true , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '21' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'C' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = true , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '22' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = true  , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '23' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = true  , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '24' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = true  , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '25' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = true ,  EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '26' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = true ,  ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '27' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = true ,  WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '28' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = true ,  LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );

for( Result__c result : resultList ){

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'A' && result.DXSolutionDeptFlg__c ){
resultMap.get( '01' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '01' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'B' && result.DXSolutionDeptFlg__c ){
resultMap.get( '02' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '02' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'C' && result.DXSolutionDeptFlg__c ){
resultMap.get( '03' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '03' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'A' && result.PlatformSolutionDeptFlg__c ){
resultMap.get( '04' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '04' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'B' && result.PlatformSolutionDeptFlg__c ){
resultMap.get( '05' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '05' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'C' && result.PlatformSolutionDeptFlg__c ){
resultMap.get( '06' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '06' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'A' && result.DSPSSolutionDeptFlg__c ){
resultMap.get( '07' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '07' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'B' && result.DSPSSolutionDeptFlg__c ){
resultMap.get( '08' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '08' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'C' && result.DSPSSolutionDeptFlg__c ){
resultMap.get( '09' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '09' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'A' && result.ManagedServiceDeptFlg__c ){
resultMap.get( '10' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '10' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'B' && result.ManagedServiceDeptFlg__c ){
resultMap.get( '11' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '11' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'C' && result.ManagedServiceDeptFlg__c ){
resultMap.get( '12' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '12' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'A' && result.EastJapanSolutionDeptFlg__c ){
resultMap.get( '13' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '13' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'B' && result.EastJapanSolutionDeptFlg__c ){
resultMap.get( '14' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '14' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'C' && result.EastJapanSolutionDeptFlg__c ){
resultMap.get( '15' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '15' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'A' && result.ChubuSolutionDeptFlg__c ){
resultMap.get( '16' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '16' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'B' && result.ChubuSolutionDeptFlg__c ){
resultMap.get( '17' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '17' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'C' && result.ChubuSolutionDeptFlg__c ){
resultMap.get( '18' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '18' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}
// 作成条件テーブル No.19
if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'A' && result.WestJapanSolutionDeptFlg__c ){
resultMap.get( '19' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '19' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'B' && result.WestJapanSolutionDeptFlg__c ){
resultMap.get( '20' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '20' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'C' && result.WestJapanSolutionDeptFlg__c ){
resultMap.get( '21' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '21' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() && result.DXSolutionDeptFlg__c ){
resultMap.get( '22' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '22' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}
// 作成条件テーブル No.23
if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() && result.PlatformSolutionDeptFlg__c ){
resultMap.get( '23' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '23' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() && result.DSPSSolutionDeptFlg__c ){
resultMap.get( '24' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '24' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() && result.ManagedServiceDeptFlg__c ){
resultMap.get( '25' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '25' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() && result.EastJapanSolutionDeptFlg__c ){
resultMap.get( '26' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '26' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() && result.ChubuSolutionDeptFlg__c ){
resultMap.get( '27' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '27' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() && result.WestJapanSolutionDeptFlg__c ){
resultMap.get( '28' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '28' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}
}

insert resultMap.values();
}

}```

```global without sharing class ResultFulfillingAggregateScheduler implements Schedulable{

/**
*  *** AcceptanceExpectedDate is divided into 1st half and 2nd half (1st half: April to September, 2nd half: October to next March)
*  *** Split timing is based on execution date
*/
public void execute( SchedulableContext sc ){
// Get record type
String conditonRecordTypeA = 'OrderEstimated';
String conditonRecordTypeB = 'OrderRegistration';
Map<String,Schema.RecordTypeInfo> recordTypeMap = new Map<String,Schema.RecordTypeInfo>();
for( Schema.RecordTypeInfo info : Result__c.SObjectType.getDescribe().getRecordTypeInfos() ){
if( info.getDeveloperName() == conditonRecordTypeA || info.getDeveloperName() == conditonRecordTypeB ){
recordTypeMap.put( info.getDeveloperName() , info );
}
}
/**

*/
// Set String value
List<String> conditionOrderProbabilityRank = new List<String>{ 'A' , 'B' , 'C' };
// Set conditions for first half and second half
Date day = Date.today();
Date startDate = Date.newInstance( day.year() - ( day.month() < 4 ? 1 : 0 ) , ( day.month() >= 4 || day.month() <= 9 ) ? 4 : 10 , 1 );
// execute SOQL
List<Result__c> resultList = [
SELECT OrderProbabilityRank__c , RecordTypeId , DXSolutionDeptFlg__c , PlatformSolutionDeptFlg__c , DSPSSolutionDeptFlg__c , ManagedServiceDeptFlg__c , EastJapanSolutionDeptFlg__c , ChubuSolutionDeptFlg__c , WestJapanSolutionDeptFlg__c ,  LimitProfit__c , LimitIncomePartTarget__c
FROM Result__c
WHERE ( DXSolutionDeptFlg__c = TRUE OR PlatformSolutionDeptFlg__c = TRUE OR DSPSSolutionDeptFlg__c = TRUE OR ManagedServiceDeptFlg__c = TRUE OR EastJapanSolutionDeptFlg__c = TRUE OR ChubuSolutionDeptFlg__c = TRUE OR WestJapanSolutionDeptFlg__c = TRUE )
AND ( FulfillingAggregateFlg__c = FALSE )
AND ( AcceptanceExpectedDate__c >= :startDate AND AcceptanceExpectedDate__c <= :endDate )
AND ( ( RecordType.DeveloperName = :conditonRecordTypeA AND OrderProbabilityRank__c IN :conditionOrderProbabilityRank ) OR RecordType.DeveloperName = :conditonRecordTypeB )
];
// Save records to aggregate
Map<String,Result__c> resultMap = new Map<String,Result__c>();
resultMap.put( '01' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'A' , FulfillingAggregateFlg__c = true , SE3__c = 'AAA' , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '02' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'B' , FulfillingAggregateFlg__c = true , SE3__c = 'AAA' , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '03' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'C' , FulfillingAggregateFlg__c = true , SE3__c = 'AAA' , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '22' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() , FulfillingAggregateFlg__c = true , SE3__c = 'AAA', LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );

// do the aggregation
for( Result__c result : resultList ){

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'A' && result.DXSolutionDeptFlg__c ){
resultMap.get( '01' ).LimitIncomeAchievementSum__c += result.LimitProfit__c;
resultMap.get( '01' ).LimitIncomeTargetSum__c += result.LimitIncomePartTarget__c;
resultMap.get( '01' ).FulfillingAggregateDate__c = day;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'B' && result.DXSolutionDeptFlg__c ){
resultMap.get( '02' ).LimitIncomeAchievementSum__c += result.LimitProfit__c;
resultMap.get( '02' ).LimitIncomeTargetSum__c += result.LimitIncomePartTarget__c;
resultMap.get( '02' ).FulfillingAggregateDate__c = day;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'C' && result.DXSolutionDeptFlg__c ){
resultMap.get( '03' ).LimitIncomeAchievementSum__c += result.LimitProfit__c;
resultMap.get( '03' ).LimitIncomeTargetSum__c += result.LimitIncomePartTarget__c;
resultMap.get( '03' ).FulfillingAggregateDate__c = day;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() && result.DXSolutionDeptFlg__c ){
resultMap.get( '22' ).LimitIncomeAchievementSum__c += result.LimitProfit__c;
resultMap.get( '22' ).LimitIncomeTargetSum__c += result.LimitIncomePartTarget__c;
resultMap.get( '22' ).FulfillingAggregateDate__c = day;
}

}
// insert record
insert resultMap.values();
}

}```

Please tell me how to write the test class.
Check what week of the year a date is To find out what week of the year a date is in, use the formula: What formula can you have if you want a year to start on April 1st and end on March 31st?
```IF(
CEILING( ( date - DATE( YEAR( date ), 1, 1) + 1) / 7) > 52,
52,
CEILING( ( date - DATE( YEAR( date ), 1, 1) + 1) / 7)
)```
```F(DAY( CloseDate ) / 7 <= 1 , 1 ,
IF(DAY( CloseDate ) / 7 <= 2 , 2 ,
IF(DAY( CloseDate ) / 7 <= 3 , 3 ,
IF(DAY( CloseDate ) / 7 <= 4 , 4 ,
IF(DAY( CloseDate ) / 7 <= 5 , 5 , 0) ))))```
It seems that you are counting the weeks of the month.

I got the following error in process builder:

Invalid formula: syntax error. missing '='
how can i fix it
```CASE(1,

IF(AND(DAY([Opportunity].CloseDate)>= 1,DAY([Opportunity]].CloseDate)<= 7),1,2),”1Weeks”,

IF(AND(DAY([Opportunity]].CloseDate)>= 8,DAY([Opportunity]].CloseDate)<= 14),1,2),”2Weeks”,

IF(AND(DAY([Opportunity]].CloseDate)>= 15,DAY([Opportunity]].CloseDate)<= 21),1,2),”3Weeks”,

IF(AND(DAY([Opportunity]].CloseDate)>= 22,DAY([Opportunity]].CloseDate)<= 28),1,2),”4Weeks”,

“5Weeks”

)```

(1) Order rank = 'A' and DX flag = true amount
⑵Order rank = 'A' and DC flag = true amount
(3) Amount of order rank = 'A' and FV flag = true

I want to write the total amount of the three in a formula, how should I write it?
Error message
Method does not exist or incorrect signature: void addMonth(Integer) from the type Date.

How can I fix it?

```​​​​​​​        Date day = Date.today();
Date startDate = Date.newInstance( day.year() - ( day.month() < 4 ? 1 : 0 ) , ( day.month() >= 4 || day.month() <= 9 ) ? 4 : 10 , 1 );

I have created the following code, but I am getting an error.
Where should i fix?

For example
・Unexpected token 'OR'.
・Expecting ';' but was: 'AND'
・Field is not writeable: Result__c.ManagedServiceDeptFlg__c
```global without sharing class ResultFulfillingAggregateScheduler implements Schedulable{

public void execute( SchedulableContext sc ){

String conditonRecordTypeA = 'OrderEstimated';
String conditonRecordTypeB = 'OrderRegistration';
Map<String,Schema.RecordTypeInfo> recordTypeMap = new Map<String,Schema.RecordTypeInfo>();
for( Schema.RecordTypeInfo info : Result__c.SObjectType.getDescribe().getRecordTypeInfos() ){
if( info.getDeveloperName() == conditonRecordTypeA || info.getDeveloperName() == conditonRecordTypeB ){
recordTypeMap.put( info.getDeveloperName() , info );
}
}

List<String> conditionOrderProbabilityRank = new List<String>{ 'A' , 'B' , 'C' };

Date day = Date.today();
Date startDate = Date.newInstance( day.year() - ( day.month() < 4 ? 1 : 0 ) , ( day.month() >= 4 || day.month() <= 9 ) ? 4 : 10 , 1 );

List<Result__c> resultList = [
SELECT OrderProbabilityRank__c , RecordTypeId , DXSolutionDeptFlg__c , PlatformSolutionDeptFlg__c , DSPSSolutionDeptFlg__c , ManagedServiceDeptFlg__c , EastJapanSolutionDeptFlg__c , ChubuSolutionDeptFlg__c , WestJapanSolutionDeptFlg__c ,  LimitProfit__c , LimitIncomePartTarget__c
FROM Result__c
WHERE ( DXSolutionDeptFlg__c = TRUE OR PlatformSolutionDeptFlg__c = TRUE OR DSPSSolutionDept__c = TRUE OR ManagedServiceDeptFlg__c OR EastJapanSolutionDeptFlg__c OR ChubuSolutionDeptFlg__c OR WestJapanSolutionDeptFlg__c )
AND ( FulfillingAggregateFlg__c = FALSE )
AND ( AcceptanceExpectedDate__c >= :startDate AND AcceptanceExpectedDate__c <= :endDate )
AND ( ( RecordType.DeveloperName = :conditonRecordTypeA AND OrderProbabilityRank__c IN :conditionOrderProbabilityRank ) OR RecordType.DeveloperName = :conditonRecordTypeB )
];
// 集計を保存するレコードを準備する（key = 作成条件テーブルナンバー）
Map<String,Result__c> resultMap = new Map<String,Result__c>();
resultMap.put( '01' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'A' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = true  , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '02' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'B' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = true  , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '03' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'C' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = true  , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '04' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'A' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = true  , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '05' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'B' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = true  , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '06' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'C' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = true  , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '07' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'A' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = true  , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '08' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'B' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = true  , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '09' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'C' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = true  , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '10' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'A' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDepFlgt__c = false , ManagedServiceDeptFlg__c = true ,  EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '11' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'B' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = true ,  EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '12' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'C' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = true ,  EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '13' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'A' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDepFlgt__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = true ,  ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '14' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'B' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = true ,  ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '15' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'C' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = true ,  ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '16' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'A' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = true ,  WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '17' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'B' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = true ,  WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '18' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'C' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = true ,  WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '19' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'A' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = true , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '20' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'B' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = true , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '21' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'C' , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = true , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '22' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = true  , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '23' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = true  , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '24' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = true  , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '25' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = true ,  EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '26' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = true ,  ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '27' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = true ,  WestJapanSolutionDeptFlg__c = false , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );
resultMap.put( '28' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() , FulfillingAggregateFlg__c = true , DXSolutionDeptFlg__c = false , PlatformSolutionDeptFlg__c = false , DSPSSolutionDeptFlg__c = false , ManagedServiceDeptFlg__c = false , EastJapanSolutionDeptFlg__c = false , ChubuSolutionDeptFlg__c = false , WestJapanSolutionDeptFlg__c = true ,  LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );

for( Result__c result : resultList ){

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'A' && result.DXSolutionDeptFlg__c ){
resultMap.get( '01' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '01' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'B' && result.DXSolutionDeptFlg__c ){
resultMap.get( '02' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '02' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'C' && result.DXSolutionDeptFlg__c ){
resultMap.get( '03' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '03' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'A' && result.PlatformSolutionDeptFlg__c ){
resultMap.get( '04' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '04' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'B' && result.PlatformSolutionDeptFlg__c ){
resultMap.get( '05' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '05' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'C' && result.PlatformSolutionDeptFlg__c ){
resultMap.get( '06' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '06' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'A' && result.DSPSSolutionDeptFlg__c ){
resultMap.get( '07' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '07' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'B' && result.DSPSSolutionDeptFlg__c ){
resultMap.get( '08' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '08' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'C' && result.DSPSSolutionDeptFlg__c ){
resultMap.get( '09' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '09' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'A' && result.ManagedServiceDeptFlg__c ){
resultMap.get( '10' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '10' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'B' && result.ManagedServiceDeptFlg__c ){
resultMap.get( '11' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '11' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'C' && result.ManagedServiceDeptFlg__c ){
resultMap.get( '12' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '12' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'A' && result.EastJapanSolutionDeptFlg__c ){
resultMap.get( '13' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '13' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'B' && result.EastJapanSolutionDeptFlg__c ){
resultMap.get( '14' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '14' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'C' && result.EastJapanSolutionDeptFlg__c ){
resultMap.get( '15' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '15' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'A' && result.ChubuSolutionDeptFlg__c ){
resultMap.get( '16' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '16' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'B' && result.ChubuSolutionDeptFlg__c ){
resultMap.get( '17' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '17' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'C' && result.ChubuSolutionDeptFlg__c ){
resultMap.get( '18' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '18' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}
// 作成条件テーブル No.19
if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'A' && result.WestJapanSolutionDeptFlg__c ){
resultMap.get( '19' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '19' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'B' && result.WestJapanSolutionDeptFlg__c ){
resultMap.get( '20' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '20' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'C' && result.WestJapanSolutionDeptFlg__c ){
resultMap.get( '21' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '21' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() && result.DXSolutionDeptFlg__c ){
resultMap.get( '22' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '22' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}
// 作成条件テーブル No.23
if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() && result.PlatformSolutionDeptFlg__c ){
resultMap.get( '23' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '23' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() && result.DSPSSolutionDeptFlg__c ){
resultMap.get( '24' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '24' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() && result.ManagedServiceDeptFlg__c ){
resultMap.get( '25' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '25' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() && result.EastJapanSolutionDeptFlg__c ){
resultMap.get( '26' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '26' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() && result.ChubuSolutionDeptFlg__c ){
resultMap.get( '27' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '27' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}

if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeB ).getRecordTypeId() && result.WestJapanSolutionDeptFlg__c ){
resultMap.get( '28' ).LimitIncomeAchievementSum__c += LimitProfit__c;
resultMap.get( '28' ).LimitIncomeTargetSum__c += LimitIncomePartTarget__c;
}
}

insert resultMap.values();
}

}```