Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wiaflos
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wiaflos
wiaflos
Commits
6895f4b3
Commit
6895f4b3
authored
Nov 28, 2016
by
Nigel Kukard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reworked tax mode usage and error checking
parent
789b0608
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
18 deletions
+21
-18
Purchasing.pm
wiaflos/server/core/Purchasing.pm
+8
-7
SupplierCreditNotes.pm
wiaflos/server/core/SupplierCreditNotes.pm
+13
-11
No files found.
wiaflos/server/core/Purchasing.pm
View file @
6895f4b3
...
...
@@ -751,16 +751,16 @@ sub linkSupplierInvoiceItem
# Get ready for calculating tax
my
(
$taxAmount
,
$taxMode
)
=
wiaflos::server::core::Tax::
getTaxAmount
(
$detail
->
{
'TaxMode'
},
$taxRate
,
$totalPrice
);
if
(
!
defined
(
$taxMode
))
{
if
(
!
defined
(
$tax
Amount
)
||
!
defined
(
$tax
Mode
))
{
setError
(
wiaflos::server::core::Tax::
Error
());
return
$taxType
;
return
ERR_USAGE
;
}
# Calculate discount
if
(
!
$discount
->
is_zero
())
{
# Set discountAmount depending on tax mode
my
$discountAmount
=
$totalPrice
->
copy
();
$discountAmount
->
bsub
(
$taxAmount
)
if
(
$detail
->
{
'TaxMode'
}
eq
"
incl
"
);
$discountAmount
->
bsub
(
$taxAmount
)
if
(
$detail
->
{
'TaxMode'
}
eq
"
1
"
);
# Get discount multiplier
my
$tmpDisc
=
$discount
->
copy
();
...
...
@@ -913,13 +913,14 @@ sub postSupplierInvoice
$quantity
->
precision
(
-
4
);
$quantity
->
badd
(
$row
->
{
'Quantity'
});
# Calculate final prices
my
$itemInclPrice
=
Math::
BigFloat
->
new
(
$row
->
{
'Price'
});
$itemInclPrice
->
badd
(
$row
->
{
'TaxAmount'
})
if
(
$row
->
{
'TaxMode'
}
eq
"2"
);
# Calculate the Excl price, subtract tax if the tax is included
my
$itemExclPrice
=
Math::
BigFloat
->
new
(
$row
->
{
'Price'
});
$itemExclPrice
->
bsub
(
$row
->
{
'TaxAmount'
})
if
(
$row
->
{
'TaxMode'
}
eq
"1"
);
# Calculate the Excl price, add tax if the tax is excluded
my
$itemInclPrice
=
Math::
BigFloat
->
new
(
$row
->
{
'Price'
});
$itemInclPrice
->
badd
(
$row
->
{
'TaxAmount'
})
if
(
$row
->
{
'TaxMode'
}
eq
"2"
);
# Pull in tax GL account and addup what we need to post
if
(
defined
(
$taxEntries
{
$row
->
{
'TaxGLAccountID'
}}))
{
$taxEntries
{
$row
->
{
'TaxGLAccountID'
}}
->
badd
(
$row
->
{
'TaxAmount'
});
...
...
wiaflos/server/core/SupplierCreditNotes.pm
View file @
6895f4b3
...
...
@@ -979,16 +979,18 @@ sub postSupplierCreditNote
my
$itemInclPrice
=
$crnUnitPrice
->
copy
();
my
$itemExclPrice
=
$crnUnitPrice
->
copy
();
# Work out tax amount
my
(
$taxAmount
)
=
wiaflos::server::core::Tax::
getTaxAmount
(
$fi
->
{
'TaxMode'
},
$fi
->
{
'TaxRate'
},
$crnUnitPrice
->
bstr
());
# Adjust tax on item if its already including
if
(
$fi
->
{
'TaxMode'
}
eq
"2"
)
{
$itemInclPrice
->
badd
(
$taxAmount
);
}
elsif
(
$fi
->
{
'TaxMode'
}
eq
"1"
)
{
$itemExclPrice
->
bsub
(
$taxAmount
);
}
else
{
setError
(
"TaxMode '"
.
$fi
->
{
'TaxMode'
}
.
"' invalid"
);
my
(
$taxAmount
,
$taxMode
)
=
wiaflos::server::core::Tax::
getTaxAmount
(
$fi
->
{
'TaxMode'
},
$fi
->
{
'TaxRate'
},
$crnUnitPrice
->
bstr
());
if
(
!
defined
(
$taxAmount
)
||
!
defined
(
$taxMode
))
{
setError
(
wiaflos::server::core::Tax::
Error
());
DBRollback
();
return
ERR_UNKNOWN
;
return
ERR_USAGE
;
}
# If tax is including, work out the excl price by subtracting the tax amount
if
(
$taxMode
eq
"1"
)
{
$itemExclPrice
->
bsub
(
$taxAmount
);
# If tax is excluding, work out the incl price by adding the tax amount
}
elsif
(
$taxMode
eq
"2"
)
{
$itemInclPrice
->
badd
(
$taxAmount
);
}
my
$itemTaxAmount
=
Math::
BigFloat
->
new
(
$taxAmount
);
...
...
@@ -1014,7 +1016,7 @@ sub postSupplierCreditNote
$crnItemPriceBalance
->
bsub
(
$allocatePrice
);
my
$totalTaxAmount
=
Math::
BigFloat
->
new
(
$itemTaxAmount
)
->
bmul
(
$allocateQty
);
# Tax hack, if the price is including tax, we need to equal out the item price balance
if
(
$
fi
->
{
'TaxMode'
}
eq
"1"
)
{
if
(
$
taxMode
eq
"1"
)
{
$crnItemPriceBalance
->
bsub
(
$totalTaxAmount
);
}
...
...
@@ -1094,7 +1096,7 @@ sub postSupplierCreditNote
$crnItemPriceBalance
->
bsub
(
$allocatePrice
);
my
$totalTaxAmount
=
Math::
BigFloat
->
new
(
$itemTaxAmount
)
->
bmul
(
$allocateQty
);
# Tax hack, if the price is including tax, we need to equal out the item price balance
if
(
$
fi
->
{
'TaxMode'
}
eq
"1"
)
{
if
(
$
taxMode
eq
"1"
)
{
$crnItemPriceBalance
->
bsub
(
$totalTaxAmount
);
}
...
...
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