Skip to content

Commit 0593091

Browse files
add return parameters to collectPremium
1 parent 20c6f16 commit 0593091

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

contracts/components/Product.sol

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,37 @@ abstract contract Product is
107107
applicationData);
108108
}
109109

110+
function _collectPremium(bytes32 processId)
111+
internal
112+
returns(
113+
bool success,
114+
uint256 feeAmount,
115+
uint256 netAmount
116+
)
117+
{
118+
IPolicy.Policy memory policy = _getPolicy(processId);
119+
120+
if (policy.premiumPaidAmount < policy.premiumExpectedAmount) {
121+
(success, feeAmount, netAmount)
122+
= _collectPremium(
123+
processId,
124+
policy.premiumExpectedAmount - policy.premiumPaidAmount
125+
);
126+
}
127+
}
128+
110129
function _collectPremium(
111130
bytes32 processId,
112131
uint256 amount
113132
)
114133
internal
134+
returns(
135+
bool success,
136+
uint256 feeAmount,
137+
uint256 netAmount
138+
)
115139
{
116-
_productService.collectPremium(processId, amount);
140+
(success, feeAmount, netAmount) = _productService.collectPremium(processId, amount);
117141
}
118142

119143
function _revoke(bytes32 processId) internal {

contracts/services/IProductService.sol

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@ interface IProductService {
1212
bytes calldata applicationData
1313
) external;
1414

15-
function collectPremium(bytes32 processId, uint256 amount) external;
15+
function collectPremium(bytes32 processId, uint256 amount) external
16+
returns(
17+
bool success,
18+
uint256 feeAmount,
19+
uint256 netPremiumAmount
20+
);
1621

1722
function revoke(bytes32 processId) external;
18-
function underwrite(bytes32 processId) external returns (bool success);
23+
function underwrite(bytes32 processId) external returns(bool success);
1924
function decline(bytes32 processId) external;
2025
function expire(bytes32 processId) external;
2126
function close(bytes32 processId) external;
@@ -24,7 +29,7 @@ interface IProductService {
2429
bytes32 processId,
2530
uint256 claimAmount,
2631
bytes calldata data
27-
) external returns (uint256 claimId);
32+
) external returns(uint256 claimId);
2833

2934
function declineClaim(bytes32 processId, uint256 claimId) external;
3035

@@ -33,7 +38,7 @@ interface IProductService {
3338
uint256 claimId,
3439
uint256 payoutAmount,
3540
bytes calldata data
36-
) external returns (uint256 payoutId);
41+
) external returns(uint256 payoutId);
3742

3843
function processPayout(
3944
bytes32 processId,
@@ -48,5 +53,5 @@ interface IProductService {
4853
string calldata callbackMethodName,
4954
address callbackContractAddress,
5055
uint256 responsibleOracleId
51-
) external returns (uint256 requestId);
56+
) external returns(uint256 requestId);
5257
}

0 commit comments

Comments
 (0)