| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737 |
- //
- // SalesSlipReceivablesVCViewController.m
- // IBOSSmini
- //
- // Created by guan hong hou on 2018/4/8.
- // Copyright © 2018年 elongtian. All rights reserved.
- //
- #import "SalesSlipReceivablesVC.h"
- @interface SalesSlipReceivablesVC ()
- @end
- @implementation SalesSlipReceivablesVC
- #pragma mark - 公共函数
- /**
- 视图加载完成
- */
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self loadNavStyle];
- [self initUI];
- if([_salesSlipModel.finalReceivableAmount doubleValue]>0){
- [self loadEarnestDataSource];
- }
-
- else if([_salesSlipModel.finalReceivables doubleValue]<0){
- _lblAvailablePredeposit.text=@"0.0000";
- _lblSubtractionPredeposit.userInteractionEnabled=NO;
- [self loadSettlementMethodDataSource];
-
- }
- }
- /**
- 修改:2017-9-25
- 适配机型
- 安全区视图发生变化
- */
- -(void)viewSafeAreaInsetsDidChange{
- self.view.backgroundColor = [UIColor whiteColor];
-
- _scrollView.frame=CGRectMake(0,0, Screen_Width, self.view.safeAreaLayoutGuide.layoutFrame.size.height-50);
- _btnSave.frame=CGRectMake(20,self.view.safeAreaLayoutGuide.layoutFrame.size.height-50, Screen_Width-40,50) ;
- [super viewSafeAreaInsetsDidChange];
- }
- #pragma mark - 委托函数
- /**
- 结算方式回调函数
- @param collectAmountModel <#collectAmountModel description#>
- */
- -(void)callbackSettlementMethod:(CollecteAmountModel *) collectAmountModel{
- _settlementTypeId=collectAmountModel.settlementTypeID;
- _lblSettlementMethod.text=collectAmountModel.settlementTypeName;
- }
- /**
- 冲减预存回调
- @param arry <#arry description#>
- */
- -(void)callbackUseStorageAmount:(NSMutableArray *)arry{
- double sum = 0;
- _useStorageCheckedList = arry;
- for(UseStorageModel *model in _useStorageCheckedList){
- NSString *earnestSum = model.earnestSum;
- double earnestSumValue = [earnestSum doubleValue];
- if(earnestSumValue > 0){
- sum+=earnestSumValue;
- }
- }
- NSString *sumStr=[NSString stringWithFormat:@"%.4f",sum];
- _lblSubtractionPredeposit.text = sumStr;
-
- }
- /**
- 冲减预存加载完成
- @param sender <#sender description#>
- */
- -(void)onEarnestLoadFinish:(ASIDownManager *)sender{
- NSDictionary *dic = [sender.mWebStr JSONValue];
- [self stopLoading];
- // 服务器返回数据是否正确
- if (dic && [dic isKindOfClass:[NSDictionary class]]) {
- // 服务器返回数据状态值
- int iStatus = [[dic objectForKey:@"Status"] intValue];
- // 服务器返回数据消息
- NSString *message=[dic objectForKey:@"Message"];
- // 服务器返回数据状态值正确
- if (iStatus == 0) {
- NSArray * infoArr=[dic objectForKey:@"Result"];
- if(infoArr!=nil&& infoArr.count>0)
- {
- _useStorageList=[[NSMutableArray alloc]init];
- for (int i = 0; i < infoArr.count; i++) {
- NSDictionary *dic=infoArr[i];
-
- UseStorageModel *model = [[UseStorageModel alloc] init];
- model.waitAuditSum = [NSString stringWithFormat:@"%.4f",[[dic objectForKey: @"WaitAuditSum"] doubleValue]];
- model.settlementType = [dic objectForKey: @"SettlementType"];
- model.settlementTypeName = [dic objectForKey: @"SettlementTypeName"];
- model.waitSetPrestore =[NSString stringWithFormat:@"%.4f",[[dic objectForKey: @"WaitSetPrestore"] doubleValue]] ;
- model.prestoreSum = [NSString stringWithFormat:@"%.4f",[[dic objectForKey: @"PrestoreSum"] doubleValue]];
- model.freezeSum = [NSString stringWithFormat:@"%.4f",[[dic objectForKey: @"FreezeSum"] doubleValue]];
- model.unusedEarnest = [NSString stringWithFormat:@"%.4f",[[dic objectForKey: @"UnusedEarnest"] doubleValue]];
- model.earnestSum = [NSString stringWithFormat:@"%.4f",[[dic objectForKey: @"EarnestSum"] doubleValue]];
- model.organizationID = [NSString stringWithFormat:@"%@",[dic objectForKey: @"OrganizationID"]];
- model.objectType = [dic objectForKey: @"ObjectType"];
- model.objectID = [NSString stringWithFormat:@"%@",[dic objectForKey: @"ObjectID"]];
-
- [_useStorageList addObject:model];
-
- }
- double sum=0;
- for(UseStorageModel *model in _useStorageList){
- NSString *unusedEarnestSum = model.unusedEarnest;
- double unusedEarnestSumValue = [unusedEarnestSum doubleValue];
- sum+=unusedEarnestSumValue;
- }
- NSString *sumStr=[NSString stringWithFormat:@"%.4f",sum];
- _lblAvailablePredeposit.text = sumStr;
-
- }
- else{
- _lblAvailablePredeposit.text=@"0.0000";
- }
- }
-
- else if(iStatus==ActionResultStatusAuthError
- ||iStatus==ActionResultStatusNoLogin
- ||iStatus==ActionResultStatusLogined ||iStatus == ActionResultStatusLoginedInvalid){
-
- [self showReLoginDialog:message];
- }
- else{
-
- [self showAlertViewText:message];
- }
-
- [self loadSettlementMethodDataSource];
- }
- }
- /**
- 冲减预存加载失败
- @param sender <#sender description#>
- */
- -(void)onEarnestLoadFail:(ASIDownManager *)sender{
- [self stopLoading];
- [self showAlertViewText:@"加载失败"];
- }
- /**
- 保存成功加载完成
- @param sender <#sender description#>
- */
- -(void)onLoadFinish:(ASIDownManager *)sender{
- NSDictionary *dic = [sender.mWebStr JSONValue];
- [self stopLoading];
- // 服务器返回数据是否正确
- if (dic && [dic isKindOfClass:[NSDictionary class]]) {
- // 服务器返回数据状态值
- int iStatus = [[dic objectForKey:@"Status"] intValue];
- // 服务器返回数据消息
- NSString *message=[dic objectForKey:@"Message"];
- // 服务器返回数据状态值正确
- if (iStatus == 0) {
- //初始化->
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示"
- message:@"保存成功!" preferredStyle:
- UIAlertControllerStyleAlert ];
- // addAction->
- [alert addAction:[UIAlertAction actionWithTitle:@"确定"
- style:UIAlertActionStyleDefault
- handler:^(UIAlertAction *action)
- {
-
- if([self.refreshDelegate respondsToSelector:@selector(refreshData)])
- {
- [self.refreshDelegate refreshData];
-
- }
- [self.navigationController popViewControllerAnimated:YES];
-
-
- }]];
- //展示->
- [self presentViewController:alert animated:YES completion:nil];
-
-
- }
-
- else if(iStatus==ActionResultStatusAuthError
- ||iStatus==ActionResultStatusNoLogin
- ||iStatus==ActionResultStatusLogined ||iStatus == ActionResultStatusLoginedInvalid){
-
- [self showReLoginDialog:message];
- }
- else{
-
- [self showAlertViewText:message];
- }
- }
- }
- /**
- 保存加载失败
- @param sender <#sender description#>
- */
- -(void)onLoadFail:(ASIDownManager *)sender{
- [self stopLoading];
- [self showAlertViewText:@"加载失败"];
- }
- -(void)onSettlementMethodLoadFinish:(ASIDownManager *)sender{
- NSDictionary *dic = [sender.mWebStr JSONValue];
- [self stopLoading];
- // 服务器返回数据是否正确
- if (dic && [dic isKindOfClass:[NSDictionary class]]) {
- // 服务器返回数据状态值
- int iStatus = [[dic objectForKey:@"Status"] intValue];
- // 服务器返回数据消息
- NSString *message=[dic objectForKey:@"Message"];
-
- // 服务器返回数据状态值正确
- if (iStatus == 0) {
- NSArray * infoArr=[dic objectForKey:@"Result"];
- if(infoArr!=nil&& infoArr.count>0)
- {
- _settlementMethodList=[[NSMutableArray alloc]init];
- for (int i = 0; i < infoArr.count; i++) {
- NSDictionary *dic=infoArr[i];
-
- CollecteAmountModel *model = [[CollecteAmountModel alloc] init];
- model.settlementTypeName = [dic objectForKey:@"SettlementTypeName"];
- model.settlementTypeID = [NSString stringWithFormat:@"%@",[dic objectForKey:@"SettlementType"]];
-
- [_settlementMethodList addObject:model];
- }
- CollecteAmountModel *collectModel=[_settlementMethodList objectAtIndex:0];
- _lblSettlementMethod.text=collectModel.settlementTypeName;
- _settlementTypeId=collectModel.settlementTypeID;
-
- }
- }
-
- else if(iStatus==ActionResultStatusAuthError
- ||iStatus==ActionResultStatusNoLogin
- ||iStatus==ActionResultStatusLogined ||iStatus == ActionResultStatusLoginedInvalid){
-
- [self showReLoginDialog:message];
- }
- else{
-
- [self showAlertViewText:message];
- }
- }
- }
- -(void)onSettlementMethodLoadFail:(ASIDownManager *)sender{
- [self stopLoading];
- [self showAlertViewText:@"加载失败"];
- }
- #pragma mark - 私有函数
- /**
- 导航按钮样式
- */
- -(void)loadNavStyle
- {
-
- self.navigationItem.title=@"新建应收款";
- //返回
- UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
- [button setBackgroundImage:[UIImage imageNamed:@"icon_back"]
- forState:UIControlStateNormal];
- [button addTarget:self action:@selector(goBack)
- forControlEvents:UIControlEventTouchUpInside];
- button.frame = CGRectMake(0, 0, 15, 18);
-
- UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
- self.navigationItem.leftBarButtonItem = menuButton;
- }
- /**
- 返回
- */
- - (void)goBack
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
- /**
- 初始化UI
- */
- -(void)initUI{
- [self.view setBackgroundColor:[UIColor whiteColor]];
- _scrollView=[UIScrollView new];
- _scrollView.frame=CGRectZero;
- [self.view addSubview:_scrollView];
- _vBody=[UIView new];
- _vBody.frame=CGRectZero;
- [_scrollView addSubview:_vBody];
- _scrollView.delegate=self;
- UITapGestureRecognizer* gesture=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKey)];
-
- [self.view addGestureRecognizer:gesture];
-
- UILabel *lblTitleBasicInfo=[[UILabel alloc]init];
- lblTitleBasicInfo.frame=CGRectMake(15,16, 100, 25);
- lblTitleBasicInfo.text = @"基础信息";
- lblTitleBasicInfo.textColor=[UIColor redColor];
- lblTitleBasicInfo.font= [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [_vBody addSubview:lblTitleBasicInfo];
-
- UIView *separator1 = [UIView new];
- separator1.backgroundColor=LineBackgroundColor;
- separator1.frame=CGRectMake(0,CGRectGetMaxY(lblTitleBasicInfo.frame)+3,Screen_Width, 1);
- [_vBody addSubview:separator1];
- _vBody.frame=CGRectMake(0,0,Screen_Width, CGRectGetMaxY(separator1.frame));
-
- UIView *vSalesNo=[UIView new];
- vSalesNo.frame=CGRectMake(0, CGRectGetMaxY(separator1.frame),Screen_Width, 51);
- [_vBody addSubview:vSalesNo];
-
- _lblSalesNo=[self getUILabel:vSalesNo labelText:@"销售单号" hintText:@"" labelColor:[UIColor blackColor] isHaveRightArrow:NO tag:1000];
- _lblSalesNo.text=_salesSlipModel.SalesNo;
-
-
- UIView *vCustomerCode=[UIView new];
- vCustomerCode.frame=CGRectMake(0, CGRectGetMaxY(vSalesNo.frame),Screen_Width, 51);
- [_vBody addSubview:vCustomerCode];
- _lblCustomerCode=[self getUILabel:vCustomerCode labelText:@"客户编码" hintText:@"" labelColor:[UIColor blackColor] isHaveRightArrow:NO tag:1001];
- _lblCustomerCode.text=_salesSlipModel.customerCode;
- _customerId=_salesSlipModel.customerId;
-
- UIView *vDepartment=[UIView new];
- vDepartment.frame=CGRectMake(0, CGRectGetMaxY(vCustomerCode.frame),Screen_Width, 51);
- [_vBody addSubview:vDepartment];
- _lblDepartment=[self getUILabel:vDepartment labelText:@"业务部门" hintText:@"" labelColor:[UIColor blackColor] isHaveRightArrow:NO tag:1002];
- _lblDepartment.text=_salesSlipModel.organizationName;
- _organizationId=_salesSlipModel.organizationId;
- _salesId=_salesSlipModel.salesId;
-
- UIView *vBusinessType=[UIView new];
- vBusinessType.frame=CGRectMake(0, CGRectGetMaxY(vDepartment.frame),Screen_Width, 51);
- [_vBody addSubview:vBusinessType];
-
- _lblBusinessType=[self getUILabel:vBusinessType labelText:@"业务类型" hintText:@"" labelColor:[UIColor blackColor] isHaveRightArrow:NO tag:1003];
- _lblBusinessType.text=_salesSlipModel.salesTypeName;
- UIView *vCustomerName=[UIView new];
- vCustomerName.frame=CGRectMake(0, CGRectGetMaxY(vBusinessType.frame),Screen_Width, 51);
- [_vBody addSubview:vCustomerName];
-
- _lblCustomerName=[self getUILabel:vCustomerName labelText:@"客户名称" hintText:@"" labelColor:[UIColor blackColor] isHaveRightArrow:NO tag:1004];
- _lblCustomerName.text=_salesSlipModel.customerName;
-
- UIView *vSalesMan=[UIView new];
- vSalesMan.frame=CGRectMake(0, CGRectGetMaxY(vCustomerName.frame),Screen_Width, 51);
- [_vBody addSubview:vSalesMan];
-
- _lblSalesMan=[self getUILabel:vSalesMan labelText:@"业 务 员" hintText:@"" labelColor:[UIColor blackColor] isHaveRightArrow:NO tag:1005];
- _lblSalesMan.text=_salesSlipModel.staffName;
- _salesmanId=_salesSlipModel.staffId;
- // UIView *vRemarks=[UIView new];
- // vRemarks.frame=CGRectMake(0, CGRectGetMaxY(vSalesMan.frame),Screen_Width, 51);
- // [_vBody addSubview:vRemarks];
- // _txtRemarks=[self getTextField:vRemarks labelText:@"备 注" hintText:@"请输入备注" labelColor:[UIColor blackColor] tag:1006];
- // _txtRemarks.enabled=NO;
-
- UILabel *lblTitleAmountInfo=[[UILabel alloc]init];
- lblTitleAmountInfo.frame=CGRectMake(15,CGRectGetMaxY(vSalesMan.frame)+16, 100, 25);
- lblTitleAmountInfo.text = @"金额信息";
- lblTitleAmountInfo.textColor=[UIColor redColor];
- lblTitleAmountInfo.font= [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [_vBody addSubview:lblTitleAmountInfo];
-
- UIView *separator2 = [UIView new];
- separator2.backgroundColor=LineBackgroundColor;
- separator2.frame=CGRectMake(0,CGRectGetMaxY(lblTitleAmountInfo.frame)+3,Screen_Width, 1);
- [_vBody addSubview:separator2];
-
-
- UIView *vAmountCollected=[UIView new];
- vAmountCollected.frame=CGRectMake(0, CGRectGetMaxY(separator2.frame),Screen_Width, 51);
- [_vBody addSubview:vAmountCollected];
- _txtAmountCollected=[self getTextField:vAmountCollected labelText:@"收款金额" hintText:@"请输入收款金额" labelColor:[UIColor redColor] tag:1007];
- _txtAmountCollected.keyboardType=UIKeyboardTypeDecimalPad;
- _txtAmountCollected.text=_salesSlipModel.finalReceivableAmount;
- UIView *vSettlementMethod=[UIView new];
- vSettlementMethod.frame=CGRectMake(0, CGRectGetMaxY(vAmountCollected.frame),Screen_Width, 51);
- [_vBody addSubview:vSettlementMethod];
- _lblSettlementMethod=[self getUILabel:vSettlementMethod labelText:@"结算方式" hintText:@"请选择结算方式" labelColor:[UIColor redColor] isHaveRightArrow:YES tag:1009];
-
- UITapGestureRecognizer *tapGesture=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(goSettlementMethod:)];
- [_lblSettlementMethod addGestureRecognizer:tapGesture];
- [tapGesture setNumberOfTapsRequired:1];
-
- UIView *vSubtractionPredeposit=[UIView new];
- vSubtractionPredeposit.frame=CGRectMake(0, CGRectGetMaxY(vSettlementMethod.frame),Screen_Width, 51);
- [_vBody addSubview:vSubtractionPredeposit];
- _lblSubtractionPredeposit=[self getUILabel:vSubtractionPredeposit labelText:@"冲减预存" hintText:@"请选择冲减预存" labelColor:[UIColor blackColor] isHaveRightArrow:YES tag:1010];
-
- UITapGestureRecognizer *tapGesture1=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(goSubtractionPredeposit:)];
- [_lblSubtractionPredeposit addGestureRecognizer:tapGesture1];
- [tapGesture1 setNumberOfTapsRequired:1];
-
- UIView *vAmountReceivable=[UIView new];
- vAmountReceivable.frame=CGRectMake(0, CGRectGetMaxY(vSubtractionPredeposit.frame),Screen_Width, 51);
- [_vBody addSubview:vAmountReceivable];
- _lblAmountReceivable=[self getUILabel:vAmountReceivable labelText:@"应收金额" hintText:@"" labelColor:[UIColor blackColor] isHaveRightArrow:NO tag:1008];
-
- _lblAmountReceivable.text=_salesSlipModel.accountReceivableAmount;
- UIView *vAmountReceived=[UIView new];
- vAmountReceived.frame=CGRectMake(0, CGRectGetMaxY(vAmountReceivable.frame),Screen_Width, 51);
- [_vBody addSubview:vAmountReceived];
- _lblAmountReceived=[self getUILabel:vAmountReceived labelText:@"已收金额" hintText:@"" labelColor:[UIColor blackColor] isHaveRightArrow:NO tag:1011];
- _lblAmountReceived.text=_salesSlipModel.receivablePayAmount;
- UIView *vCancellationAmount=[UIView new];
- vCancellationAmount.frame=CGRectMake(0, CGRectGetMaxY(vAmountReceived.frame),Screen_Width, 51);
- [_vBody addSubview:vCancellationAmount];
- _lblCancellationAmount=[self getUILabel:vCancellationAmount labelText:@"核销金额" hintText:@"" labelColor:[UIColor blackColor] isHaveRightArrow:NO tag:1012];
- _lblCancellationAmount.text=_salesSlipModel.verificationSum;
-
- UIView *vRemainderReceivables=[UIView new];
- vRemainderReceivables.frame=CGRectMake(0, CGRectGetMaxY(vCancellationAmount.frame),Screen_Width, 51);
- [_vBody addSubview:vRemainderReceivables];
-
- _lblRemainderReceivables=[self getUILabel:vRemainderReceivables labelText:@"剩余应收" hintText:@"" labelColor:[UIColor blackColor] isHaveRightArrow:NO tag:1013];
- _lblRemainderReceivables.text=_salesSlipModel.finalReceivableAmount;
-
- UIView *vAvailablePredeposit=[UIView new];
- vAvailablePredeposit.frame=CGRectMake(0, CGRectGetMaxY(vRemainderReceivables.frame),Screen_Width, 51);
- [_vBody addSubview:vAvailablePredeposit];
-
- _lblAvailablePredeposit=[self getUILabel:vAvailablePredeposit labelText:@"可用预存" hintText:@"" labelColor:[UIColor blackColor] isHaveRightArrow:NO tag:1014];
-
- UIImage *pic=[UIImage imageNamed:@"bt_datasave"];
- CGFloat h = (Screen_Width-40)*pic.size.height/pic.size.width;
- _vBody.frame=CGRectMake(0,0,Screen_Width, CGRectGetMaxY(vAvailablePredeposit.frame));
- _scrollView.contentSize = CGSizeMake(self.view.frame.size.width, CGRectGetMaxY(_vBody.frame)+rectStatusHeight+rectNavHeight+20);
- _scrollView.frame=CGRectMake(0,0, Screen_Width, Screen_Height-50);
- //保存按钮
- _btnSave=[UIButton buttonWithType:UIButtonTypeCustom];
- _btnSave.frame=CGRectMake(20, Screen_Height- h - 5 - rectStatusHeight-rectNavHeight, Screen_Width-40,h) ;
- [_btnSave setBackgroundImage:pic forState:UIControlStateNormal];
- [_btnSave addTarget:self action:@selector(dataSave) forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:_btnSave];
- }
- /**
- 保存函数
- */
- -(void)dataSave{
- NSString *businessTypeName= _lblBusinessType.text;
- NSString *remainderReceivable=_lblRemainderReceivables.text;
- NSString *amountReceivable=_lblAmountReceivable.text;
- NSString *amountReceived=_lblAmountReceived.text;
- NSString *verificationAmount=_lblCancellationAmount.text;
- if(remainderReceivable==nil||[remainderReceivable isEqualToString:@""]){
- [self showAlertViewText:@"剩余应收不能为空"];
- return;
- }
-
- NSString *amountCollected=_txtAmountCollected.text;
- if(amountCollected==nil||[amountCollected isEqualToString:@""]){
- [self showAlertViewText:@"收款金额不能为空"];
- return;
- }
-
- if(![RegularExpression isLegalAmount:amountCollected]){
- [self showAlertViewText:@"收款金额格式不正确"];
- return;
- }
-
- NSString *settlementMethod= _lblSettlementMethod.text;
- if(settlementMethod==nil||[settlementMethod isEqualToString:@""]){
- [self showAlertViewText:@"请选择结算方式"];
- return;
- }
- else if([settlementMethod isEqualToString:@"请选择结算方式"]){
- [self showAlertViewText:@"请选择结算方式"];
- return;
-
- }
-
- if([remainderReceivable doubleValue]<0){
- double remainderReceivableValue=[remainderReceivable doubleValue];
- double amountCollectedValue=[amountCollected doubleValue];
-
- if(amountCollectedValue>0){
- [self showAlertViewText:@"收款金额只能为负数"];
- return;
-
- }
- else{
- remainderReceivableValue=fabs([remainderReceivable doubleValue]);
- amountCollectedValue=fabs([amountCollected doubleValue]);
- if(amountCollectedValue>remainderReceivableValue){
- [self showAlertViewText:@"收款金额不能大于剩余应收"];
- return;
- }
- }
- }
- else{
- double remainderReceivableValue=[remainderReceivable doubleValue];
- double amountCollectedValue=[amountCollected doubleValue];
- if(amountCollectedValue>remainderReceivableValue){
- [self showAlertViewText:@"收款金额不能大于剩余应收"];
- return;
- }
-
- }
- NSString *useDeposit=_lblSubtractionPredeposit.text;
- if(useDeposit==nil||[useDeposit isEqualToString:@""]){
- useDeposit=@"0";
- }
- else if([useDeposit isEqualToString:@"请选择冲减预存"]){
- useDeposit=@"0";
- }
- [self startLoading];
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:@"SaveReceivablesPayIphone" forKey:@"Action"];
- [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
- [dict setObject:kkUserCode forKey:@"UserCode"];
- [dict setObject:kkUserPwd forKey:@"UserPassword"];
- [dict setObject:kkSessionKey forKey:@"SessionKey"];
- [dict setObject:businessTypeName forKey:@"SalesTypeName"];
- [dict setObject:_organizationId forKey:@"BusinessOrganization"];
- [dict setObject:_salesId forKey:@"InvoiceID"];
- [dict setObject:_customerId forKey:@"ObjectID"];
- [dict setObject:remainderReceivable forKey:@"LeftReceivable"];
- [dict setObject:_settlementTypeId forKey:@"SettlementType"];
- [dict setObject:amountCollected forKey:@"TotalPaySum"];
- [dict setObject:useDeposit forKey:@"UseDepositAmount"];
-
- NSMutableArray *useStorageArray=[[NSMutableArray alloc]init];
- NSString *useStorageValue=@"";
- if(_useStorageCheckedList != nil && _useStorageCheckedList.count > 0){
- for (UseStorageModel *model in _useStorageCheckedList) {
- if([model.earnestSum doubleValue]>0){
- NSDictionary *dic=[NSDictionary new];
- dic = @{@"SettlementType":model.settlementType,
- @"EarnestSum":model.earnestSum,
- @"Remarks":model.remarks==nil?@"":model.remarks,
- };
- [useStorageArray addObject: dic];
- }
- }
- SBJsonWriter *write =[[SBJsonWriter alloc] init];
- useStorageValue = [write stringWithObject:useStorageArray];
- [dict setObject:useStorageValue forKeyedSubscript:@"UseDepositDetail"];
- }
-
- NSMutableArray *receivablesPayDetailArray=[[NSMutableArray alloc]init];
- NSDictionary *receivablesPayDetailDic=[NSDictionary new];
-
- receivablesPayDetailDic = @{@"AccountDetailType":@"7",@"InvoiceID":_salesId,@"SalesMan":_salesmanId,@"AccountReceivableAmount":amountReceivable,@"ReceivablePayAmount":amountCollected,@"ReceivablePayedAmount":amountReceived,@"VerificationSum":verificationAmount,@"UseDeposit":useDeposit,@"Remarks":@""};
-
-
- [receivablesPayDetailArray addObject:receivablesPayDetailDic];
- SBJsonWriter *write =[[SBJsonWriter alloc] init];
- NSString *receivablesPayDetail = [write stringWithObject:receivablesPayDetailArray];
-
- [dict setObject:receivablesPayDetail forKeyedSubscript:@"ReceivablesPayDetail"];
-
- _downManager = [[ASIDownManager alloc] init];
- _downManager.delegate = self;
- _downManager.OnImageDown = @selector(onLoadFinish:);
- _downManager.OnImageFail = @selector(onLoadFail:);
- [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
- }
- /**
- 跳转到冲减预存
- @param gesture <#gesture description#>
- */
- -(void)goSubtractionPredeposit:(UITapGestureRecognizer *)gesture{
- if(_useStorageList==nil||_useStorageList.count==0){
- return;
- }
-
- if(_useStorageCheckedList==nil||_useStorageCheckedList.count==0){
- _useStorageCheckedList=_useStorageList;
- }
- UseStorageVC *vc = [[UseStorageVC alloc] init];
- vc.organizationID = _organizationId;
- vc.customerID = _customerId;
- vc.earnestList = _useStorageCheckedList;
- vc.useEarnestAmountDelegate = self;
- [self.navigationController pushViewController:vc animated:YES];
-
- }
- /**
- 使用定金
- */
- -(void)loadEarnestDataSource{
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:@"GetAccountPrestoreDataIphone" forKey:@"Action"];
- [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
- [dict setObject:kkUserCode forKey:@"UserCode"];
- [dict setObject:kkUserPwd forKey:@"UserPassword"];
- [dict setObject:kkSessionKey forKey:@"SessionKey"];
- [dict setObject:_organizationId==nil?@"":_organizationId forKey:@"OrganizationID"];
- [dict setObject:_customerId==nil?@"":_customerId forKey:@"CustomerID"];
- [dict setObject:@"" forKey:@"SalesID"];
-
- _downManager = [[ASIDownManager alloc] init];
- _downManager.delegate = self;
- _downManager.OnImageDown = @selector(onEarnestLoadFinish:);
- _downManager.OnImageFail = @selector(onEarnestLoadFail:);
- [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
- }
- /**
- 收款方式
- */
- -(void)loadSettlementMethodDataSource{
- [self startLoading];
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:@"GetReceivableWayIphone" forKey:@"Action"];
- [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
- [dict setObject:kkUserCode forKey:@"UserCode"];
- [dict setObject:kkUserPwd forKey:@"UserPassword"];
- [dict setObject:kkSessionKey forKey:@"SessionKey"];
-
- _downManager = [[ASIDownManager alloc] init];
- _downManager.delegate = self;
- _downManager.OnImageDown = @selector(onSettlementMethodLoadFinish:);
- _downManager.OnImageFail = @selector(onSettlementMethodLoadFail:);
- [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil];
- }
- /**
- 跳转到结算方式
- @param gesture <#gesture description#>
- */
- - (void)goSettlementMethod:(UITapGestureRecognizer *)gesture {
- if(_settlementMethodList==nil||_settlementMethodList.count==0){
- return;
- }
- SettlementMethodVC *vc = [[SettlementMethodVC alloc]init];
- vc.settlementMethodArray=_settlementMethodList;
- vc.settlementDelegate=self;
- [self.navigationController pushViewController:vc animated:YES];
- }
- /**
- 创建 UITextField
- */
- -(UITextField *)getTextField:(UIView*)v labelText:(NSString*)labelTitle hintText:(NSString*)hint labelColor:(UIColor*) color tag:(NSInteger) tag {
-
- UILabel *lblCustomer = [UILabel new];
- lblCustomer.frame=CGRectMake(15,16, 100, 25);
- lblCustomer.text = labelTitle;
- lblCustomer.textColor=color;
- lblCustomer.font= [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [v addSubview:lblCustomer];
- UITextField *txtCustomer = [UITextField new];
- txtCustomer.frame=CGRectMake(CGRectGetMaxX(lblCustomer.frame)+10,16, SCREENWIDTH-CGRectGetMaxX(lblCustomer.frame)-30, 25);
- txtCustomer.tag=tag;
- txtCustomer.delegate = self;
- txtCustomer.font=[UIFont systemFontOfSize: LabelAndTextFontOfSize];
- txtCustomer.placeholder = hint;
- [v addSubview:txtCustomer];
-
- UIView *separator = [UIView new];
- separator.backgroundColor=LineBackgroundColor;
- separator.frame=CGRectMake(CGRectGetMaxX(lblCustomer.frame)+10,CGRectGetMaxY(txtCustomer.frame)+10,Screen_Width-CGRectGetMaxX(lblCustomer.frame)+10, 1);
- [v addSubview:separator];
-
-
- return txtCustomer;
- }
- /**
- 创建UILabel
- */
- -(UILabel *)getUILabel:(UIView*)v labelText:(NSString*)labelTitle hintText:(NSString*)hint labelColor:(UIColor*) color isHaveRightArrow:(Boolean)rightArrowFlag tag:(NSInteger) tag{
-
- UILabel *lblTitleCustomer = [UILabel new];
- lblTitleCustomer.frame=CGRectMake(15,16, 100, 25);
- lblTitleCustomer.text = labelTitle;
- lblTitleCustomer.textColor=color;
- lblTitleCustomer.font= [UIFont systemFontOfSize: LabelAndTextFontOfSize];
- [v addSubview:lblTitleCustomer];
- UILabel *lblCustomer = [UILabel new];
- lblCustomer.frame=CGRectMake(CGRectGetMaxX(lblTitleCustomer.frame)+10,16, SCREENWIDTH-CGRectGetMaxX(lblTitleCustomer.frame)-30, 25);
- lblCustomer.font=[UIFont systemFontOfSize: LabelAndTextFontOfSize];
- lblCustomer.userInteractionEnabled=YES;
- lblCustomer.text=hint;
- lblCustomer.tag=tag;
-
- [v addSubview:lblCustomer];
-
- UIView *separator = [UIView new];
- separator.backgroundColor=LineBackgroundColor;
- separator.frame=CGRectMake(CGRectGetMaxX(lblTitleCustomer.frame)+10,CGRectGetMaxY(lblCustomer.frame)+10,Screen_Width-CGRectGetMaxX(lblTitleCustomer.frame)+10, 1);
- [v addSubview:separator];
- if(rightArrowFlag){
- UIButton *btnRightArrow = [UIButton buttonWithType:UIButtonTypeCustom];
- btnRightArrow.frame=CGRectMake(Screen_Width-50,10,32,30);
- UIImageView *rightArrowImg = [[UIImageView alloc]initWithFrame:CGRectMake(25,9,7, 12)];
- [rightArrowImg setImage:[UIImage imageNamed:@"rightarrow"]];
- [ btnRightArrow addSubview:rightArrowImg];
- rightArrowImg.userInteractionEnabled=NO;
- [v addSubview:btnRightArrow];
- }
- return lblCustomer;
- }
- /**
- 隐藏键盘
- */
- - (void)hideKey{
- [self.view endEditing:YES];
- }
- @end
|