| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- //
- // NewDeliveryRequirementModel.m
- // IBOSSHSH
- //
- // Created by ssl on 2018/1/15.
- // Copyright © 2018年 elongtian. All rights reserved.
- //
- #import "NewDeliveryRequirementModel.h"
- @implementation NewDeliveryRequirementModel
- #pragma mark - 私有函数
- /*!
- * 1.该方法是 `字典里的属性Key` 和 `要转化为模型里的属性名` 不一样 而重写的
- * 前:模型的属性 后:字典里的属性
- */
- + (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper{
-
- return @{@"code":@"Code",
- @"receiptType":@"ReceiptType",
- @"receiptRemarks":@"ReceiptRemarks",
- @"sourceFrom":@"SourceFrom",
- @"detailId":@"DetailID",
- @"invoiceId":@"InvoiceID",
- @"invoiceDetailId":@"InvoiceDetailID",
- @"circulateType":@"CirculateType",
- @"acreage":@"Acreage"
-
- };
-
- }
- /*!
- * 2. 下面的两个方法 `字典里值`与`模型的值`类型不一样`需要转换`而重写的方法
- * NSDate *time dic[@"t"]是double类型的的秒数
- * Dic -> model
- */
- - (BOOL)modelCustomTransformFromDictionary:(NSDictionary *)dic {
- self.salesDetailType = [[dic objectForKey:@"SalesDetailType"] intValue];
- self.decimalPlaces = [[dic objectForKey:@"DecimalPlaces"] intValue];
- NSString *str = [NSString stringWithFormat:@"%@%d%@",@"%.",self.decimalPlaces,@"f"];
- double receiptQuantity = [[dic objectForKey:@"ReceiptQuantity"]doubleValue];
- self.receiptType = @"1";
- self.installReceiptType = @"1";
- if(receiptQuantity){
- self.receiptQuantity = [NSString stringWithFormat:str,receiptQuantity];
- }
- self.outQuantity = [NSString stringWithFormat:str,[[dic objectForKey:@"OutQuantity"]doubleValue]];
- self.deliveryQuantity = [NSString stringWithFormat:str,[[dic objectForKey:@"DeliveryQuantity"]doubleValue]];
- self.finishQuantity = [[dic objectForKey:@"FinishQuantity"]doubleValue];
- self.completeReceiptQuantity = [[dic objectForKey:@"CompleteReceiptQuantity"]doubleValue];
- self.returnQuantity = [[dic objectForKey:@"ReturnQuantity"]doubleValue];
- self.noOutReturnQuantity = [[dic objectForKey:@"NoOutReturnQuantity"]doubleValue];
- self.receiptNotInQuantity = [[dic objectForKey:@"ReceiptNotInQuantity"]doubleValue];
- self.MNFManufactureQuantity = [[dic objectForKey:@"MNFManufactureQuantity"]doubleValue];
- self.sourceFromQuantity = [[dic objectForKey:@"SourceFromQuantity"]doubleValue];
- //允许进行回执的量
- double tempQuantity;
- if([self.sourceFrom doubleValue] == 1){
- if([self.outQuantity doubleValue] < self.MNFManufactureQuantity){
- tempQuantity = [self.outQuantity doubleValue] -self.receiptNotInQuantity -self.completeReceiptQuantity-self.returnQuantity;
- }else{
- tempQuantity = [self.outQuantity doubleValue] - self.MNFManufactureQuantity-self.receiptNotInQuantity-self.completeReceiptQuantity-self.returnQuantity;
- }
- if(self.salesDetailType == 2){
- tempQuantity = self.sourceFromQuantity - self.completeReceiptQuantity -self.noOutReturnQuantity;
- }
- tempQuantity = tempQuantity < 0 ? 0 :tempQuantity;
- self.maxReceiptQuantity = [self.deliveryQuantity doubleValue] > tempQuantity? tempQuantity:[self.deliveryQuantity doubleValue];
- }else{
- self.maxReceiptQuantity = [self.deliveryQuantity doubleValue] > [self.outQuantity doubleValue]? [self.outQuantity doubleValue]:[self.deliveryQuantity doubleValue];
- }
- //安装
- self.installQuantity = [dic objectForKey:@"InstallationQuantity"] == nil?@"0":[NSString stringWithFormat:str,[[dic objectForKey:@"InstallationQuantity"]doubleValue]];
- self.maxInstallReceiptQuantity = [NSString stringWithFormat:str,[[dic objectForKey:@"MaxInstallationReceiptQuantity"]doubleValue]];
- self.installReceiptQuantity = self.maxInstallReceiptQuantity;
-
-
-
- return YES;
- }
- @end
|