| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- //
- // NewDeliveryReceiptModel.m
- // IBOSS
- //
- // Created by Dongke on 16/1/15.
- // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved.
- //
- // 功能描述:新增配送回执模型
- #import "NewDeliveryReceiptModel.h"
- @implementation NewDeliveryReceiptModel
- #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",
- @"onlyCode":@"OnlyCode"
- };
-
- }
- /*!
- * 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];
- 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.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{
- if(![[dic allKeys] containsObject:@"MaxReceiptQuantity"]){
- self.maxReceiptQuantity = [self.deliveryQuantity doubleValue] > [self.outQuantity doubleValue]? [self.outQuantity doubleValue]:[self.deliveryQuantity doubleValue];
- }
- else{
- double maximumReceiptQuantityValue=[[dic objectForKey:@"MaxReceiptQuantity"]doubleValue];
- self.maxReceiptQuantity=maximumReceiptQuantityValue;
- }
- }
-
-
- return YES;
- }
- @end
|