Created
March 23, 2015 22:48
-
-
Save TechnotronicOz/047c1cd073274d5dd72b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func (me *AdjustmentState) AddUnmatchedAdjustmentsDetails(unmatchedAdjustments []Adjustment) error { | |
| /*unmatchedCount := int64(len(unmatchedAdjustments)) | |
| unmatchedSum := float64(0.0) | |
| for _, adjustment := range unmatchedAdjustments { | |
| unmatchedSum -= math.Abs(adjustment.Amount) | |
| } | |
| me.audit.unmatchedAdjustmentInvoiceAmount = number.RoundCurrency(unmatchedSum) | |
| me.audit.unmatchedAdjustmentInvoiceCount = unmatchedCount | |
| return nil*/ | |
| unmatchedCount, unmatchedSum := countAndSumAdustments(unmatchedAdjustments) | |
| me.audit.unmatchedAdjustmentInvoiceAmount = unmatchedSum | |
| me.audit.unmatchedAdjustmentInvoiceCount = unmatchedCount | |
| return nil | |
| } | |
| func (me *AdjustmentState) AddMatchedAdjustmentDetails(matchedAdjustments []AdjustmentInvoice) error { | |
| matchedCount := int64(len(matchedAdjustments)) | |
| matchedSum := float64(0.0) | |
| for _, adjustment := range matchedAdjustments { | |
| matchedSum -= math.Abs(adjustment.Amount) | |
| } | |
| me.audit.matchedAdjustmentInvoiceAmount = number.RoundCurrency(matchedSum) | |
| me.audit.matchedAdjustmentInvoiceCount = matchedCount | |
| return nil | |
| } | |
| func countAndSumAdustments(adjustments []Adjustment) (adjustmentCount int64, adjustmentAmount float64) { | |
| count := int64(len(adjustments)) | |
| sum := float64(0.0) | |
| for _, adjustment := range adjustments { | |
| sum -= math.Abs(adjustment.Amount) | |
| } | |
| sum = number.RoundCurrency(sum) | |
| return count, sum | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment