Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
X
xffruit
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张杰
xffruit
Commits
5fa396de
Commit
5fa396de
authored
7 years ago
by
Sandy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改金额计算精度问题
parent
b832e80a
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
339 additions
and
159 deletions
+339
-159
project.pbxproj
XFFruit.xcodeproj/project.pbxproj
+12
-12
CalculateHelper.m
XFFruit/General/CalculateHelper.m
+0
-114
CalculateHelper.h
XFFruit/General/Classes/CalculateHelper.h
+39
-2
CalculateHelper.m
XFFruit/General/Classes/CalculateHelper.m
+257
-0
NewPurchaseViewController.m
...trollers/Purchase/Controllers/NewPurchaseViewController.m
+3
-3
ShopDetaileViewController.m
...trollers/PurchaseNotice/Views/ShopDetaileViewController.m
+5
-5
NewReceiveProductViewController.m
...s/Receiving/Controllers/NewReceiveProductViewController.m
+17
-17
NewTransferViewController.m
...trollers/Transfer/Controllers/NewTransferViewController.m
+6
-6
No files found.
XFFruit.xcodeproj/project.pbxproj
View file @
5fa396de
This diff is collapsed.
Click to expand it.
XFFruit/General/CalculateHelper.m
deleted
100644 → 0
View file @
b832e80a
//
// CalculateHelper.m
// XFFruit
//
// Created by Z on 16/7/14.
// Copyright © 2016年 Xummer. All rights reserved.
//
#import "CalculateHelper.h"
@implementation
CalculateHelper
+
(
NSDecimalNumber
*
)
calculateNum1
:(
id
)
num1
num2
:(
id
)
num2
type
:(
CalculateType
)
type
roundingType
:(
NSRoundingMode
)
roundingType
cutLenth
:(
NSInteger
)
coutLenth
{
NSDecimalNumberHandler
*
roundUp
=
[
NSDecimalNumberHandler
decimalNumberHandlerWithRoundingMode
:
roundingType
scale
:
coutLenth
raiseOnExactness:
NO
raiseOnOverflow:
NO
raiseOnUnderflow:
NO
raiseOnDivideByZero:
YES
];
NSDecimalNumber
*
decimalNum1
=
[
self
changeType
:
num1
];
NSDecimalNumber
*
decimalNum2
=
[
self
changeType
:
num2
];
NSDecimalNumber
*
decimalResult
;
NSString
*
result
;
switch
(
type
)
{
case
CalculateTypeAdd
:
{
decimalResult
=
[
decimalNum1
decimalNumberByAdding
:
decimalNum2
withBehavior
:
roundUp
];
result
=
[
decimalResult
stringValue
];
break
;
}
case
CalculateTypeSub
:
{
decimalResult
=
[
decimalNum1
decimalNumberBySubtracting
:
decimalNum2
withBehavior
:
roundUp
];
result
=
[
decimalResult
stringValue
];
break
;
}
case
CalculateTypeMul
:
{
decimalResult
=
[
decimalNum1
decimalNumberByMultiplyingBy
:
decimalNum2
withBehavior
:
roundUp
];
result
=
[
decimalResult
stringValue
];
break
;
}
case
CalculateTypeDiv
:
{
decimalResult
=
[
decimalNum1
decimalNumberByDividingBy
:
decimalNum2
withBehavior
:
roundUp
];
result
=
[
decimalResult
stringValue
];
break
;
}
}
return
decimalResult
;
}
+
(
NSDecimalNumber
*
)
changeType
:(
id
)
num1
{
NSDecimalNumber
*
decimalNum1
;
if
([
num1
isKindOfClass
:[
NSDecimalNumber
class
]])
{
decimalNum1
=
num1
;
}
else
if
([
num1
isKindOfClass
:[
NSString
class
]]){
decimalNum1
=
[
NSDecimalNumber
decimalNumberWithString
:
num1
];
}
else
if
([
num1
isKindOfClass
:[
NSNumber
class
]]){
decimalNum1
=
[
NSDecimalNumber
decimalNumberWithDecimal
:[
num1
decimalValue
]];
}
else
if
(
num1
==
nil
){
decimalNum1
=
[
NSDecimalNumber
decimalNumberWithString
:
@"0"
];
}
return
decimalNum1
;
}
+
(
NSString
*
)
getMoneyStringFrom
:(
id
)
num
Lenth
:(
NSInteger
)
cutLenth
{
NSDecimalNumberHandler
*
roundUp
=
[
NSDecimalNumberHandler
decimalNumberHandlerWithRoundingMode
:
NSRoundBankers
scale
:
cutLenth
?
cutLenth
:
2
raiseOnExactness:
NO
raiseOnOverflow:
NO
raiseOnUnderflow:
NO
raiseOnDivideByZero:
YES
];
NSDecimalNumber
*
decimal
=
[
self
changeType
:
num
];
NSDecimalNumber
*
result
=
[
decimal
decimalNumberByAdding
:[
NSDecimalNumber
decimalNumberWithString
:
@"0"
]
withBehavior
:
roundUp
];
return
[
result
stringValue
];
}
+
(
NSString
*
)
getMoneyStringFrom
:(
id
)
num
{
NSString
*
originString
=
[
self
getMoneyStringFrom
:
num
Lenth
:
2
];
NSArray
*
array
=
[
originString
componentsSeparatedByString
:
@"."
];
NSString
*
top
=
array
[
0
];
NSString
*
result
;
if
(
array
.
count
==
1
)
{
result
=
[
NSString
stringWithFormat
:
@"%@.00"
,
top
];
}
else
if
(
array
.
count
==
2
){
NSString
*
bottom
=
array
[
1
];
if
(
bottom
.
length
==
2
)
{
result
=
originString
;
}
NSString
*
chr
;
for
(
NSInteger
i
=
bottom
.
length
;
i
<
2
;
i
++
)
{
chr
=
[
bottom
substringWithRange
:
NSMakeRange
(
i
,
1
)];
if
([
chr
isEqualToString
:
@"0"
])
{
result
=
[
top
stringByAppendingString
:
chr
];
}
}
}
return
result
;
}
@end
This diff is collapsed.
Click to expand it.
XFFruit/General/CalculateHelper.h
→
XFFruit/General/C
lasses/C
alculateHelper.h
View file @
5fa396de
...
@@ -17,8 +17,11 @@ typedef NS_ENUM(NSInteger, CalculateType) {
...
@@ -17,8 +17,11 @@ typedef NS_ENUM(NSInteger, CalculateType) {
/*
/*
NSRoundPlain, // Round up on a tie //貌似取整
NSRoundPlain, // Round up on a tie //貌似取整
NSRoundDown, // Always down == truncate //只舍不入
NSRoundDown, // Always down == truncate //只舍不入
NSRoundUp, // Always up // 只入不舍
NSRoundUp, // Always up // 只入不舍
NSRoundBankers // on a tie round so last digit is even 貌似四舍五入
NSRoundBankers // on a tie round so last digit is even 貌似四舍五入
*/
*/
/**
/**
...
@@ -33,7 +36,41 @@ typedef NS_ENUM(NSInteger, CalculateType) {
...
@@ -33,7 +36,41 @@ typedef NS_ENUM(NSInteger, CalculateType) {
* @return 结算结果
* @return 结算结果
*/
*/
+
(
NSDecimalNumber
*
)
calculateNum1
:(
id
)
num1
num2
:(
id
)
num2
type
:(
CalculateType
)
type
roundingType
:(
NSRoundingMode
)
roundingType
cutLenth
:(
NSInteger
)
coutLenth
;
+
(
NSDecimalNumber
*
)
calculateNum1
:(
id
)
num1
num2
:(
id
)
num2
type
:(
CalculateType
)
type
roundingType
:(
NSRoundingMode
)
roundingType
cutLenth
:(
NSInteger
)
coutLenth
;
+
(
NSString
*
)
getMoneyStringFrom
:(
id
)
num
Lenth
:(
NSInteger
)
cutLenth
;
+
(
NSDecimalNumber
*
)
calculateNum1
:(
id
)
num1
num2
:(
id
)
num2
type
:(
CalculateType
)
type
;
/** add */
+
(
NSDecimalNumber
*
)
add
:(
id
)
num1
num2
:(
id
)
num2
;
/** sub */
+
(
NSDecimalNumber
*
)
sub
:(
id
)
num1
num2
:(
id
)
num2
;
/** mul */
+
(
NSDecimalNumber
*
)
mul
:(
id
)
num1
num2
:(
id
)
num2
;
/** div */
+
(
NSDecimalNumber
*
)
div
:(
id
)
num1
num2
:(
id
)
num2
;
/** 一百倍 */
+
(
NSDecimalNumber
*
)
oneHundredTimes
:(
id
)
num
;
/** 计算百分比 */
+
(
NSString
*
)
getPercent
:(
id
)
num1
num
:(
id
)
num2
;
/** 获取金额 保留两位小数*/
+
(
NSString
*
)
getMoneyStringFrom
:(
id
)
num
;
+
(
NSString
*
)
getMoneyStringFrom
:(
id
)
num
;
+
(
NSDecimalNumber
*
)
changeType
:(
id
)
num1
;
/** 获取金额 */
+
(
NSString
*
)
getMoneyStringFrom
:(
id
)
num
Lenth
:(
NSInteger
)
cutLenth
isSeparate
:(
BOOL
)
isSeparate
;
+
(
NSString
*
)
getMoneyStringFromString
:(
NSString
*
)
originString
;
//获得绝对值
+
(
NSString
*
)
getABSValue
:(
NSString
*
)
string
;
/** 每3位加逗号 */
+
(
NSString
*
)
separateMoney
:(
id
)
num
;
/** 把非decimalNumber转化 */
+
(
NSDecimalNumber
*
)
decimalNumber
:(
id
)
number
;
/**
* 判断数字是否在给定的范围内,num1和num2的顺序不影响判断
*
* @param num 需要判断的数字
* @param num1 范围区间
* @param num2 范围区间
*
* @return 是否在区间内
*/
+
(
BOOL
)
number
:(
id
)
num
isInNum1
:(
id
)
num1
num2
:(
id
)
num2
;
@end
@end
This diff is collapsed.
Click to expand it.
XFFruit/General/Classes/CalculateHelper.m
0 → 100644
View file @
5fa396de
//
// CalculateHelper.m
// XFFruit
//
// Created by Z on 16/7/14.
// Copyright © 2016年 Xummer. All rights reserved.
//
#import "CalculateHelper.h"
@implementation
CalculateHelper
+
(
NSDecimalNumber
*
)
calculateNum1
:(
id
)
num1
num2
:(
id
)
num2
type
:(
CalculateType
)
type
roundingType
:(
NSRoundingMode
)
roundingType
cutLenth
:(
NSInteger
)
coutLenth
{
NSDecimalNumberHandler
*
roundUp
=
[
NSDecimalNumberHandler
decimalNumberHandlerWithRoundingMode
:
roundingType
scale
:
coutLenth
raiseOnExactness
:
NO
raiseOnOverflow
:
NO
raiseOnUnderflow
:
NO
raiseOnDivideByZero
:
YES
];
NSDecimalNumber
*
decimalNum1
=
[
self
changeType
:
num1
];
NSDecimalNumber
*
decimalNum2
=
[
self
changeType
:
num2
];
if
(
decimalNum1
==
nil
||
decimalNum2
==
nil
)
{
return
nil
;
}
NSDecimalNumber
*
decimalResult
;
NSString
*
result
;
switch
(
type
)
{
case
CalculateTypeAdd
:
{
decimalResult
=
[
decimalNum1
decimalNumberByAdding
:
decimalNum2
withBehavior
:
roundUp
];
result
=
[
decimalResult
stringValue
];
break
;
}
case
CalculateTypeSub
:
{
decimalResult
=
[
decimalNum1
decimalNumberBySubtracting
:
decimalNum2
withBehavior
:
roundUp
];
result
=
[
decimalResult
stringValue
];
break
;
}
case
CalculateTypeMul
:
{
decimalResult
=
[
decimalNum1
decimalNumberByMultiplyingBy
:
decimalNum2
withBehavior
:
roundUp
];
result
=
[
decimalResult
stringValue
];
break
;
}
case
CalculateTypeDiv
:
{
if
([
decimalNum2
isEqualToNumber
:
@0
])
{
decimalResult
=
[
NSDecimalNumber
decimalNumberWithString
:
@"0"
];
}
else
{
decimalResult
=
[
decimalNum1
decimalNumberByDividingBy
:
decimalNum2
withBehavior
:
roundUp
];
result
=
[
decimalResult
stringValue
];
}
break
;
}
}
return
decimalResult
;
}
+
(
NSDecimalNumber
*
)
calculateNum1
:(
id
)
num1
num2
:(
id
)
num2
type
:(
CalculateType
)
type
{
NSDecimalNumber
*
decimalNum1
=
[
self
changeType
:
num1
];
NSDecimalNumber
*
decimalNum2
=
[
self
changeType
:
num2
];
if
(
decimalNum1
==
nil
||
decimalNum2
==
nil
)
{
return
nil
;
}
NSDecimalNumber
*
decimalResult
;
NSString
*
result
;
switch
(
type
)
{
case
CalculateTypeAdd
:
{
decimalResult
=
[
decimalNum1
decimalNumberByAdding
:
decimalNum2
];
result
=
[
decimalResult
stringValue
];
break
;
}
case
CalculateTypeSub
:
{
decimalResult
=
[
decimalNum1
decimalNumberBySubtracting
:
decimalNum2
];
result
=
[
decimalResult
stringValue
];
break
;
}
case
CalculateTypeMul
:
{
decimalResult
=
[
decimalNum1
decimalNumberByMultiplyingBy
:
decimalNum2
];
result
=
[
decimalResult
stringValue
];
break
;
}
case
CalculateTypeDiv
:
{
if
([
decimalNum2
isEqualToNumber
:
@0
])
{
decimalResult
=
[
NSDecimalNumber
decimalNumberWithString
:
@"0"
];
}
else
{
decimalResult
=
[
decimalNum1
decimalNumberByDividingBy
:
decimalNum2
];
result
=
[
decimalResult
stringValue
];
}
break
;
}
}
return
decimalResult
;
}
//把传入的类型变成NSDecimalNumber
+
(
NSDecimalNumber
*
)
changeType
:(
id
)
num1
{
NSDecimalNumber
*
decimalNum1
;
if
([
num1
isKindOfClass
:[
NSDecimalNumber
class
]])
{
decimalNum1
=
num1
;
}
else
if
([
num1
isKindOfClass
:[
NSString
class
]])
{
if
([
num1
isEqualToString
:
@""
])
{
decimalNum1
=
[
NSDecimalNumber
decimalNumberWithString
:
@"0"
];
}
else
{
decimalNum1
=
[
NSDecimalNumber
decimalNumberWithString
:
num1
];
}
}
else
if
([
num1
isKindOfClass
:[
NSNumber
class
]])
{
decimalNum1
=
[
NSDecimalNumber
decimalNumberWithDecimal
:[
num1
decimalValue
]];
}
else
if
(
num1
==
nil
)
{
decimalNum1
=
[
NSDecimalNumber
decimalNumberWithString
:
@"0"
];
}
else
{
decimalNum1
=
[
NSDecimalNumber
decimalNumberWithString
:
@"0"
];
}
return
decimalNum1
;
}
+
(
NSDecimalNumber
*
)
decimalNumber
:(
id
)
number
{
return
[
self
changeType
:
number
];
}
+
(
NSDecimalNumber
*
)
oneHundredTimes
:(
id
)
num
{
return
[
self
calculateNum1
:
num
num2
:
@100
type
:
CalculateTypeMul
roundingType
:
NSRoundPlain
cutLenth
:
10
];
}
+
(
NSString
*
)
getPercent
:(
id
)
num1
num
:(
id
)
num2
{
[
self
calculateNum1
:
num1
num2
:
num1
type
:
CalculateTypeDiv
roundingType
:
NSRoundPlain
cutLenth
:
4
];
NSDecimalNumber
*
result
=
[
self
oneHundredTimes
:[
self
calculateNum1
:
num1
num2
:
num2
type
:
CalculateTypeDiv
roundingType
:
NSRoundPlain
cutLenth
:
4
]];
return
[
NSString
stringWithFormat
:
@"%@%%"
,
[
self
getMoneyStringFromString
:
result
.
stringValue
]];
}
+
(
NSString
*
)
getMoneyStringFrom
:(
id
)
num
Lenth
:(
NSInteger
)
cutLenth
isSeparate
:(
BOOL
)
isSeparate
{
NSDecimalNumberHandler
*
roundUp
=
[
NSDecimalNumberHandler
decimalNumberHandlerWithRoundingMode
:
NSRoundPlain
scale
:
cutLenth
raiseOnExactness:
NO
raiseOnOverflow:
NO
raiseOnUnderflow:
NO
raiseOnDivideByZero:
YES
];
NSDecimalNumber
*
decimal
=
[
self
changeType
:
num
];
NSDecimalNumber
*
result
=
[
decimal
decimalNumberByAdding
:[
NSDecimalNumber
decimalNumberWithString
:
@"0"
]
withBehavior
:
roundUp
];
NSString
*
rs
=
nil
;
if
(
isSeparate
)
{
rs
=
[
self
separateMoney
:
result
];
}
else
{
rs
=
[
result
stringValue
];
}
NSArray
*
array
=
[
rs
componentsSeparatedByString
:
@"."
];
NSString
*
top
=
[
array
[
0
]
stringByAppendingString
:
@"."
];
NSString
*
finalResult
=
array
[
0
];
if
(
array
.
count
==
1
)
{
if
(
cutLenth
>
0
)
{
finalResult
=
top
;
for
(
NSInteger
i
=
0
;
i
<
cutLenth
;
i
++
)
{
finalResult
=
[
finalResult
stringByAppendingString
:
@"0"
];
}
}
}
else
{
finalResult
=
rs
;
NSString
*
bottom
=
array
[
1
];
for
(
NSInteger
i
=
bottom
.
length
;
i
<
cutLenth
;
i
++
)
{
finalResult
=
[
finalResult
stringByAppendingString
:
@"0"
];
}
}
return
finalResult
;
}
+
(
NSString
*
)
getMoneyStringFrom
:(
id
)
num
{
NSString
*
originString
=
[
self
getMoneyStringFrom
:
num
Lenth
:
2
isSeparate
:
NO
];
return
[
self
getMoneyStringFromString
:
originString
];
}
+
(
NSString
*
)
getMoneyStringFromString
:(
NSString
*
)
originString
{
NSArray
*
array
=
[
originString
componentsSeparatedByString
:
@"."
];
NSString
*
top
=
[
array
[
0
]
stringByAppendingString
:
@"."
];
NSString
*
result
;
if
(
array
.
count
==
1
)
{
result
=
[
NSString
stringWithFormat
:
@"%@00"
,
top
];
}
else
if
(
array
.
count
==
2
)
{
NSString
*
bottom
=
array
[
1
];
if
(
bottom
.
length
==
2
)
{
result
=
originString
;
}
for
(
NSInteger
i
=
bottom
.
length
;
i
<
2
;
i
++
)
{
result
=
[
originString
stringByAppendingString
:
@"0"
];
}
}
return
result
;
}
+
(
NSString
*
)
getABSValue
:(
NSString
*
)
string
{
if
([
string
hasPrefix
:
@"-"
]
&&
!
[
string
hasPrefix
:
@"--"
])
{
NSString
*
absString
=
[
string
substringWithRange
:
NSMakeRange
(
1
,
string
.
length
-
1
)];
return
absString
;
}
else
{
return
string
;
}
}
+
(
NSString
*
)
separateMoney
:(
id
)
num1
{
NSDecimalNumber
*
num
=
[
self
changeType
:
num1
];
NSNumberFormatter
*
numberFormatter
=
[[
NSNumberFormatter
alloc
]
init
];
numberFormatter
.
locale
=
[
NSLocale
currentLocale
];
// this ensure the right separator behavior
numberFormatter
.
numberStyle
=
NSNumberFormatterDecimalStyle
;
numberFormatter
.
usesGroupingSeparator
=
YES
;
// example for writing the number object into a label
NSString
*
string
=
[
numberFormatter
stringFromNumber
:
num
];
return
string
;
}
/** add */
+
(
NSDecimalNumber
*
)
add
:(
id
)
num1
num2
:(
id
)
num2
{
return
[
self
calculateNum1
:
num1
num2
:
num2
type
:
CalculateTypeAdd
];
}
/** sub */
+
(
NSDecimalNumber
*
)
sub
:(
id
)
num1
num2
:(
id
)
num2
{
return
[
self
calculateNum1
:
num1
num2
:
num2
type
:
CalculateTypeSub
];
}
/** mul */
+
(
NSDecimalNumber
*
)
mul
:(
id
)
num1
num2
:(
id
)
num2
{
return
[
self
calculateNum1
:
num1
num2
:
num2
type
:
CalculateTypeMul
];
}
/** div */
+
(
NSDecimalNumber
*
)
div
:(
id
)
num1
num2
:(
id
)
num2
{
return
[
self
calculateNum1
:
num1
num2
:
num2
type
:
CalculateTypeDiv
];
}
+
(
BOOL
)
number
:(
id
)
num
isInNum1
:(
id
)
num1
num2
:(
id
)
num2
{
NSDecimalNumber
*
decNum
=
[
self
decimalNumber
:
num
];
NSDecimalNumber
*
minNumber
;
NSDecimalNumber
*
maxNumber
;
NSDecimalNumber
*
decNumber1
=
[
self
decimalNumber
:
num1
];
NSDecimalNumber
*
decNumber2
=
[
self
decimalNumber
:
num2
];
NSComparisonResult
result
=
[
decNumber1
compare
:
decNumber2
];
if
(
result
==
NSOrderedAscending
)
{
minNumber
=
decNumber1
;
maxNumber
=
decNumber2
;
}
else
{
minNumber
=
decNumber2
;
maxNumber
=
decNumber1
;
}
if
(([
decNum
compare
:
minNumber
]
==
NSOrderedDescending
&&
[
decNum
compare
:
maxNumber
]
==
NSOrderedAscending
)
||
[
decNum
compare
:
minNumber
]
==
NSOrderedSame
||
[
decNum
compare
:
maxNumber
]
==
NSOrderedSame
)
{
return
YES
;
}
else
{
return
NO
;
}
}
@end
This diff is collapsed.
Click to expand it.
XFFruit/ViewControllers/Purchase/Controllers/NewPurchaseViewController.m
View file @
5fa396de
...
@@ -488,11 +488,11 @@ typedef enum : NSUInteger {
...
@@ -488,11 +488,11 @@ typedef enum : NSUInteger {
shopDetail
.
product_uuid
=
billProduct
.
product_uuid
;
shopDetail
.
product_uuid
=
billProduct
.
product_uuid
;
shopDetail
.
product_code
=
billProduct
.
product_code
;
shopDetail
.
product_code
=
billProduct
.
product_code
;
shopDetail
.
merchandise
=
billProduct
.
product_name
;
shopDetail
.
merchandise
=
billProduct
.
product_name
;
shopDetail
.
packageSpecification
=
[
CalculateHelper
getMoneyStringFrom
:
billProduct
.
qpc
Lenth
:
0
];
shopDetail
.
packageSpecification
=
[
CalculateHelper
getMoneyStringFrom
:
billProduct
.
qpc
Lenth
:
0
isSeparate
:
NO
];
shopDetail
.
packageUnit
=
billProduct
.
unit
;
shopDetail
.
packageUnit
=
billProduct
.
unit
;
shopDetail
.
packageQuantity
=
[
CalculateHelper
getMoneyStringFrom
:
billProduct
.
qty
Lenth
:
0
];
shopDetail
.
packageQuantity
=
[
CalculateHelper
getMoneyStringFrom
:
billProduct
.
qty
Lenth
:
0
isSeparate
:
NO
];
shopDetail
.
packageUnitPrice
=
billProduct
.
price
;
shopDetail
.
packageUnitPrice
=
billProduct
.
price
;
shopDetail
.
foundationQuantity
=
[
CalculateHelper
getMoneyStringFrom
:
billProduct
.
baseQty
Lenth
:
0
];
shopDetail
.
foundationQuantity
=
[
CalculateHelper
getMoneyStringFrom
:
billProduct
.
baseQty
Lenth
:
0
isSeparate
:
NO
];
shopDetail
.
foundationUnitPrice
=
billProduct
.
basePrice
;
shopDetail
.
foundationUnitPrice
=
billProduct
.
basePrice
;
shopDetail
.
totalMoney
=
billProduct
.
total
;
shopDetail
.
totalMoney
=
billProduct
.
total
;
shopDetail
.
remark
=
billProduct
.
remark
;
shopDetail
.
remark
=
billProduct
.
remark
;
...
...
This diff is collapsed.
Click to expand it.
XFFruit/ViewControllers/PurchaseNotice/Views/ShopDetaileViewController.m
View file @
5fa396de
...
@@ -251,7 +251,7 @@ typedef enum : NSUInteger {
...
@@ -251,7 +251,7 @@ typedef enum : NSUInteger {
[
model
setValuesForKeysWithDictionary
:
dict
];
[
model
setValuesForKeysWithDictionary
:
dict
];
if
([
self
.
shopDetail
.
product_code
isEqualToString
:
model
.
productCode
])
{
if
([
self
.
shopDetail
.
product_code
isEqualToString
:
model
.
productCode
])
{
if
([[
CalculateHelper
changeType
:
self
.
shopDetail
.
foundationQuantity
]
compare
:
decimalNumberWithDouble
(
model
.
qty
)]
==
NSOrderedDescending
)
{
if
([[
CalculateHelper
decimalNumber
:
self
.
shopDetail
.
foundationQuantity
]
compare
:
decimalNumberWithDouble
(
model
.
qty
)]
==
NSOrderedDescending
)
{
CLog
(
@"库存不足"
);
CLog
(
@"库存不足"
);
NSString
*
msg
=
[
NSString
stringWithFormat
:
@"采购单<%@>在总部系统的库存不足!"
,
billNumber
];
NSString
*
msg
=
[
NSString
stringWithFormat
:
@"采购单<%@>在总部系统的库存不足!"
,
billNumber
];
ShowMessage
(
msg
);
ShowMessage
(
msg
);
...
@@ -661,19 +661,19 @@ typedef enum : NSUInteger {
...
@@ -661,19 +661,19 @@ typedef enum : NSUInteger {
}
}
}
else
if
(
textField
==
foundationUnitPrice
){
}
else
if
(
textField
==
foundationUnitPrice
){
//基础单价
//基础单价
self
.
basePrice
=
[
NSNumber
numberWithFloat
:
foundationUnitPrice
.
text
.
floatValue
];
self
.
basePrice
=
[
CalculateHelper
decimalNumber
:
foundationUnitPrice
.
text
];
[
self
setPacktAndTotalPrice
];
[
self
setPacktAndTotalPrice
];
//如果基础数量和包装数量有的话计算出包装单价和和总价
//如果基础数量和包装数量有的话计算出包装单价和和总价
}
else
if
(
textField
==
packageUnitPrice
){
}
else
if
(
textField
==
packageUnitPrice
){
//包装单价
//包装单价
self
.
packPrice
=
[
NSNumber
numberWithFloat
:
packageUnitPrice
.
text
.
floatValue
];
self
.
packPrice
=
[
CalculateHelper
decimalNumber
:
packageUnitPrice
.
text
];
[
self
setUnitAndTotalPrice
];
[
self
setUnitAndTotalPrice
];
}
else
if
(
textField
==
totalMoney
){
}
else
if
(
textField
==
totalMoney
){
//总金额
//总金额
self
.
totalPrice
=
[
NSNumber
numberWithFloat
:
totalMoney
.
text
.
floatValue
];
self
.
totalPrice
=
[
CalculateHelper
decimalNumber
:
totalMoney
.
text
];
[
self
setUnitAndPackPrice
];
[
self
setUnitAndPackPrice
];
}
else
if
(
textField
==
_checkPriceTextField
){
}
else
if
(
textField
==
_checkPriceTextField
){
self
.
checkPrice
=
[
CalculateHelper
changeType
:
_checkPriceTextField
.
text
];
self
.
checkPrice
=
[
CalculateHelper
decimalNumber
:
_checkPriceTextField
.
text
];
self
.
checkTotal
=
[
CalculateHelper
calculateNum1
:
_checkPriceTextField
.
text
num2
:
foundationQuantity
.
text
type
:
CalculateTypeMul
roundingType
:
NSRoundBankers
cutLenth
:
2
];
self
.
checkTotal
=
[
CalculateHelper
calculateNum1
:
_checkPriceTextField
.
text
num2
:
foundationQuantity
.
text
type
:
CalculateTypeMul
roundingType
:
NSRoundBankers
cutLenth
:
2
];
_checkTotalTextField
.
text
=
self
.
checkTotal
.
stringValue
;
_checkTotalTextField
.
text
=
self
.
checkTotal
.
stringValue
;
...
...
This diff is collapsed.
Click to expand it.
XFFruit/ViewControllers/Receiving/Controllers/NewReceiveProductViewController.m
View file @
5fa396de
...
@@ -302,37 +302,37 @@
...
@@ -302,37 +302,37 @@
if
(
textField
==
_shPackField
)
{
if
(
textField
==
_shPackField
)
{
if
(
_shPackField
.
text
.
length
>
0
)
{
if
(
_shPackField
.
text
.
length
>
0
)
{
//基础数量【实收】= 包装数量【实收】* 规格
//基础数量【实收】= 包装数量【实收】* 规格
// NSDecimalNumber *baseCount = [
NSDecimalNumber
*
baseCount
=
[
CalculateHelper
mul
:
_shPackField
.
text
num2
:
self
.
noticeProduct
.
qpc
];
float
baseCount
=
[
_shPackField
.
text
floatValue
]
*
[
self
.
noticeProduct
.
qpc
floatValue
];
_shBaseQuantityField
.
text
=
[
NSString
stringWithFormat
:
@"%.2f"
,
baseCount
.
doubleValue
];
_shBaseQuantityField
.
text
=
[
NSString
stringWithFormat
:
@"%.2f"
,
baseCount
];
//总金额【实收】= 基础数量【实收】* 基础单价
//总金额【实收】= 基础数量【实收】* 基础单价
float
total
=
0
;
NSDecimalNumber
*
total
=
[
CalculateHelper
decimalNumber
:
@0
]
;
if
([
_shPackField
.
text
floatValue
]
==
[
self
.
noticeProduct
.
qty
floatValue
])
{
if
([
_shPackField
.
text
floatValue
]
==
[
self
.
noticeProduct
.
qty
floatValue
])
{
total
=
[
self
.
noticeProduct
.
total
floatValue
];
total
=
[
CalculateHelper
decimalNumber
:
self
.
noticeProduct
.
total
];
}
else
{
}
else
{
total
=
baseCount
*
[
self
.
noticeProduct
.
price
floatValu
e
];
total
=
[
CalculateHelper
mul
:
baseCount
num2
:
self
.
noticeProduct
.
pric
e
];
}
}
_chooseTotalPriceLabel
.
text
=
[
NSString
stringWithFormat
:
@"%.2f元"
,
total
];
_chooseTotalPriceLabel
.
text
=
[
NSString
stringWithFormat
:
@"%.2f元"
,
total
.
doubleValue
];
self
.
noticeProduct
.
rctTotal
=
[
NSNumber
numberWithFloat
:
total
]
;
self
.
noticeProduct
.
rctTotal
=
total
;
}
}
}
else
if
(
textField
==
_shBaseQuantityField
)
{
}
else
if
(
textField
==
_shBaseQuantityField
)
{
if
(
_shBaseQuantityField
.
text
.
length
>
0
)
{
if
(
_shBaseQuantityField
.
text
.
length
>
0
)
{
// 包装数量【实收】= 基础数量【实收】/ 规格
// 包装数量【实收】= 基础数量【实收】/ 规格
float
baseCount
=
0
;
// float baseCount = 0;
NSDecimalNumber
*
baseCount
=
[
NSDecimalNumber
decimalNumberWithString
:
@0
];
if
([
self
.
noticeProduct
.
qpc
floatValue
]
>
0
)
{
if
([
self
.
noticeProduct
.
qpc
floatValue
]
>
0
)
{
baseCount
=
[
_shBaseQuantityField
.
text
floatValue
]
/
[
self
.
noticeProduct
.
qpc
floatValue
];
baseCount
=
[
CalculateHelper
div
:
_shBaseQuantityField
.
text
num2
:
self
.
noticeProduct
.
qpc
];
}
}
_shPackField
.
text
=
[
NSString
stringWithFormat
:
@"%.2f"
,
baseCount
];
_shPackField
.
text
=
[
NSString
stringWithFormat
:
@"%.2f"
,
baseCount
.
doubleValue
];
float
total
=
0
;
NSDecimalNumber
*
total
=
[
CalculateHelper
decimalNumber
:
@0
];
// float total = 0;
if
([
_shPackField
.
text
floatValue
]
==
[
self
.
noticeProduct
.
qty
floatValue
])
{
if
([
_shPackField
.
text
floatValue
]
==
[
self
.
noticeProduct
.
qty
floatValue
])
{
total
=
[
self
.
noticeProduct
.
total
floatValue
];
total
=
[
CalculateHelper
decimalNumber
:
self
.
noticeProduct
.
total
];
}
else
{
}
else
{
total
=
baseCount
*
[
self
.
noticeProduct
.
price
floatValu
e
];
total
=
[
CalculateHelper
mul
:
baseCount
num2
:
self
.
noticeProduct
.
pric
e
];
}
}
_chooseTotalPriceLabel
.
text
=
[
NSString
stringWithFormat
:
@"%.2f元"
,
total
];
_chooseTotalPriceLabel
.
text
=
[
NSString
stringWithFormat
:
@"%.2f元"
,
total
.
doubleValue
];
self
.
noticeProduct
.
rctTotal
=
[
NSNumber
numberWithFloat
:
total
]
;
self
.
noticeProduct
.
rctTotal
=
total
;
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
XFFruit/ViewControllers/Transfer/Controllers/NewTransferViewController.m
View file @
5fa396de
...
@@ -513,13 +513,13 @@ typedef enum : NSUInteger {
...
@@ -513,13 +513,13 @@ typedef enum : NSUInteger {
billProduct
.
productUuid
=
shopDetail
.
product_uuid
;
billProduct
.
productUuid
=
shopDetail
.
product_uuid
;
billProduct
.
productCode
=
shopDetail
.
product_code
;
billProduct
.
productCode
=
shopDetail
.
product_code
;
billProduct
.
productName
=
shopDetail
.
merchandise
;
billProduct
.
productName
=
shopDetail
.
merchandise
;
billProduct
.
qpc
=
[
NSNumber
numberWithFloat
:[
shopDetail
.
packageSpecification
floatValue
]
];
billProduct
.
qpc
=
[
CalculateHelper
decimalNumber
:
shopDetail
.
packageSpecification
];
billProduct
.
unit
=
shopDetail
.
packageUnit
;
billProduct
.
unit
=
shopDetail
.
packageUnit
;
billProduct
.
qty
=
[
NSNumber
numberWithFloat
:[
shopDetail
.
packageQuantity
floatValue
]
];
billProduct
.
qty
=
[
CalculateHelper
decimalNumber
:
shopDetail
.
packageQuantity
];
billProduct
.
packprice
=
[
NSNumber
numberWithFloat
:[
shopDetail
.
packageUnitPrice
floatValue
]
];
billProduct
.
packprice
=
[
CalculateHelper
decimalNumber
:
shopDetail
.
packageUnitPrice
];
billProduct
.
price
=
[
NSNumber
numberWithFloat
:[
shopDetail
.
foundationUnitPrice
floatValue
]
];
billProduct
.
price
=
[
CalculateHelper
decimalNumber
:
shopDetail
.
foundationUnitPrice
];
billProduct
.
baseQty
=
[
NSNumber
numberWithFloat
:[
shopDetail
.
foundationQuantity
floatValue
]
];
billProduct
.
baseQty
=
[
CalculateHelper
decimalNumber
:
shopDetail
.
foundationQuantity
];
billProduct
.
total
=
[
NSNumber
numberWithFloat
:[
shopDetail
.
totalMoney
floatValue
]
];
billProduct
.
total
=
[
CalculateHelper
decimalNumber
:
shopDetail
.
totalMoney
];
billProduct
.
note
=
shopDetail
.
remark
;
billProduct
.
note
=
shopDetail
.
remark
;
billProduct
.
qpcStr
=
shopDetail
.
packageQpcStr
?
shopDetail
.
packageQpcStr
:
@"无"
;
billProduct
.
qpcStr
=
shopDetail
.
packageQpcStr
?
shopDetail
.
packageQpcStr
:
@"无"
;
billProduct
.
baseUnit
=
shopDetail
.
packageQpcUnit
;
billProduct
.
baseUnit
=
shopDetail
.
packageQpcUnit
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment