TransferPdtDetail.m 2.25 KB
Newer Older
陈俊俊's avatar
陈俊俊 committed
1 2 3 4 5 6 7 8 9 10 11 12
//
//  TransferPdtDetail.m
//  XFFruit
//
//  Created by 陈俊俊 on 15/9/28.
//  Copyright (c) 2015年 Xummer. All rights reserved.
//

#import "TransferPdtDetail.h"

@implementation TransferPdtDetail

Sandy's avatar
Sandy committed
13 14 15 16 17 18 19
- (void)setPurchasePdt:(PurchaseBillProduct *)purchasePdt {
    _purchasePdt = purchasePdt;
    self.productUuid = purchasePdt.product_uuid;
    self.productCode = purchasePdt.product_code;
    self.productName = purchasePdt.product_name;
    self.price = purchasePdt.basePrice;
    self.packprice = purchasePdt.price;
Sandy's avatar
Sandy committed
20 21
    self.rctQty = purchasePdt.receivedQty;
    self.rctBaseQty = purchasePdt.receivedBaseQty;
Sandy's avatar
Sandy committed
22 23 24 25 26 27 28
    
}

- (void)setTransportPdt:(TransportPdtDetail *)transportPdt {
    _transportPdt = transportPdt;
    self.rctQty = transportPdt.receivedQty;
    self.rctBaseQty = transportPdt.receivedBaseQty;
Sandy's avatar
Sandy committed
29
    self.sourcebillnumber = transportPdt.purchasebillnumber;
Sandy's avatar
Sandy committed
30 31
}

Sandy's avatar
Sandy committed
32 33 34 35 36
/**
 *  转化为采购单对象
 *
 *  @return return value description
 */
Sandy's avatar
Sandy committed
37 38 39 40 41 42 43 44 45 46
- (PurchaseBillProduct *)changeToPurchasePdt {
    if (!self.purchasePdt) {
        self.purchasePdt = [PurchaseBillProduct new];
        NSDictionary *dict = [self dictForCommit];
        [self.purchasePdt setValuesForKeysWithDictionary:dict];
    }
    self.purchasePdt.receivedQty = self.rctQty;
    self.purchasePdt.receivedBaseQty = self.rctBaseQty;
    return self.purchasePdt;
}
Sandy's avatar
Sandy committed
47

Sandy's avatar
Sandy committed
48 49 50 51 52 53 54 55 56 57 58
- (TransportPdtDetail *)changeToTransportPdt {
    if (!self.transportPdt) {
        self.transportPdt = [TransportPdtDetail new];
        NSDictionary *dict = [self dictForCommit];
        [self.transportPdt setValuesForKeysWithDictionary:dict];
    }
    self.transportPdt.receivedQty = self.rctQty;
    self.transportPdt.receivedBaseQty = self.rctBaseQty;
    return self.transportPdt;
}

Sandy's avatar
Sandy committed
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
- (void)z_setRctQty:(CGFloat)qty {
    //基础数量【实收】= 包装数量【实收】* 规格
    float baseCount = qty * [self.qpc floatValue];
    
    //总金额【实收】= 基础数量【实收】* 基础单价
    float total = 0;
    if (qty == [self.qty floatValue]) {
        total = [self.total floatValue];
    }else{
        total = baseCount * [self.price floatValue];
    }
    self.rctQty = [NSNumber numberWithFloat:qty];
    self.rctBaseQty = [NSNumber numberWithFloat:baseCount];
    self.rctTotal = [NSNumber numberWithFloat:total];
}
陈俊俊's avatar
陈俊俊 committed
74
@end