假设:
1bhk flat 200rupee maintenanceance
2bhk flat 400rupee维持费用
假设1 bhk用户支付给定日期的金额。
但如果用户未在指定日期支付金额,则自动将20%的额外费用添加到基本金额。
是否可以在Objective C中实现这一点?
答案 0 :(得分:0)
这是非常简单的兄弟。以下代码适用于1BHK用户。
float oneBHKCharge=200;
float finalDue=0;
NSString *strDueDate = @"10-02-2017";
NSString *strPaidDate = @"10-02-2017";
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"dd-MM-yyyy"];
NSDate *dueDate = [dateFormatter dateFromString:strDueDate];
NSDate *paidDate = [dateFormatter dateFromString:strPaidDate];
NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
NSDateComponents *components = [gregorianCalendar components:NSCalendarUnitDay
fromDate:dueDate
toDate:paidDate
options:0];
if (components.day > 0)
{
finalDue = oneBHKCharge + oneBHKCharge*0.2;
}
else
{
finalDue = oneBHKCharge;
}
NSLog(@"%f",finalDue);
答案 1 :(得分:0)
这里的代码我解决了这个话题。我在NSUserdefaults中存储了过期的日子。这是检查
- (NSNumber *)invoiceOverDue
{
NSNumber *result;
NSInteger dueDays = [[NSUserDefaults standardUserDefaults] integerForKey:VPPayDue];
if ([[self dueTime] intValue] > dueDays)
{
result = [NSNumber numberWithBool:YES];
}
else {
result = [NSNumber numberWithBool:NO];
}
return result;
}
在这里,女巫的部分我计算了过期时间。
// DueTime calculation
-(NSNumber *)dueTime
{
// NSTimeInterval secondsPerDay = 24 * 60 * 60;
if ([[self invoiceStatus] intValue] > 1)
{
return [NSNumber numberWithInt:0];
}
else {
NSTimeInterval calculateTime = [[* Insert here the date of your invoice*] timeIntervalSinceNow];
//DLog(@"dueTime bevor / 86400 :%f", calculateTime);
calculateTime /= -86400;
//DLog(@"dueTime :%f", calculateTime);
int returnInt = [ConverterHelper numberRoundUp:calculateTime];
return [NSNumber numberWithInt:returnInt];
}
}