| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- //
- // NewDeliveryRequirementModel.m
- // IBOSSHSH
- //
- // Created by ssl on 2018/1/15.
- // Copyright © 2018年 elongtian. All rights reserved.
- //
- #import "NewDispatchRequirementModel.h"
- @implementation NewDispatchRequirementModel
- #pragma mark - 私有函数
- /*!
- * 1.该方法是 `字典里的属性Key` 和 `要转化为模型里的属性名` 不一样 而重写的
- * 前:模型的属性 后:字典里的属性
- */
- + (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper{
-
- return @{@"code":@"Code",
- @"goodsName":@"GoodsName",
- @"receiptType":@"ReceiptType",
- @"receiptRemarks":@"ReceiptRemarks",
- @"sourceFrom":@"SourceFrom",
- @"detailId":@"DetailID",
- @"invoiceId":@"InvoiceID",
- @"invoiceDetailId":@"InvoiceDetailID",
- @"acreage":@"Acreage",
- @"onlyCode":@"OnlyCode",
- @"outQuantity":@"OutQuantity",
- @"circulateType":@"CirculateType",
- @"receiptDetailId":@"ReceiptDetailID",
- @"finalDeliveryReceiptQuantity":@"FinalDeliveryReceiptQuantity",
- @"finalInstallReceiptQuantity":@"FinalInstallationFinishQuantity"
- };
-
- }
- /*!
- * 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.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]];
-
- double maxInstallReceiptQuantityValue= [self.installQuantity doubleValue] > [self.outQuantity doubleValue]? [self.outQuantity doubleValue]:[self.installQuantity doubleValue];
- self.maxInstallReceiptQuantity = [NSString stringWithFormat:str,maxInstallReceiptQuantityValue];
- self.installReceiptQuantity =self.maxInstallReceiptQuantity ;
-
-
- return YES;
- }
- @end
|