Commit 44795351 authored by Sandy's avatar Sandy

采购单收货完成

parent 4a62d8c4
......@@ -8,7 +8,7 @@
#import "IBTObject.h"
#import "ICRAnnouncement.h"
#define HTTP [ICRHTTPController sharedController]
typedef NS_ENUM(NSUInteger, ICRAttachmentType) {
kAttachmentBoard = 0,
kAttachmentAnswer,
......@@ -359,7 +359,25 @@ typedef NS_ENUM(NSUInteger, ICRAttachmentType) {
success:(void (^)(id))succ
failure:(void (^)(id))fail;
/**
* 是否wms仓库
*
* @param uuid 仓库uuid
* @param succ succ description
* @param fail fail description
*/
- (void)isWmsWarehouse:(NSString *)uuid success:(void (^)(id succ))succ
failure:(void (^)(id fail))fail;
/**
* 是否产品中心仓库
*
* @param uuid 仓库uuid
* @param succ succ description
* @param fail fail description
*/
- (void)isCenterWarehouse:(NSString *)uuid success:(void (^)(id succ))succ
failure:(void (^)(id fail))fail;
//1.添加发运单
- (void)saveTransportWithData:(id)data
success:(void (^)(id))succ
......
......@@ -2387,6 +2387,65 @@ acceptTypeJson:YES
failure:failure];
}
/**
* 是否wms仓库
*
* @param uuid 仓库uuid
* @param succ succ description
* @param fail fail description
*/
- (void)isWmsWarehouse:(NSString *)uuid success:(void (^)(id succ))succ
failure:(void (^)(id fail))fail {
void (^success)(AFHTTPRequestOperation *operation, id responseObject) = ^(AFHTTPRequestOperation *operation, id responseObject) {
CLog(@"%@", responseObject);
if (succ) {
succ( responseObject );
}
};
void (^failure)(AFHTTPRequestOperation *operation, NSError *error) = ^(AFHTTPRequestOperation *operation, NSError *error) {
CLog(@"%@", error);
if (fail) {
fail( error );
}
};
NSString *url = [NSString stringWithFormat:@"%@/data/warehouse/isWmsWarehouse/%@",HTTP_REST_API_BASE_URL,uuid];
NSString *encodeUrlStr = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[self GET:encodeUrlStr parameters:nil needToken:NO acceptTypeJson:YES success:success failure:failure];
}
/**
* 是否产品中心仓库
*
* @param uuid 仓库uuid
* @param succ succ description
* @param fail fail description
*/
- (void)isCenterWarehouse:(NSString *)uuid success:(void (^)(id succ))succ
failure:(void (^)(id fail))fail {
void (^success)(AFHTTPRequestOperation *operation, id responseObject) = ^(AFHTTPRequestOperation *operation, id responseObject) {
CLog(@"%@", responseObject);
if (succ) {
succ( responseObject );
}
};
void (^failure)(AFHTTPRequestOperation *operation, NSError *error) = ^(AFHTTPRequestOperation *operation, NSError *error) {
CLog(@"%@", error);
if (fail) {
fail( error );
}
};
NSString *url = [NSString stringWithFormat:@"%@/data/warehouse/isProductCenter/%@",HTTP_REST_API_BASE_URL,uuid];
NSString *encodeUrlStr = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[self GET:encodeUrlStr parameters:nil needToken:NO acceptTypeJson:YES success:success failure:failure];
}
#pragma mark - 添加发运单
- (void)saveTransportWithData:(id)data
success:(void (^)(id))succ
......
......@@ -349,10 +349,20 @@ typedef enum : NSUInteger {
for (FeeAcountDetail *fee in _aBottomView.costVC.costArr) {
[costs addObject:[fee dictForCommit]];
}
//获取到期时间
NSString *dateString = [[NSDate date] httpParameterString];
NSDateFormatter *f = [NSDateFormatter new];
[f setDateFormat:@"yyy-MM-dd HH:ss:mm"];
NSDate *date = [f dateFromString:dateString];
NSDate *new = [NSDate dateWithTimeInterval:60 * 60 * 24 * 5 sinceDate:date];
NSString *expiredTime = [f stringFromDate:new];
NSDictionary *dict = @{@"uuid":uuidObject,
@"version":versionObject,
@"billnumber":billNumberObject,
@"state":state,
@"expiredDate":expiredTime,
@"type":[IBTCommon checkString:_purchaseView.type],
@"noticeUuid":[IBTCommon checkString:_purchaseView.noticeUuid],
@"noticeNumber":[IBTCommon checkString:_purchaseView.noticeNumber],
......
......@@ -29,6 +29,14 @@ typedef NS_ENUM(NSInteger, PurchaseType) {
@property (nonatomic,assign)NSInteger indexStyle;//0.1.2
@property (nonatomic, assign) PurchaseType type;
/**
* 收货仓库是否wms
*/
@property (nonatomic, assign) BOOL isWms;
/**
* 收货仓库是否产品中心仓
*/
@property (nonatomic, assign) BOOL isCenter;
......
......@@ -66,6 +66,8 @@ typedef enum : NSUInteger {
@property (strong, nonatomic) UILabel *labelInspectTime;
@property (strong, nonatomic) UILabel *labelReciever;
@property (strong, nonatomic) UILabel *labelRecieveTime;
@property (strong, nonatomic) UILabel *labelExpiredDate;
@property (strong, nonatomic) UILabel *labelOutSideNum;
@property (nonatomic,assign)BOOL isNotShowEdit;
//@property (nonatomic,strong)RejectView *rejectView;
......@@ -76,14 +78,18 @@ typedef enum : NSUInteger {
- (void)viewDidLoad {
[super viewDidLoad];
[self judgeType];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(editReceiveProduct:) name:KNOTIFICATION_EditReceiveProduct object:nil];
[self bulidLayout];
[self getDataFromServer];
}
- (void)judgeType {
if ([self.bill.state isEqualToString:PURCHASE_STATE_WAITE_RECIEVE]) {
self.type = PurchaseTypeAfterVerify;
}else{
self.type = PurchaseTypeBeforeVerify;
}
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(editReceiveProduct:) name:KNOTIFICATION_EditReceiveProduct object:nil];
[self bulidLayout];
[self getDataFromServer];
}
- (void)getDataFromServer{
__weak typeof(self)weakSelf = self;
......@@ -98,7 +104,7 @@ typedef enum : NSUInteger {
PurchaseBill *bill = [[PurchaseBill alloc]init];
[bill setValuesForKeysWithDictionary:dictData];
self.bill = bill;
[weakSelf judgeType];
[_aBottomView refreshCost:dictData[@"accountDetails"]];
[strongSelf fetchtPurchaseDetail];
}else{
......@@ -119,6 +125,8 @@ typedef enum : NSUInteger {
#pragma mark - 视图初始化
- (void)bulidLayout{
[_scrollView removeAllSubViews];
_scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, ScreenSize.width, ScreenSize.height - 64 - BottomHeight)];
_scrollView.showsHorizontalScrollIndicator = NO;
_scrollView.showsVerticalScrollIndicator = NO;
......@@ -333,8 +341,14 @@ typedef enum : NSUInteger {
NSInteger success = [data[@"success"] integerValue];
NSString *message = data[@"message"];
if (success == 1) {
//是wms且非产品中心仓,审核时同时收货
if (self.isWms && self.isCenter == NO && [action isEqualToString:PURCHASE_ACTION_APPROVE]) {
[self getDataFromServer];
}else{
[ICRUserUtil sharedInstance].needFresh = YES;
[self PopViewControllerAnimated:YES];
}
}else{
[IBTLoadingView showTips:message];
}
......@@ -385,7 +399,7 @@ typedef enum : NSUInteger {
}
- (void)createPurchaseView{
_leftArr = @[@"单号:",@"采购通知单:",@"创建人:",@"创建时间:",@"审核人:",@"审核时间:",@"收货人:",@"收货时间:",@"采购员:",@"状态:",@"类型:",@"供应商:",@"供应商确认:",@"收货仓库:",@"其他费用:",@"总金额:",@"外部单据号:",@"备注:"];
_leftArr = @[@"单号:",@"采购通知单:",@"创建人:",@"创建时间:",@"审核人:",@"审核时间:",@"收货人:",@"收货时间:",@"有效期:",@"采购员:",@"状态:",@"类型:",@"供应商:",@"供应商确认:",@"收货仓库:",@"其他费用:",@"总金额:",@"外部单据号:",@"备注:"];
_purchaseView= [[UIView alloc]initWithFrame:CGRectMake(0, TopMargin, ScreenSize.width, LeftHeight*_leftArr.count +LeftMargin)];
_purchaseView.backgroundColor = [UIColor whiteColor];
......@@ -439,6 +453,10 @@ typedef enum : NSUInteger {
self.labelReciever = rightLabel;
}else if ([title isEqualToString:@"收货时间:"]){
self.labelRecieveTime = rightLabel;
}else if ([title isEqualToString:@"有效期:"]){
self.labelExpiredDate = rightLabel;
}else if ([title isEqualToString:@"外部单据号:"]){
self.labelOutSideNum = rightLabel;
}
[_purchaseView addSubview:rightLabel];
......@@ -488,21 +506,32 @@ typedef enum : NSUInteger {
self.labelCreateTime.text = [IBTCommon checkString:self.bill.create_time];
self.labelInspector.text = [IBTCommon checkString:self.bill.approv_operName];
self.labelInspectTime.text = [IBTCommon checkString:self.bill.approv_time];
self.labelExpiredDate.text = [IBTCommon checkString:self.bill.expiredDate];
self.labelOutSideNum.text = [IBTCommon checkString:self.bill.outSideBillNumber];
NSMutableArray *productArr = [NSMutableArray array];
if (self.type == PurchaseTypeAfterVerify) {
for (NSDictionary *billDict in self.bill.products) {
TransferPdtDetail *billProbuct = [TransferPdtDetail new];
[billProbuct setValuesForKeysWithDictionary:billDict];
PurchaseBillProduct *p = [PurchaseBillProduct new];
[p setValuesForKeysWithDictionary:billDict];
billProbuct.purchasePdt = p;
if (self.isCenter) {
[billProbuct z_setRctQty:p.qty.floatValue];
}else if (self.isWms){
[billProbuct z_setRctQty:0];
}
[productArr addObject:billProbuct];
}
_pvc.productArr = productArr;
[_pvc.tableView reloadData];
if (self.isWms && self.isCenter == NO) {
[self httpRecieve];
}
}else{
for (NSDictionary *billDict in self.bill.products) {
......@@ -514,6 +543,9 @@ typedef enum : NSUInteger {
[_aBottomView.productVC.tableView reloadData];
}
[self setNoteHeight];
}
......@@ -578,10 +610,12 @@ typedef enum : NSUInteger {
- (void)httpRecieve{
NSString *receiveTime = [[NSDate date] httpParameterString];
self.bill.receive_time = receiveTime;
self.bill.receive_id = [ICRUserUtil sharedInstance].userId;
self.bill.receive_operName = [ICRUserUtil sharedInstance].userName;
NSMutableDictionary *param = [self.bill dictForCommit].mutableCopy;
NSMutableArray *arrProduct = [NSMutableArray array];
for (TransferPdtDetail *pdt in _pvc.productArr) {
PurchaseBillProduct *pPdt = [pdt changeToPurchasePdt];
......@@ -589,22 +623,23 @@ typedef enum : NSUInteger {
[arrProduct addObject:dict];
}
[param setObject:arrProduct forKey:@"product"];
[param setObject:arrProduct forKey:@"products"];
[param setObject:self.bill.accountDetails forKey:@"accountDetails"];
// IBTLoadingView showHUDAddedTo:self.view animated:<#(BOOL)#>
ICRHTTPController *http = [ICRHTTPController sharedController];
IBTLoadingView *hud = [IBTLoadingView showHUDAddedTo:self.view animated:YES];
__weak UIViewController *weakSelf = self;
[http recievePurchase:param success:^(id succ) {
[HTTP recievePurchase:param success:^(id succ) {
[hud hide:YES];
if ([succ[@"success"] boolValue]) {
[ICRUserUtil sharedInstance].needFresh = YES;
[IBTLoadingView showTips:@" 收货成功! "];
[weakSelf.navigationController popViewControllerAnimated:YES];
}
} failure:^(id fail) {
[IBTLoadingView showTips:fail];
}];
}
......
......@@ -466,10 +466,30 @@ typedef enum : NSUInteger {
nvc.title = @"修改采购单";
[self PushViewController:nvc animated:YES];
}else{
PurchaseDetailViewController *pvc = [PurchaseDetailViewController new];
pvc.title = @"查看采购单";
pvc.bill = bill;
[self PushViewController:pvc animated:YES];
void(^fail)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil];
[IBTLoadingView showTips:data];
};
__weak UIViewController *weakSelf = self;
//先判断是否wms或中心仓
[IBTLoadingView showProgressLabel:@"正在加载..."];
[HTTP isWmsWarehouse:bill.receiveWrh_uuid success:^(id succ) {
pvc.isWms = [succ[@"data"] boolValue];
[HTTP isCenterWarehouse:bill.receiveWrh_uuid success:^(id succ) {
[IBTLoadingView hideHUDWithText:nil];
pvc.isCenter = [succ[@"data"] boolValue];
[weakSelf PushViewController:pvc animated:YES];
} failure:fail];
} failure:fail];
}
}
}
......
......@@ -21,6 +21,7 @@
@property (nonatomic,strong)NSString *receiveWrh_code;//收货代码
@property (nonatomic,strong)NSString *receiveWrh_name;//收货姓名
@property (nonatomic,strong)NSString *rejectCause;//拒绝原因
@property (strong, nonatomic) NSString *enterprise;
@property (nonatomic,strong)NSNumber *total;//总金额
@property (nonatomic,strong)NSNumber *charge;//费用
......@@ -43,4 +44,20 @@
@property (nonatomic, strong) NSString *approv_time;//审核时间
@property (nonatomic, strong) NSString *approv_id;//审核人id
@property (nonatomic, strong) NSString *approv_operName;//审核人
/*
receive_time
收货时间
receive_id
收货人代码
receive_operName
收货人名称
expiredDate
到效日期
*/
@property (strong, nonatomic) NSString *receive_time;
@property (strong, nonatomic) NSString *receive_id;
@property (strong, nonatomic) NSString *receive_operName;
@property (strong, nonatomic) NSString *expiredDate;
@end
......@@ -58,4 +58,5 @@
@property (strong, nonatomic) PurchaseBillProduct *purchasePdt;
- (PurchaseBillProduct *)changeToPurchasePdt;
- (void)z_setRctQty:(CGFloat)qty;
@end
......@@ -29,4 +29,20 @@
self.purchasePdt.receivedBaseQty = self.rctBaseQty;
return self.purchasePdt;
}
- (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];
}
@end
......@@ -56,7 +56,7 @@
self.secondTable.bounces = NO;
self.secondTable.separatorStyle = UITableViewCellSeparatorStyleNone;
[self.bgView addSubview:self.secondTable];
NSArray *arr = @[@"商品",@"单价",@"包装数量"];
NSArray *arr = @[@"商品",@"包装规格",@"包装数量",@"基础数量"];
HeaderCell *headCell = [[HeaderCell alloc]initWithFrame:CGRectMake(0, 0, ScreenSize.width, 38) withArr:arr withHiddenEdit:YES];
self.secondTable.tableHeaderView = headCell;
......
......@@ -13,7 +13,7 @@
@property (nonatomic,strong)UIButton *editBtn;
@property (nonatomic,strong)UILabel *seqLabel;
@property (nonatomic,strong)UILabel *titleLabel;
@property (nonatomic,strong)UILabel *priceLabel;
@property (nonatomic,strong)UILabel *qpcLabel;
@property (nonatomic,strong)UILabel *countLabel;
@property (nonatomic,strong)UILabel *shippedQtyLabel;
@property (nonatomic,strong)UILabel *lineLabel;
......
......@@ -51,13 +51,13 @@
self.titleLabel.text = @"苹果桃子";
self.titleLabel.font = GXF_SIXTEENTEH_SIZE;
self.priceLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMaxX(self.titleLabel.frame) + SpaceMargin, 0, headWidth, TableHeight))];
self.priceLabel.textAlignment = NSTextAlignmentCenter;
self.priceLabel.textColor = GXF_CONTENT_COLOR;
self.priceLabel.text = @"80";
self.priceLabel.font = GXF_SIXTEENTEH_SIZE;
self.qpcLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMaxX(self.titleLabel.frame) + SpaceMargin, 0, headWidth, TableHeight))];
self.qpcLabel.textAlignment = NSTextAlignmentCenter;
self.qpcLabel.textColor = GXF_CONTENT_COLOR;
self.qpcLabel.text = @"80";
self.qpcLabel.font = GXF_SIXTEENTEH_SIZE;
self.countLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMaxX(self.priceLabel.frame) + SpaceMargin, 0, headWidth, TableHeight))];
self.countLabel = [[UILabel alloc]initWithFrame:(CGRectMake(CGRectGetMaxX(self.qpcLabel.frame) + SpaceMargin, 0, headWidth, TableHeight))];
self.countLabel.textAlignment = NSTextAlignmentCenter;
self.countLabel.text = @"200";
self.countLabel.textColor = GXF_CONTENT_COLOR;
......@@ -153,7 +153,7 @@
[self.contentView addSubview:self.smallImageView];
[self.contentView addSubview:self.seqLabel];
[self.contentView addSubview:self.titleLabel];
[self.contentView addSubview:self.priceLabel];
[self.contentView addSubview:self.qpcLabel];
[self.contentView addSubview:self.countLabel];
[self.contentView addSubview:self.shippedQtyLabel];
[self.contentView addSubview:self.editBtn];
......@@ -179,14 +179,14 @@
- (void)setPdtDetail:(TransportPdtDetail *)pdtDetail row:(NSInteger)row{
self.seqLabel.text = [NSString stringWithFormat:@"%@",@(row+1)];
self.titleLabel.text = pdtDetail.productName;
self.priceLabel.text = [NSString stringWithFormat:@"%.2f元",[pdtDetail.price floatValue]];
self.qpcLabel.text = [NSString stringWithFormat:@"%.1f元",[pdtDetail.qpc floatValue]];
self.countLabel.text = [NSString stringWithFormat:@"%@%@",[pdtDetail.qty stringValue],pdtDetail.unit];
self.shippedQtyLabel.text = [NSString stringWithFormat:@"%@%@",pdtDetail.transferQty != nil && ![pdtDetail.transferQty isKindOfClass:[NSNull class]]? [pdtDetail.transferQty stringValue]:@"0",pdtDetail.unit];
self.shippedQtyLabel.text = [NSString stringWithFormat:@"%@",pdtDetail.baseQty != nil && ![pdtDetail.baseQty isKindOfClass:[NSNull class]]? [pdtDetail.baseQty stringValue]:@"0"];
self.showNameLabel.text = [NSString stringWithFormat:@"商品:%@[%@]",pdtDetail.productName,pdtDetail.productCode];
self.showStandLabel.text = [NSString stringWithFormat:@"包装规格:1*%@%@",[pdtDetail.qpc stringValue],pdtDetail.baseUnit];
self.showCountLabel.text = [NSString stringWithFormat:@"包装数量:%@%@",[pdtDetail.qty stringValue],pdtDetail.unit];
self.showBaseCountLabel.text =[NSString stringWithFormat:@"基础数量:%@%@",[pdtDetail.baseQty stringValue],pdtDetail.baseUnit];
self.showBaseCountLabel.text =[NSString stringWithFormat:@"基础数量:%@%@",[pdtDetail.baseQty stringValue],pdtDetail.baseQty];
self.showPriceLabel.text = [NSString stringWithFormat:@"包装单价:%.2f元",[pdtDetail.packprice floatValue]];
self.showPurchaseLabel.text = [NSString stringWithFormat:@"采购单号:%@",pdtDetail.purchasebillnumber.length > 0 ? pdtDetail.purchasebillnumber: @"无"];
self.showTotalLabel.text = [NSString stringWithFormat:@"总金额:%.2f元",[pdtDetail.total floatValue]];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment