Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(minor): set tax values for item variants #37674

Merged
merged 2 commits into from
Oct 29, 2023

Conversation

GursheenK
Copy link
Member

Bug
When get_mapped_doc is used to create say a Sales Invoice from a Sales Order and the Order has the Variant of an Item present in it, the system tries to update the taxes for that variant. However, this takes place even if the Variant already has some rows in the taxes table.

Fix

  • Only update the taxes for Variant if the child table is empty.
  • Set all values for the child table and not just the item tax template value, since either the valid_from or maximum_net_rate is required for sorting the taxes.

no-docs

@github-actions github-actions bot added needs-tests This PR needs automated unit-tests. stock labels Oct 25, 2023
@codecov
Copy link

codecov bot commented Oct 25, 2023

Codecov Report

Merging #37674 (d436a40) into develop (74a0d64) will increase coverage by 0.00%.
Report is 27 commits behind head on develop.
The diff coverage is 85.26%.

@@           Coverage Diff            @@
##           develop   #37674   +/-   ##
========================================
  Coverage    67.32%   67.32%           
========================================
  Files          757      757           
  Lines        60144    60144           
========================================
+ Hits         40491    40492    +1     
+ Misses       19653    19652    -1     
Files Coverage Δ
erpnext/accounts/utils.py 73.12% <100.00%> (ø)
...xt/buying/doctype/purchase_order/purchase_order.py 78.99% <ø> (ø)
erpnext/controllers/stock_controller.py 82.02% <ø> (ø)
erpnext/selling/doctype/sales_order/sales_order.py 79.09% <100.00%> (ø)
erpnext/stock/get_item_details.py 83.06% <100.00%> (ø)
...next/stock/report/reserved_stock/reserved_stock.py 46.66% <ø> (ø)
erpnext/stock/doctype/item/item.py 85.01% <0.00%> (ø)
erpnext/stock/doctype/pick_list/pick_list.py 78.77% <85.71%> (ø)
...stock/doctype/purchase_receipt/purchase_receipt.py 91.47% <93.75%> (ø)
erpnext/stock/doctype/stock_entry/stock_entry.py 82.30% <94.73%> (ø)
... and 1 more

... and 1 file with indirect coverage changes

@bosue
Copy link
Contributor

bosue commented Oct 25, 2023

Particularly the days around a change in tax rate, either of the two or even both tax rates may be correct depending on the (respective) Delivery date.

There are circumstances where you‘ll need the pre-1 July tax rate even if you‘re in July already, and there are circumstances where you need the post-1 July tax rate ahead of 1 July. This may all be tied to the actual Delivery or Service date, which may only be finalized later in the process.

I therefore think the proper fix is versioning tax rates, tax accounts etc. in a timeline that doesn‘t live in the transaction, so there‘s no need to update individual transactions. Or updating taxes only upon saving resp. submission of the new transaction and then coupled with a notice or warning.

There may be an expectation that the system doesn‘t automatically change any data enclosed in a DocType when duplicating or mapping ad doc to another doc.

“Only update if…“ seems a bit arbitrary, thus hard to match any expectation, so that‘s why I‘m weighing in. Optimally it should be either always or never, and in the case of taxes, where consistency is needed, it should be always, the open questions only being when, on which data basis and silently or with a warning? We already have too many subtle exceptions in place.

But I may be misunderstanding / misinterpreting something, sry in this case. 😏

@deepeshgarg007 deepeshgarg007 merged commit 1081df3 into frappe:develop Oct 29, 2023
14 checks passed
s-aga-r pushed a commit that referenced this pull request Oct 29, 2023
* fix: copy all child fields to item variant

(cherry picked from commit 5deba1b)

* fix: only update if variant table empty

(cherry picked from commit d436a40)

---------

Co-authored-by: Gursheen Anand <gursheen@frappe.io>
s-aga-r pushed a commit that referenced this pull request Oct 29, 2023
* fix: copy all child fields to item variant

(cherry picked from commit 5deba1b)

* fix: only update if variant table empty

(cherry picked from commit d436a40)

---------

Co-authored-by: Gursheen Anand <gursheen@frappe.io>
@bosue
Copy link
Contributor

bosue commented Oct 29, 2023

Hm, okay, even better if I was wrong.

frappe-pr-bot pushed a commit that referenced this pull request Oct 31, 2023
# [14.46.0](v14.45.4...v14.46.0) (2023-10-31)

### Bug Fixes

* add regional support to extend purchase gl entries ([d02ebd6](d02ebd6))
* avoid name clash in delivery stop (backport [#37306](#37306)) ([#37701](#37701)) ([556095d](556095d))
* Cash flow mapping fix ([#37522](#37522)) ([8e31379](8e31379))
* close employee loan on write off ([#37638](#37638)) ([922ace4](922ace4))
* **defaults:** apply discount and provisonal defaults from item group and brand if available (backport [#37466](#37466)) ([#37703](#37703)) ([a0893dd](a0893dd))
* **delivery:** rename dt fetch stop action (backport [#37605](#37605)) ([#37606](#37606)) ([8660faa](8660faa))
* GL Entries for receiving non CWIP assets using Purchase Receipt ([#37660](#37660)) ([80774e2](80774e2))
* incorrect cost center in the purchase invoice (backport [#37591](#37591)) ([#37609](#37609)) ([50daf70](50daf70))
* incorrect material request quantity in production plan ([#37785](#37785)) ([25718d9](25718d9))
* incorrect process loss validation for multiple finished items (backport [#37576](#37576)) ([#37656](#37656)) ([638c271](638c271))
* indexing on Delivery Note Item (backport [#37766](#37766)) ([#37777](#37777)) ([9b66a06](9b66a06))
* make changes that enable gantt view for job cards (backport [#37661](#37661)) ([#37756](#37756)) ([712ddb7](712ddb7))
* **minor:** filter bank accounts in bank statement import ([#37525](#37525)) ([1cb9f4c](1cb9f4c))
* **minor:** filter tax template based on company in subscription ([#37562](#37562)) ([c05e0a4](c05e0a4))
* **minor:** set tax values for item variants (backport [#37674](#37674)) ([#37738](#37738)) ([fabcfc1](fabcfc1))
* negative current qty causing recursion issue ([#37752](#37752)) ([f1407bc](f1407bc))
* overallocation on Payment with PO/SO ([d71b885](d71b885))
* purchase receipt with stock and asset items ([375be8c](375be8c))
* remove from or target warehouse for non internal transfer entries (backport [#37612](#37612)) ([#37628](#37628)) ([78b7c26](78b7c26))
* set correct `purchase_sle` in `get_last_sle()` ([#37708](#37708)) ([86cf156](86cf156))
* set empty value for tax template in item details ([#37496](#37496)) ([ec208b8](ec208b8))
* typeerror on tds payable monthly report ([fea27d5](fea27d5))
* update existing doc if possible ([89f07dc](89f07dc))
* wrong german translation ([#37658](#37658)) ([fa5780c](fa5780c))

### Features

* allow return of components for SCO that don't have SCR created (backport [#37686](#37686)) ([#37692](#37692)) ([e96d5b3](e96d5b3))
* **delivery:** link to delivery notes list view from delivery trip (backport [#37604](#37604)) ([#37695](#37695)) ([c58fefb](c58fefb))

### Reverts

* Revert "fix: set empty value for tax template in item details (#37496)" ([ca13816](ca13816)), closes [#37496](#37496) [#37496](#37496)
frappe-pr-bot pushed a commit that referenced this pull request Nov 16, 2023
# [15.1.0](v15.0.0...v15.1.0) (2023-11-16)

### Bug Fixes

* `PermissionError` while creating DN from SO (backport [#37758](#37758)) ([#37768](#37768)) ([e742310](e742310))
* `TypeError` in PR for non-stock item (backport [#37819](#37819)) ([#37842](#37842)) ([847dd9e](847dd9e))
* add translation wrapper (backport [#37911](#37911)) ([#37947](#37947)) ([915ca47](915ca47))
* asset depreciation ledger (backport [#37991](#37991)) ([#37993](#37993)) ([b3562bd](b3562bd))
* avoid name clash in delivery stop (backport [#37306](#37306)) ([#37702](#37702)) ([bfd240a](bfd240a))
* close `Credit Limit Crossed` dialog (backport [#38052](#38052)) ([#38059](#38059)) ([cff56d4](cff56d4))
* COA Importer app related issues ([#37238](#37238)) ([d5bf7a0](d5bf7a0))
* consider reserved stock while cancelling a stock transaction (backport [#37754](#37754)) ([#37906](#37906)) ([e0b0b6b](e0b0b6b))
* credit note receive payment entry ([9781f9b](9781f9b))
* **customer:** contact creation for companies ([#38055](#38055)) ([fc09d75](fc09d75))
* **customer:** quick form and integration fixes ([#37386](#37386)) ([02e2258](02e2258))
* **defaults:** apply discount and provisonal defaults from item group and brand if available (backport [#37466](#37466)) ([#37704](#37704)) ([f382b1c](f382b1c))
* deprecate unused create_contact ([6f2b34e](6f2b34e))
* don't reset rate if greater than zero in standalone debit note (backport [#37935](#37935)) ([#37941](#37941)) ([e156564](e156564))
* force delete removed report (backport [#37668](#37668)) ([#37670](#37670)) ([a871d95](a871d95))
* handle gle for standalone credit and debit notes ([6e463b1](6e463b1))
* Identical items are added line by line instead of grouped together in POS ([#37986](#37986)) ([011cf3d](011cf3d))
* ignore Stock Reservation for future dated PR (backport [#37979](#37979)) ([#37990](#37990)) ([d74f0ef](d74f0ef))
* In-Transit Warehouse company filter (backport [#37796](#37796)) ([#37798](#37798)) ([254ec2c](254ec2c))
* incorrect material request quantity in production plan (backport [#37785](#37785)) ([#37790](#37790)) ([8b3c4a9](8b3c4a9))
* indentation issue in the Production Plan Summary report (backport [#38019](#38019)) ([#38069](#38069)) ([6d325a4](6d325a4))
* indexing on Delivery Note Item (backport [#37766](#37766)) ([#37778](#37778)) ([98a7c17](98a7c17))
* link between parent and child procedure (backport [#37903](#37903)) ([#37944](#37944)) ([a065f22](a065f22))
* list index out of range (backport [#37890](#37890)) ([#37920](#37920)) ([e71ef10](e71ef10))
* make `Material Request Item` required if `Material Request` is set in PO (backport [#37928](#37928)) ([#37937](#37937)) ([7ad0817](7ad0817))
* make adjustment entry using stock reconciliation (backport [#37995](#37995)) ([#38009](#38009)) ([b23fa1f](b23fa1f))
* make changes that enable gantt view for job cards (backport [#37661](#37661)) ([#37757](#37757)) ([f132552](f132552))
* make item field read-only in batch (backport [#38010](#38010)) ([#38034](#38034)) ([99b7cdb](99b7cdb))
* make project page translatable (backport [#37743](#37743)) ([#37801](#37801)) ([59e67cd](59e67cd))
* Mark Status field in Payment Entry 'no_copy'. ([#38000](#38000)) ([3c0f8b1](3c0f8b1))
* minor change added to test_case ([b1714ec](b1714ec))
* minor issue ([24be044](24be044))
* **minor:** set tax values for item variants (backport [#37674](#37674)) ([#37739](#37739)) ([5c46d74](5c46d74))
* new logic for handling revaluation journals ([fb71a6e](fb71a6e))
* Not able to save subcontracting receipt ([#38085](#38085)) ([a874997](a874997))
* **packed_item:** ensure proper names for ref integrity (backport [#37597](#37597)) ([#37794](#37794)) ([9aa29f5](9aa29f5))
* permission error while creating Supplier Quotation from Portal (backport [#37864](#37864)) ([#37871](#37871)) ([be8399f](be8399f))
* **plaid:** Do not sync pending transactions ([2149de4](2149de4))
* POS change amount gl entry with no amount ([#37799](#37799)) ([fd7a768](fd7a768))
* Quality Inspection Parameter migration - DuplicateEntryError due to case sensitivity (backport [#37499](#37499)) ([#37917](#37917)) ([7d0f1f4](7d0f1f4))
* remove from or target warehouse for non internal transfer entries (backport [#37612](#37612)) ([#37627](#37627)) ([3155790](3155790))
* remove validation for negative outstanding invoices ([8602a3e](8602a3e))
* remove voucher type and no for Item and Warehouse based reposting ([b96be67](b96be67))
* sales order not assigned to territory orders (backport [#37905](#37905)) ([#38025](#38025)) ([40cc3a7](40cc3a7))
* skip check for removed validation ([22e58e0](22e58e0))
* sort by section code ([06bb1a3](06bb1a3))
* standard submit perm in repost ledger for editable invoices (backport [#37826](#37826)) ([#37855](#37855)) ([71361f7](71361f7))
* status for over delivery or billing ([95d6742](95d6742))
* test for invoice returns ([a89af58](a89af58))
* type error on new payment entry ([5937135](5937135))
* typo in AR report ([fc3d303](fc3d303))
* typo in function name and msg (backport [#37722](#37722)) ([#37741](#37741)) ([4819fde](4819fde))
* unsupported operand type(s) for serial and batch bundle in POS Invoice (backport [#37721](#37721)) ([#37731](#37731)) ([b03c65f](b03c65f))
* use get_all instead of get_list ([2a5b3bd](2a5b3bd))
* validate so item with qtn ([71538cf](71538cf))
* valuation rate for the subcontracting receipt supplied items with Serial and Batch Bundle (backport [#38094](#38094)) (backport [#38097](#38097)) ([#38101](#38101)) ([880cea5](880cea5))

### Features

* **accounts_receivable:** test_case added for multi-select customer group ([848efe8](848efe8))
* add cols for supplier inv details ([e51e5b3](e51e5b3))
* allow return of components for SCO that don't have SCR created (backport [#37686](#37686)) ([#37693](#37693)) ([4044325](4044325))
* auto reserve stock for Sales Order on purchase (backport [#37603](#37603)) ([#37648](#37648)) ([da5bf50](da5bf50))
* **delivery:** link to delivery notes list view from delivery trip (backport [#37604](#37604)) ([#37696](#37696)) ([08ea62f](08ea62f))
* multi-select customer group in AR Report ([fff294f](fff294f))
* proprietorship & partnership options in entity type ([6df125a](6df125a))
* reserved production plan sub assembly items (backport [#37884](#37884)) ([#37927](#37927)) ([df90fd7](df90fd7))
* settings page for repost ([c047fd7](c047fd7))
* **Stock Balance:** add filters from route (backport [#37836](#37836)) ([#37840](#37840)) ([fad8228](fad8228))

### Performance Improvements

* Add index to supplier invoice field (backport [#37861](#37861)) ([#37863](#37863)) ([b1982a6](b1982a6))
* index return against for purchase invoice (backport [#37881](#37881)) ([#37883](#37883)) ([febd20a](febd20a))
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport version-14-hotfix backport to version 14 backport version-15-hotfix needs-tests This PR needs automated unit-tests. stock
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants